Commit d3983e356a7744e43ea1ceb2b20a410b70816a62

Started articles CRUD
Renamed config settings

Commit diff

HACKING

 
2424
25251. Do the normal rails app stuff (database.yml etc.)
2626
272. Rename the config/gitorious.sample.yml file to gitorious.yml, and update it with your changes.
272. Rename the config/gitorious.sample.yml file to gitlab.yml, and update it with your changes.
2828
293a. If you want real project data, find a project, set the 'ready' status to true, create a bare git repository (git --bare init) in the directory GitoriousConfig['repository_base_path']/#{project.slug}/#{repository.name}.git, and push something to that repository (cd to a git repository with commits and do "git push path/to/the/bare/repository/you/just/created master").
293a. If you want real project data, find a project, set the 'ready' status to true, create a bare git repository (git --bare init) in the directory GitlabConfig['repository_base_path']/#{project.slug}/#{repository.name}.git, and push something to that repository (cd to a git repository with commits and do "git push path/to/the/bare/repository/you/just/created master").
3030
31313b. OR run the script/task_performer and let it create the repository for you (remember to do step 2 first)
3232
toggle raw diff

app/controllers/application.rb

 
22# Likewise, all the methods added will be available for all controllers.
33
44class ApplicationController < ActionController::Base
5 session :session_key => '_ks1_session_id', :secret => GitoriousConfig["cookie_secret"]
5 session :session_key => '_ks1_session_id', :secret => GitlabConfig["cookie_secret"]
66 include AuthenticatedSystem
77 include ExceptionNotifiable
88
toggle raw diff

app/models/git/repository.rb

 
4646 end
4747
4848 def clone_url
49 "git://#{GitoriousConfig['gitorious_host']}/#{gitdir}"
49 "git://#{GitlabConfig['gitlab_host']}/#{gitdir}"
5050 end
5151
5252 def http_clone_url
53 "http://git.#{GitoriousConfig['gitorious_host']}/#{gitdir}"
53 "http://git.#{GitlabConfig['gitlab_host']}/#{gitdir}"
5454 end
5555
5656 def push_url
57 "git@#{GitoriousConfig['gitorious_host']}:#{gitdir}"
57 "git@#{GitlabConfig['gitlab_host']}:#{gitdir}"
5858 end
5959
6060 def full_repository_path
121121 end
122122
123123 def paginated_commits(tree_name, page, per_page = 30)
124 per_page = GitoriousConfig["number_of_displayed_commits"]
124 per_page = GitlabConfig["number_of_displayed_commits"]
125125 page = (page || 1).to_i
126126 total = git.commit_count(tree_name)
127127 offset = (page - 1) * per_page
236236 end
237237
238238 def self.full_path_from_partial_path(path)
239 File.expand_path(File.join(GitoriousConfig["repository_base_path"], path))
239 File.expand_path(File.join(GitlabConfig["repository_base_path"], path))
240240 end
241241end
toggle raw diff

