Commit dcf465142573f68cc73018d0adf868bbed3dea53

Cleaned up the Appcast wiki pages

Commit diff

app/helpers/bluecloth_helper.rb

 
99 #TODO include this in header
1010 out << "<style>#{CodeRay::Encoders[:html]::CSS.new(:appcast).stylesheet}</style>"
1111 out << "<h1 class='pagetitle'>"
12 out << @project.title + ' ' if @project != nil
12 if @project != nil
13 out << @project.title
14 out << ' ' if @project.title.size > 0
15 end
1316 out << @wiki.title << "</h1>\n"
1417 bc = BlueCloth::new(@wiki.page)
1518 out << parse_coderay(bc.to_html)
toggle raw diff

app/models/project.rb.orig

 
0class Project < ActiveRecord::Base
1 acts_as_taggable
2
3 belongs_to :user
4 has_many :comments, :dependent => :destroy
5 has_many :repositories, :order => "repositories.mainline desc, repositories.created_at asc",
6 :dependent => :destroy
7 has_one :mainline_repository, :conditions => ["mainline = ?", true],
8 :class_name => "Repository"
9 has_many :repository_clones, :conditions => ["mainline = ?", false],
10 :class_name => "Repository"
11
12 # Appcast membership system
13 if $application_mode == MODE_APPCAST then
14 belongs_to :wiki
15 has_many :members, :dependent => :destroy
16 has_many :users, :through => :members
17 has_many :articles
18 end
19
20
21 is_indexed :fields => ["title", "description", "slug"],
22 :concatenate => [
23 { :class_name => 'Tag',
24 :field => 'name',
25 :as => 'category',
26 :association_sql => "LEFT OUTER JOIN taggings ON taggings.taggable_id = projects.id " +
27 "AND taggings.taggable_type = 'Project' LEFT OUTER JOIN tags ON taggings.tag_id = tags.id"
28 }],
29 :include => [{
30 :association_name => "user",
31 :field => "login",
32 :as => "user"
33 }]
34
35
36 URL_FORMAT_RE = /^(http|https|nntp):\/\//.freeze
37 validates_presence_of :title, :user_id, :slug
38 validates_uniqueness_of :slug, :case_sensitive => false
39 validates_format_of :slug, :with => /^[a-z0-9_\-]+$/i,
40 :message => "must match something in the range of [a-z0-9_\-]+"
41 validates_format_of :home_url, :with => URL_FORMAT_RE,
42 :if => proc{|record| !record.home_url.blank? },
43 :message => "Must begin with http(s)"
44 validates_format_of :mailinglist_url, :with => URL_FORMAT_RE,
45 :if => proc{|record| !record.mailinglist_url.blank? },
46 :message => "Must begin with http(s)"
47 validates_format_of :bugtracker_url, :with => URL_FORMAT_RE,
48 :if => proc{|record| !record.bugtracker_url.blank? },
49 :message => "Must begin with http(s)"
50
51 before_validation :downcase_slug
52 after_create :create_mainline_repository
53
54 LICENSES = [
55 'MIT License',
56 'BSD License',
57 'Ruby License',
58 'GNU General Public License version 2(GPLv2)',
59 'GNU General Public License version 3 (GPLv3)',
60<<<<<<< HEAD:app/models/project.rb
61 'GNU Library Public License (LGPL)',
62=======
63 'GNU Lesser General Public License (LGPL)',
64 'GNU Affero General Public License (AGPLv3)',
65>>>>>>> d2dea3016197479bf4c039126ea7dfc7304a6fb2:app/models/project.rb
66 'Mozilla Public License 1.0 (MPL)',
67 'Mozilla Public License 1.1 (MPL 1.1)',
68 'Qt Public License (QPL)',
69 'Python License',
70 'zlib/libpng License',
71 'Apache Software License',
72 'Apple Public Source License',
73 'Perl Artistic License',
74 'Microsoft Permissive License (Ms-PL)',
75 'ISC License',
76 'Lisp Lesser License',
77 'Public Domain',
78 'Other Open Source Initiative Approved License',
79 'Other/Proprietary License',
80 'None',
81 ]
82
83 def self.find_by_slug!(slug)
84 find_by_slug(slug) || raise(ActiveRecord::RecordNotFound)
85 end
86
87 def self.per_page() 20 end
88
89 def self.top_tags(limit = 10)
90 tag_counts(:limit => limit, :order => "count desc")
91 end
92
93 def to_param
94 slug
95 end
96
97 def admin?(candidate)
98 candidate == user
99 end
100
101 def can_be_deleted_by?(candidate)
102 (candidate == user) && (repositories.size == 1)
103 end
104
105 def tag_list=(tag_list)
106 tag_list.gsub!(",", "")
107
108 super
109 end
110
111 def stripped_description
112 description.gsub(/<\/?[^>]*>/, "")
113 # sanitizer = HTML::WhiteListSanitizer.new
114 # sanitizer.sanitize(description, :tags => %w(str), :attributes => %w(class))
115 end
116
117 def to_xml(opts = {})
118 info = Proc.new { |options|
119 builder = options[:builder]
120 builder.owner user.login
121
122 builder.repositories :type => "array" do
123 repositories.each { |repo|
124 builder.repository do
125 builder.id repo.id
126 builder.name repo.name
127 builder.owner repo.user.login
128 end
129 }
130 end
131 }
132 super({:procs => [info]}.merge(opts))
133 end
134
135 protected
136 def create_mainline_repository
137 self.repositories.create!(:user => self.user, :name => "mainline")
138 end
139
140 def downcase_slug
141 slug.downcase! if slug
142 end
143
144
145 #
146 # Appcast specific
147 #
148
149 #public version of .count to filter projects you are not authorised to see
150 def self.public_count (user, curruser)
151 visible_projects = find_by_user(user, curruser)
152 return visible_projects.size
153 end
154
155 #
156 def self.allowed_access (project_id, curruser)
157 projects_allowed = Project.list_for_user(curruser)
158 p = find(:first, :conditions => ["status = '#{:active}' AND projects.id = '" << project_id.to_s << "' AND ( audience = '#{:public}' OR projects.id IN (" << projects_allowed << ") )"])
159 if p != nil then
160 return true
161 else
162 return false
163 end
164 end
165
166 #
167 #FIXME this should maybe show inactive too
168 def self.find_by_user(user, curruser)
169 projects_allowed = Project.list_for_user(curruser)
170 projects_available = Project.list_for_user(user)
171 find(:all, :conditions => ["status = '#{:active}' AND projects.id IN (" << projects_available << ") AND ( audience = '#{:public}' OR projects.id IN (" << projects_allowed << ") )"])
172 end
173
174 # returns all allowed projects
175 def self.find_all_projects (curruser)
176 projects_allowed = Project.list_for_user(curruser)
177 find(:all, :conditions => ["status = '#{:active}' AND ( audience = '#{:public}' OR id IN (" << projects_allowed << ") )"])
178 end
179
180 # returns all public projects (no private regardless of allowed)
181 def self.find_all_active_public_projects (curruser)
182 projects_allowed = Project.list_for_user(curruser)
183 find(:all, :conditions => ["status = '#{:active}' AND ( audience = '#{:public}' AND NOT id IN (" << projects_allowed << ") )"])
184 end
185
186 # returns only allowed, no public
187 def self.find_all_active_member_projects(curruser)
188 find(:all,
189 :joins => "INNER JOIN members ON projects.id = members.project_id AND members.user_id = '#{curruser.id}'",
190 :conditions => ["status = '#{:active}'"]
191 )
192 end
193
194 #
195 def self.find_by_slug_secure(slug, curruser)
196 projects_allowed = Project.list_for_user(curruser)
197 find(:first, :conditions => ["status = '#{:active}' AND slug = '#{slug}' AND ( audience = '#{:public}' OR projects.id IN (" << projects_allowed << ") )"])
198 end
199
200 # takes a list of project_ids e.g. '1','2','3'
201 def self.find_by_list (list, curruser)
202 projects_allowed = Project.list_for_user(curruser)
203 find(:all, :conditions => ["status = '#{:active}' AND id IN (" << list << ") AND ( audience = '#{:public}' AND id IN (" << projects_allowed << ") )"])
204 end
205
206 #
207 # Get a list of project_ids of a user is a members of in the format '1','2','3'
208 # FIXME this should be in a helper I think
209 #
210 def self.list_for_user(user)
211 #if user != nil then
212 # list = ""
213 # projects = Member.find_by_user(user.id)
214 # if projects.size > 0 then
215 # start = true
216 # for project in projects
217 # if not start then
218 # list = list << ","
219 # else
220 # start = false
221 # end
222 # list = list << "'" << project.project_id.to_s << "'"
223 # end
224 # return list
225 # else
226 # return "'1'" # see below
227 # end
228 #else
229 return "'1'" # Project.id 1 is no project (this is a bit of a frig really, without it 2 queries will be needed for all finds)
230 #end
231 end
232
233 def self.tab_settings (tab)
234 case tab
235 when PRJ_TAB_SUMMARY
236 title = "Summary"
237 url_suffix = ""
238 when PRJ_TAB_DOWNLOADS
239 title = "Downloads"
240 url_suffix = "/downloads"
241 when PRJ_TAB_REPOS
242 title = "Repos"
243 url_suffix = "/repos"
244 when PRJ_TAB_ROADMAP
245 title = "Roadmap"
246 url_suffix = "/roadmap"
247 when PRJ_TAB_TICKETS
248 title = "Tickets"
249 url_suffix = "/tickets"
250 when PRJ_TAB_ARTICLES
251 title = "Articles"
252 url_suffix = "/articles"
253 when PRJ_TAB_FORUM
254 title = "Forum"
255 url_suffix = "/forum"
256 when PRJ_TAB_WIKI
257 title = "Wiki"
258 url_suffix = "/wikis"
259 when PRJ_TAB_TIMELINE
260 title = "Timeline"
261 url_suffix = "/timeline"
262 when PRJ_TAB_CONFIG
263 title = "Config"
264 url_suffix = "/config"
265 end
266 return title, url_suffix
267 end
268
269
270
271end
toggle raw diff