app/models/mailer.rb

 
22 def signup_notification(user)
33 setup_email(user)
44 @subject += 'Please activate your new account'
5 @body[:url] = "http://#{GitoriousConfig['gitorious_host']}/users/activate/#{user.activation_code}"
5 @body[:url] = "http://#{GitlabConfig['gitlab_host']}/users/activate/#{user.activation_code}"
66
77 end
88
1818 @body[:cloner] = repository.user
1919 @body[:project] = repository.project
2020 @body[:repository] = repository
21 @body[:url] = "http://#{GitoriousConfig['gitorious_host']}/p/#{repository.project.slug}/repos/#{repository.name}"
21 @body[:url] = "http://#{GitlabConfig['gitlab_host']}/p/#{repository.project.slug}/repos/#{repository.name}"
2222 end
2323
2424 def merge_request_notification(merge_request)
2626 @subject += %Q{#{merge_request.source_repository.user.login} has requested a merge in #{merge_request.target_repository.project.title}}
2727 @body[:merge_request] = merge_request
2828 @body[:project] = merge_request.target_repository.project
29 url = "http://#{GitoriousConfig['gitorious_host']}/p/#{merge_request.target_repository.project.slug}"
29 url = "http://#{GitlabConfig['gitlab_host']}/p/#{merge_request.target_repository.project.slug}"
3030 url << "/repos/#{merge_request.target_repository.name}"
3131 url << "/merge_requests/#{merge_request.id}"
3232 @body[:url] = url
4141 protected
4242 def setup_email(user)
4343 @recipients = "#{user.email}"
44 @from = "Gitorious <no-reply@#{GitoriousConfig['gitorious_host']}>"
44 @from = "Gitorious <no-reply@#{GitlabConfig['gitlab_host']}>"
4545 @subject = "[Gitorious] "
4646 @sent_on = Time.now
4747 @body[:user] = user
toggle raw diff

app/models/ticket.rb

 
1require "digest/sha1"
2
13class Ticket < ActiveRecord::Base
24
35
5959 ORDER BY milestones.due_date DESC, priority")
6060 end
6161
62 def self.generate_key(length = 6)
63 #FIXME I don't think this is doing what it intends to do
64 Digest::SHA1.hexdigest(Time.now.to_s + rand(423845).to_s)[1..length]
65 end
6266
63
64 #
65
66
6767end
6868
toggle raw diff

app/views/articles/ac_project_edit.html.erb

 
1<%= render :partial => "projects/ac_project_header", :locals => { :tab => PRJ_TAB_ARTICLES,
2 :subtab => PRJ_TAB_ARTICLES_EDIT,
3 :project => @project,
4 :pagetitle => @title } %>
5
6<%= div_formattedtext_open %>
7
8<%= error_messages_for :wiki %>
9
10<% form_for :wiki, :url => project_wiki_path(@project.slug, @wiki.slug), :html => {:method => :put, :name => 'editwiki', :id => 'input'} do |f| -%>
11
12 <h2><%= @title %></h2>
13
14 <p>The wiki title is automatically prefixed with the project title when the wiki is displayed.</p>
15
16 <%= render :partial => "ac_form", :locals => { :f => f } %>
17
18 <p>
19 <%= f.label :slug -%><br/>
20 <%= f.text_field :slug -%>
21 </p>
22
23 <p>
24 <%= link_to "Cancel", project_wiki_path(@project.slug, @wiki.slug) %>
25 <a href="javascript:document.editwiki.submit();">Preview</a>
26 <a href="javascript:document.editwiki.submit();">Update</a>
27 </p>
28
29<% end -%>
30
31<br />
32<br />
33
34<%= render_wiki %>
35<%= div_formattedtext_close %>
36
37<%= render :partial => "projects/ac_project_footer" %>
toggle raw diff

app/views/comments/index.atom.builder

 
33 feed.updated((@comments.blank? ? Time.now : @comments.first.created_at))
44
55 @comments.each do |comment|
6 item_url = "http://#{GitoriousConfig['gitorious_host']}" + project_repository_comments_path(@project,@repository)
6 item_url = "http://#{GitlabConfig['gitlab_host']}" + project_repository_comments_path(@project,@repository)
77 feed.entry(comment, :url => item_url) do |entry|
88 entry.title("#{comment.user.login}: #{truncate(comment.body, 30)}")
99 entry.content(comment.body)
toggle raw diff

app/views/layouts/application.html.erb

 
1515<body>
1616<div id='page'>
1717
18 <% unless GitoriousConfig["system_message"].blank? -%>
18 <% unless GitlabConfig["system_message"].blank? -%>
1919 <div id="system_message">
20 <p><strong>System notice:</strong> <%= GitoriousConfig["system_message"] -%></p>
20 <p><strong>System notice:</strong> <%= GitlabConfig["system_message"] -%></p>
2121 </div>
2222 <% end -%>
2323
toggle raw diff

app/views/logs/feed.atom.builder

 
33 feed.updated((@commits.blank? ? nil : @commits.first.committed_date))
44
55 @commits.each do |commit|
6 item_url = "http://#{GitoriousConfig['gitorious_host']}" + project_repository_commit_path(@project, @repository, commit.id)
6 item_url = "http://#{GitlabConfig['gitlab_host']}" + project_repository_commit_path(@project, @repository, commit.id)
77 commit_stat_data = commit.stats.files.map do |file, stats|
88 [stats[:insertions].to_s.ljust(8, " "), stats[:deletions].to_s.ljust(8, " "), file].join
99 end
toggle raw diff

app/views/mailer/activation.rhtml

 
11Hello <%= @user.login %>,
22
3your account has been activated. You can add your public SSH key here http://<%= GitoriousConfig['gitorious_host'] -%>/account as well as change your details.
3your account has been activated. You can add your public SSH key here http://<%= GitlabConfig['gitlab_host'] -%>/account as well as change your details.
44
55Thank you
66
7http://<%= GitoriousConfig['gitorious_host'] %>
7http://<%= GitlabConfig['gitlab_host'] %>
88
toggle raw diff

app/views/mailer/forgotten_password.rhtml

 
66
77Thank you
88
9http://<%= GitoriousConfig['gitorious_host'] %>
9http://<%= GitlabConfig['gitlab_host'] %>
toggle raw diff

app/views/mailer/merge_request_notification.rhtml

 
1313
1414Thank you
1515
16http://<%= GitoriousConfig['gitorious_host'] %>
16http://<%= GitlabConfig['gitlab_host'] %>
toggle raw diff

app/views/mailer/new_repository_clone.rhtml

 
66
77Thank you
88
9http://<%= GitoriousConfig['gitorious_host'] %>
9http://<%= GitlabConfig['gitlab_host'] %>
toggle raw diff

app/views/mailer/signup_notification.rhtml

 
11Hello,
22
3Your <%= GitoriousConfig['gitorious_host'] -%> account has been created, your username is <%= @user.login %>
3Your <%= GitlabConfig['gitlab_host'] -%> account has been created, your username is <%= @user.login %>
44
55Please visit this url to activate your account:
66
99
1010Thank you
1111
12http://<%= GitoriousConfig['gitorious_host'] %>
12http://<%= GitlabConfig['gitlab_host'] %>
toggle raw diff

app/views/projects/index.atom.builder

 
33 feed.updated((@projects.blank? ? Time.now : @projects.first.created_at))
44
55 @projects.each do |project|
6 item_url = "http://#{GitoriousConfig['gitorious_host']}" + project_path(project)
6 item_url = "http://#{GitlabConfig['gitlab_host']}" + project_path(project)
77 feed.entry(project, :url => item_url) do |entry|
88 entry.title(project.title)
99 entry.content(project.description)
toggle raw diff

app/views/shared/_ac_article_list.html.erb

 
11<table class='public' width='100%'>
2<tr>
3 <th></th>
4 <th width=<%= STYLE_TABLE_COL_WIDTH_DDMMYYHHMM %>>Created</th>
2<thead>
3 <th style='width: 1px;'></th>
4 <th width='<%= STYLE_TABLE_COL_WIDTH_DDMMYYHHMM %>'>Created</th>
55<% if list_type == ART_LIST_USER %>
6 <th width=<%= STYLE_TABLE_COL_WIDTH_PROJECT_NAME %>>Project</th>
6 <th width='<%= STYLE_TABLE_COL_WIDTH_PROJECT_NAME %>'>Project</th>
77<% end %>
8 <th width=<%= STYLE_TABLE_COL_WIDTH_ARTICLE_TITLE %>>Title</th>
9 <th>Type, Category</th>
8 <th>Title</th>
9 <th width='160'>Type, Category</th>
1010<% if list_type == ART_LIST_PROJECT %>
11 <th>User</th>
11 <th width='<%= STYLE_TABLE_COL_WIDTH_USER_NAME %>'>User</th>
1212<% end %>
13 <th>Status</th>
14 <th>Comm.</th>
15 <th>Views</th>
16 <th colspan='3'></th>
17</tr>
13<% if @is_member %>
14 <th width='80'>Status</th>
15 <th width='50'>Comm.</th>
16 <th width='50'>Views</th>
17 <th colspan='2'></th>
18<% end %>
19</thead>
1820
1921<% for article in articles %>
2022<tr>
2123 <td style='width: 1px; background-color: <%= article_type_color(article.article_type) %>'></td>
22 <td width=<%= STYLE_TABLE_COL_WIDTH_DDMMYYHHMM %>><%= format_datetime_ddmmyyhhmm(article.created_at) %></td>
24 <td width='<%= STYLE_TABLE_COL_WIDTH_DDMMYYHHMM %>'><%= format_datetime_ddmmyyhhmm(article.created_at) %></td>
2325<% if list_type == ART_LIST_USER %>
24 <td width=<%= STYLE_TABLE_COL_WIDTH_PROJECT_NAME %>>PROJECT NAME</td>
26 <td width='<%= STYLE_TABLE_COL_WIDTH_PROJECT_NAME %>'>PROJECT NAME</td>
2527<% end %>
2628 <td><%= link_to article.title, article_permalink_path(article) %></td>
27 <td width=160><%= link_to article.article_type.to_s.capitalize, article_type_path(article.article_type) %>, <%= link_to article.category.name, article_category_path(article.category.slug) %></td>
29 <td><%= link_to article.article_type.to_s.capitalize, article_type_path(article.article_type) %>, <%= link_to article.category.name, article_category_path(article.category.slug) %></td>
2830<% if list_type == ART_LIST_PROJECT %>
29 <td width=<%= STYLE_TABLE_COL_WIDTH_USER_NAME %>><%= link_to article.user.fullname, profile_path(article.user.slug) %></td>
31 <td><%= link_to article.user.fullname, profile_path(article.user.slug) %></td>
3032<% end %>
31 <td width=80><%= article.status.to_s.capitalize %></td>
32 <td align=center width=50><% #article_comment_count(article) %></td>
33 <td align=center width=50><%= article.views %></td>
34 <td width=<%= STYLE_TABLE_COL_WIDTH_ACTION_SHORT %>><%= link_to("Edit", edit_project_article_path(article.project.slug, article.id)) %></td>
35 <td width=<%= STYLE_TABLE_COL_WIDTH_ACTION_SHORT %>><%= link_to("Del.", project_article_path(article.project.slug, article.id), :action => "destroy") %></td>
33<% if @is_member %>
34 <td><%= article.status.to_s.capitalize %></td>
35 <td align=center><%= 0 %></td>
36 <td align=center><%= article.views %></td>
37 <td width=<%= STYLE_TABLE_COL_WIDTH_ACTION_SHORT %>><%= link_to("Edit", edit_project_article_path(@project.slug, article.id)) %></td>
38 <td width=<%= STYLE_TABLE_COL_WIDTH_ACTION_SHORT %>><%= link_to("Del.", project_article_path(@project.slug, article.id), :action => "destroy") %></td>
39<% end %>
3640</tr>
3741<% end %>
3842
toggle raw diff

app/views/site/faq.html.erb

 
1515 file of the repository you wish to push:
1616<pre>
1717[remote "origin"]
18 url = git@<%= GitoriousConfig['gitorious_host'] -%>:<em>project</em>/<em>repository.git</em>
18 url = git@<%= GitlabConfig['gitlab_host'] -%>:<em>project</em>/<em>repository.git</em>
1919 fetch = +refs/heads/*:refs/remotes/origin/*
2020[branch "master"]
2121 remote = origin
2424 and then <code>git push origin master</code> to push the code to Gitorious.
2525</p>
2626<p>
27 You can also just run "<code>git push git@<%= GitoriousConfig['gitorious_host'] -%>:tumbline/mainline.git</code>", or
27 You can also just run "<code>git push git@<%= GitlabConfig['gitlab_host'] -%>:tumbline/mainline.git</code>", or
2828 you can setup a remote by doing the following (add --fetch to the add call to
2929 get the config from above):
3030 <pre>
31 git remote add origin git@<%= GitoriousConfig['gitorious_host'] -%>:<em>project</em>/<em>repository.git</em>
31 git remote add origin git@<%= GitlabConfig['gitlab_host'] -%>:<em>project</em>/<em>repository.git</em>
3232 # to push the master branch to the origin remote we added above:
3333 git push origin master
3434 # after that you can just do:
4444 can contact you about your projects if they need to. We do however take light
4545 measures against crawlers by not displaying your email in completely plain text. <br />
4646 But just to be clear: we won't sell or use any information you give to
47 <%= GitoriousConfig['gitorious_host'] -%> against you or anyone else for financial and/or personal gains.
47 <%= GitlabConfig['gitlab_host'] -%> against you or anyone else for financial and/or personal gains.
4848</p>
4949
5050<hr />
toggle raw diff

config/environments/development.rb

 
1818config.action_mailer.raise_delivery_errors = false
1919config.action_mailer.delivery_method = :test
2020ExceptionNotifier.exception_recipients = YAML.load_file(File.join(RAILS_ROOT,
21 "config/gitorious.yml"))["exception_notification_emails"]
21 "config/gitlab.yml"))["exception_notification_emails"]
toggle raw diff

config/environments/production.rb

 
2727# config.action_mailer.raise_delivery_errors = false
2828
2929ExceptionNotifier.exception_recipients = YAML.load_file(File.join(RAILS_ROOT,
30 "config/gitorious.yml"))["exception_notification_emails"]
30 "config/gitlab.yml"))["exception_notification_emails"]
3131ExceptionNotifier.class_eval do
3232 remove_method :template_root
3333 ExceptionNotifier.template_root = "#{RAILS_ROOT}/vendor/plugins/exception_notification/lib/../views"
toggle raw diff

config/gitlab.sample.yml

 
1# The session secret key (`apg -m 64` is always useful for this kinda stuff)
2cookie_secret: ssssht
3
4# The path where git repositories are stored. The actual (bare) repositories resides
5# in repository_base_path/#{project.slug}/#{repository.name}.git/:
6repository_base_path: "/path/to/gitorious/repositories"
7
8# Stuff that's in the html <head>. custom stats javascript code etc
9extra_html_head_data:
10
11# System message that will appear on all pages if present
12system_message:
13
14# Port the ./script/gitorious script should use:
15gitlab_client_port: 3000
16
17# Host the ./script/gitorious script should use:
18gitlab_client_host: localhost
19
20# Host which is serving the gitorious app, eg "gitorious.org"
21gitlab_host: gitorious.org
22
23# Number of commits to show on a page (Gitorious uses 30)
24number_of_displayed_commits: 10
toggle raw diff

config/gitlab.yml

 
1# The session secret key (`apg -m 64` is always useful for this kinda stuff)
2cookie_secret: MoibTiddikvuegWimCicPeegdeesyaphfebJurwinHykhyikArsoroisAubyocFuSkedvighedRaubshyopWiwidHabCassIacGafAydzavyotutniUjudOtEpIgNoyk
3
4# The path where git repositories are stored. The actual (bare) repositories resides
5# in repository_base_path/#{project.slug}/#{repository.name}.git/:
6repository_base_path: "/home/mtkd/projects/repositories/"
7
8# Stuff that's in the html <head>. custom stats javascript code etc
9extra_html_head_data:
10
11# System message that will appear on all pages if present
12system_message: ""
13
14# Port the ./script/gitorious script should use:
15gitlab_client_port: 3000
16
17# Host the ./script/gitorious script should use:
18gitlab_client_host: localhost
19
20# Host which is serving the gitorious app, eg "gitorious.org"
21gitlab_host: gitlab.org
22
23# Number of commits to show on a page (Gitorious uses 30)
24number_of_displayed_commits: 10
25
toggle raw diff

config/gitorious.sample.yml

 
0# The session secret key (`apg -m 64` is always useful for this kinda stuff)
1cookie_secret: ssssht
2
3# The path where git repositories are stored. The actual (bare) repositories resides
4# in repository_base_path/#{project.slug}/#{repository.name}.git/:
5repository_base_path: "/path/to/gitorious/repositories"
6
7# Stuff that's in the html <head>. custom stats javascript code etc
8extra_html_head_data:
9
10# System message that will appear on all pages if present
11system_message:
12
13# Port the ./script/gitorious script should use:
14gitorious_client_port: 3000
15
16# Host the ./script/gitorious script should use:
17gitorious_client_host: localhost
18
19# Host which is serving the gitorious app, eg "gitorious.org"
20gitorious_host: gitorious.org
21
22# Number of commits to show on a page (Gitorious uses 30)
23number_of_displayed_commits: 10
toggle raw diff

config/initializers/constants.rb

 
0
1# Application mode
2MODE_GITORIOUS = 1
3MODE_GITLAB = 2
4
5
toggle raw diff

config/initializers/gitlab_config.rb

 
0
1#
2APPNAME = "Gitlab"
3SITENAME = "Gitlab"
4DOMAINNAME = "www.gitlab.org"
5
6# enable/disable features
7ALLOW_FEATURE_PROJECTS = true
8ALLOW_FEATURE_ARCHIVE = true
9ALLOW_FEATURE_FORUM = true
10ALLOW_FEATURE_WIKI = true
11ALLOW_FEATURE_MEMBERS = true
12ALLOW_FEATURE_SEARCH = true
13ALLOW_FEATURE_ABOUT = true
14
15#style enumerations
16STYLE_WITHRIGHTCOLUMN = 1
17STYLE_NORIGHTCOLUMN = 2
18
19# Tabs for project page
20PRJ_TAB_WIKI = 1
21PRJ_TAB_ACTIVITIES = 2
22PRJ_TAB_REPOS = 3
23PRJ_TAB_ROADMAP = 4
24PRJ_TAB_TICKETS = 5
25PRJ_TAB_ARTICLES = 6
26PRJ_TAB_FORUM = 7
27PRJ_TAB_LOG = 8
28PRJ_TAB_CONFIG = 9
29
30PRJ_TAB_SUBTAB_NONE = 0
31
32# 'Subtabs' for projects/documenation
33#TODO could some of these be replaced with generics?
34PRJ_TAB_WIKI_NEW = 1
35PRJ_TAB_WIKI_EDIT = 2
36PRJ_TAB_WIKI_LIST = 3
37
38# 'Subtabs' for projects/documenation
39PRJ_TAB_LOG_NEW = 1
40PRJ_TAB_LOG_EDIT = 2
41PRJ_TAB_LOG_LIST = 3
42
43# 'Subtabs' for projects/repos
44PRJ_TAB_REPOS_SUMMARY = 1
45PRJ_TAB_REPOS_LOGS = 2
46PRJ_TAB_REPOS_TREE = 3
47PRJ_TAB_REPOS_COMMIT = 4
48PRJ_TAB_REPOS_MERGEREQUESTS = 5
49
50#
51PRF_TAB_SUMMARY = 1
52PRF_TAB_ARTICLES = 2
53PRF_TAB_TICKETS = 3
54PRF_TAB_WIKIS = 4
55PRF_TAB_FORUM = 5
56PRF_TAB_TIMELINE = 6
57PRF_TAB_CONFIG = 7
58
59#
60ART_LIST_USER = 1
61ART_LIST_PROJECT = 2
62
63#
64STYLE_TABLE_COL_WIDTH_ID = "30"
65STYLE_TABLE_COL_WIDTH_DATE = "74"
66STYLE_TABLE_COL_WIDTH_DDMMYYHHMM = "124"
67STYLE_TABLE_COL_WIDTH_DDBBYY = "82"
68STYLE_TABLE_COL_WIDTH_ACTION = "60"
69STYLE_TABLE_COL_WIDTH_ACTION_SHORT = "30"
70#
71STYLE_TABLE_COL_WIDTH_ARTICLE_TITLE = "260"
72#
73#FIXME this should be title now
74STYLE_TABLE_COL_WIDTH_PROJECT_NAME = "240"
75#
76STYLE_TABLE_COL_WIDTH_REPOSITORY_NAME = "160"
77#
78STYLE_TABLE_COL_WIDTH_USER_NAME = "120"
79
80
81
toggle raw diff

config/initializers/gitlab_constants.rb

 
1
2