test/fixtures/project_descriptions/_appcast.txt

 
0<p><strong>Appcast provides the full stack to manage collaborative software projects online, yourself.</strong></p>
1<p>A personal Sourceforge including a Git repository, blog, wiki and ticketing in one application. This site (Prj2.com) uses Appcast.</p>
2<p>Features include:</p>
3<ul>
4 <li>Git distributed revision control interface (view commits and source tree)</li>
5 <li>Project management system (bug tracking, tickets, forums)</li>
6 <li>Roadmap with milestones, log of historic changes and events</li>
7 <li>Blog to communicate announcements</li>
8 <li>Wiki for project documentation</li>
9 <li>Handles multiple public and private projects</li>
10</ul>
11<p>Appcast is a fork of <a href='http://www.gitorious.org'>Gitorious</a>, is free to download and use under <a href='/wiki/license/gpl/'>GPL</a> and is built using <a href='http://www.rubyonrails.org/'>Rails</a>.</p>
12<p>Further information:</b>
13<ul>
14 <li><a href='/projects/appcast/wikis/appcast-installation-guide'>Installation Guide</a></li>
15 <li><a href='/projects/appcast/wikis/appcast-user-manual'>User Manual</a></li>
16 <li><a href='/projects/appcast/wikis/appcast-dev-notes'>Developer Notes</a></li>
17 <li><a href='/projects/appcast/wikis/appcast-credits'>Credits</a></li>
18</ul>
toggle raw diff

test/fixtures/projects.yml

 
33 id: 2
44 title: "Appcast"
55 summary: 'Rails based source repository, like Sourceforge but with a blog, wiki etc. (as used by <%= SITENAME %>)'
6 description: "<%= File.open("#{RAILS_ROOT}/test/fixtures/project_descriptions/_appcast.txt",'r').read %>"
76 user_id: 1
87 slug: "appcast"
98 license: "GNU General Public License version 2(GPLv2)"
1717noproject:
1818 id: 1
1919 title: "no project"
20 description: "project description"
2120 user_id: 1
2221 slug: "no project"
2322 license: ""
toggle raw diff

test/fixtures/wiki_pages/_appcast_contents.txt

 
1<strong>Appcast provides the full stack to manage collaborative software projects online, yourself.</strong>
1<strong>Thel
2 full stack to manage collaborative Git projects online, yourself.</strong>
23
34
4A personal Sourceforge including a Git repository, blog, wiki and ticketing in one application. This site (Prj2.com) uses Appcast.
5A personal Sourceforge including repository browser, source browser, blog, wiki and ticketing all in one web application. This site uses Appcast.
56
67
78### Features include:
1212* Roadmap with milestones, log of historic changes and events
1313* Blog to communicate announcements
1414* Wiki for project documentation
15* Handles multiple public and private projects
15* Handles multiple public and private projects with memberships
1616
1717Appcast is a fork of <a href='http://www.gitorious.org'>Gitorious</a>, is free to download and use under <a href='/wiki/license/gpl/'>GPL</a> and is built using <a href='http://www.rubyonrails.org/'>Rails</a>.
1818
1919### Further information:
2020
2121* [Installation Guide](/projects/appcast/wikis/appcast-installation-guide)
22* [User Manual](/projects/appcast/wikis/appcast-user-manual)
2322* [Developer Notes](/projects/appcast/wikis/appcast-dev-notes)
2423* [Credits](/projects/appcast/wikis/appcast-credits)
2524
toggle raw diff

test/fixtures/wiki_pages/_appcast_credits.txt

 
1Biggest credit is to Johan Sørensen of [Gitorious](http://www.gitorious.org), which
2this project is a fork of and Tom Preston-Werner who developed [Grit](http://grit.rubyforge.org) (the underlying interface to [Git](http://git.or.cz)).
13
4The credit list includes sources of code either directly used in the project, or read to help figure something out:
25
3These are sources of code, either directly used in the project, or read to help figure something out:
4
5
6*enum-column
7
8*fixture_references
9
10*foreign_key_migrations
11
12*has_many_polymorphs
13
14*paginating_find
15
16*restful_authentication
17
18*[http://mediacloth.rubyforge.org/ MediaCloth] MediaWiki parser (in Ruby)
19
20*[http://www.motiro.org/ Morito] Diff source
21
22* Grit
23
24* Gitorious
25
26
27
28
6* enum-column
7* fixture_references
8* foreign_key_migrations
9* has_many_polymorphs
10* paginating_find
11* restful_authentication
12* Bluecloth
13* Coderay
2914
15Also help appreciated from 'rsl' on #rubyonrails, 'krawek' on #gitorious and 'Ilari', 'Tv' on #git.
toggle raw diff

test/fixtures/wiki_pages/_appcast_dev_notes.txt

 
11
2The reasons for starting Appcast are detailed in the article [http://localhost:3001/2008/2/appcast-dev-team-collaboration Appcast: Dev Team Collaboration].
2The reasons for starting Appcast are detailed in the article [Appcast: Dev Team Collaboration](/2008/2/appcast-dev-team-collaboration).
3
4Appcast has been merged in to Gitorious using a flag $application_mode.
5
6There isn't much CRUD in the project right now, so most of the model is built using fixtures.
7
8The Appcast database migrations start at 400_ and may change until the version has some crud and it's worth bootstrapping.
9
10The comment system for Appcast clashes with the Gitorious one - that won't be fixed for a while.
11
12Currently I'm using this priority list:
13
14* Wiki (CRUD missing)
15* Login system (needs styling and fixing)
16* Journaling (everything except model missing)
17* Events (everything missing)
18* Articles (CRUD missing)
19* Tickets (everything except model missing)
20* Forum (everything missing)
21* User dashboard (everything missing)
22* Admin system
23* Git statistics
24* Documentation
325
4[Appcast/Gitorious Merge Notes](/projects/appcast/wikis/gitorious-merge-notes)
toggle raw diff

test/fixtures/wiki_pages/_appcast_installation_guide.txt

 
1Appcast is still very Alpha, and relies on fixtures to load up the project data as much of the CRUD is unfinished.
12
3This install list is untested and based on some early notes (I will do a clean install if anyone has any issues with it and document it properly, it's not a high priority until someone else needs it)
24
5<pre>
6# Configure a local Git repo to a /project.git named repo (not /project/.git)
37
4 sudo gem install grit
5 sudo gem install mime-types
6
7
8#
9# Installing Gitorious
10#
8# Install source
119sudo apt-get install libonig-dev
1210sudo apt-get install libbluecloth-ruby
1311sudo apt-get install libopenssl-ruby1.8
1412sudo gem install mime-types
15sudo gem install textpow #install all dependencies prompted for
16sudo gem install diff-lcs #needed for rspec
17
18git clone git://gitorious.org/gitorious/mainline.git gitorious
19
20cd gitorious
13sudo gem install bluecloth
14sudo gem install textpow
15sudo gem install diff-lcs
16git clone git://gitorious.org/gitorious/appcast.git appcast
17cd appcast
2118
19# Copy config example to working copy
2220cp config/gitorious.sample.yml config/gitorious.yml
21# Set number_of_displayed_commits and application_mode
22# Set repository_base_path to path your project.git repository is located
23nano config/gitorious.yml
2324
24nano config/gitorious.yml #(add key, Error 500 if you don't, set number_of_displayed_commits and application_mode)
25
26nano config/database.yml #(add database settings)
25# Add database settings
26nano config/database.yml
2727
28# Manually edit the project.yml fixtures with your project name
2829rake db:migrate
2930
30rake spec # test it
31
32
33
3431mongrel_rails start
32</pre>
3533
3634
35<a href='mailto:mtkd@prj.com'>mtkd@prj.com</a>
3736
toggle raw diff

test/fixtures/wiki_pages/_git_crib_sheet.txt

 
11GIT
22
3http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way
43
5Under Ubuntu had to also add git to a new sshusers group to sshusers to AllowGroups in /etc/ssh/sshd_config, used webmin to add the user to groups and to restart ssh
64
75Also note everything is case sensitive
86
7### Useful Resources:
98
9(http://www.kernel.org/pub/software/scm/git/docs/user-manual.html)
10(http://www.sourcemage.org/Git_Guide)
11(http://wiki.sourcemage.org/Git_Guide)
12(http://blog.neontology.com/posts/2007/10/17/git)
13(http://tomayko.com/writings/the-thing-about-git)
1014
15### Installing
1116
12Full GIT user manual:
13
14http://www.kernel.org/pub/software/scm/git/docs/user-manual.html
15http://www.sourcemage.org/Git_Guide
16http://wiki.sourcemage.org/Git_Guide
17http://blog.neontology.com/posts/2007/10/17/git
18http://tomayko.com/writings/the-thing-about-git
19
20Change default Linux editor in ~/.bashrc:
21
17<pre>
18# Change default Linux editor in ~/.bashrc:
2219EDITOR=nano export EDITOR
20</pre>
2321
24
25
26Create a .gitconfig in ~
22<pre>
23# Create a .gitconfig in ~
2724
2825[user]
2926 name = Your Name Comes Here
3027 email = you@yourdomain.example.com
28</pre>
3129
32
33
34Create an ignore file (.gitignore) if not already in your project root
30<pre>
31# Create an ignore file (.gitignore) if not already in your project root
3532
3633# Ignore any file named foo.txt.
3734foo.txt
4040*.[oa]
4141# Ignore directories
4242log/*
43nbproject/*
43</pre>
4444
45### Installing a remote repository
4546
46To commit changes to local repo:
47http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way
48Under Ubuntu had to also add git to a new sshusers group to sshusers to AllowGroups in /etc/ssh/sshd_config, used webmin to add the user to groups and to restart ssh
4749
48git commit -a
4950
51### Useful commands
5052
51To add a new file to local repo:
53<pre>
54# To commit changes to local repo:
55git commit -a
56</pre>
5257
58<pre>
59# To add a new file to local repo:
5360git add <filename>
5461
62# To add all new files to the local repo:
63git add .
64</pre>
65
5566
5667To see the changes:
5768
toggle raw diff

test/fixtures/wiki_pages/_wiki_contents.txt

 
1[Wiki Markdown Guide](/wikis/wiki-markdown-guide)
2
3[Wiki Test Page](/wikis/test-wiki-page)
4
5[Wiki Todo List](/wikis/wiki-todo-list)
6
7[Ubuntu Crib Sheet](/wikis/ubuntu-crib-sheet)
8
9[Ruby Crib Sheet](/wikis/ruby-crib-sheet)
10
11[Rails Crib Sheet](/wikis/rails-crib-sheet)
12
13[Git Crib Sheet](/wikis/git-crib-sheet)
14
15## Heading
16
17some text
18more text
19
20### Projects
21
22* [Appcast](/projects/appcast/wikis/appcast-contents)
1No general wikis
232
243
toggle raw diff

test/fixtures/wiki_pages/_wiki_todo_list.txt

 
1Add this to contents
2
3[Wiki Markdown Guide](/wikis/wiki-markdown-guide)
4
5[Wiki Test Page](/wikis/test-wiki-page)
6
7[Wiki Todo List](/wikis/wiki-todo-list)
8
9[Ubuntu Crib Sheet](/wikis/ubuntu-crib-sheet)
10
11[Ruby Crib Sheet](/wikis/ruby-crib-sheet)
12
13[Rails Crib Sheet](/wikis/rails-crib-sheet)
14
15[Git Crib Sheet](/wikis/git-crib-sheet)
16
17## Heading
18
19some text
20more text
21
22### Projects
23
24* [Appcast](/projects/appcast/wikis/appcast-contents)
25
26
27
28
29
130
231Copy of the old HTML todo list for Wiki
332
toggle raw diff

test/fixtures/wikis.yml