Commit c31d345b53cef2d773a7b3b28282efa357fc9a74

Removed application_mode flag

Commit diff

README-GITLAB.txt

 
1111It was simpler to merge Gitlab in than rip the Git code I needed out of
1212Gitorious (I found the project via Grit).
1313
14Initally I'm merging in without removing (if possible) Gitorious code, there
15is an application_mode set in the config yml that can be tested, if it's
16MODE_GITLAB then the rendering changes etc., setting MODE_GITORIOUS should
17render the existing Gitorious app. I've mainly done this so I can (hopefully)
18pull future Gitorious changes safely.
19
2014Notes:
2115
2216- model and views with fixtures will be first stage, controllers and other
toggle raw diff

app/controllers/application.rb

 
2323 end
2424 end
2525
26 layout :layout_skin
27
2826 protected
2927
3028 def require_user_has_ssh_keys
6060 end
6161
6262 def render_not_found
63 case $application_mode
64 when MODE_GITLAB
65 render :file => "#{RAILS_ROOT}/public/ac_404.html", :status => 404
66 when MODE_GITORIOUS
67 render :file => "#{RAILS_ROOT}/public/404.html", :status => 404
68 end
69 end
70
71 # Swithes to /views/layouts/[mode]
72 def layout_skin
73 case GitoriousConfig["application_mode"]
74 when MODE_GITORIOUS
75 $application_mode = MODE_GITORIOUS
76 "application"
77 when MODE_GITLAB
78 $application_mode = MODE_GITLAB
79 "gitlab"
80 end
63 render :file => "#{RAILS_ROOT}/public/ac_404.html", :status => 404
8164 end
8265
8366end
toggle raw diff

app/controllers/commits_controller.rb

 
1313 @commit = @git.commit(params[:id])
1414 @diffs = @commit.diffs
1515 @comment_count = @repository.comments.count(:all, :conditions => {:sha1 => @commit.id})
16 case $application_mode
17 when MODE_GITLAB
18 @title = "View Commit " << @commit.id_abbrev
19 render :action => "ac_show"
20 when MODE_GITORIOUS
21 respond_to do |format|
22 format.html
23 # TODO: format.diff { render :content_type => "text/plain" }
24 end
25 end
26
16 @title = "View Commit " << @commit.id_abbrev
17 render :action => "ac_show"
2718 end
2819
2920end
toggle raw diff

app/controllers/logs_controller.rb

 
1111 @git = @repository.git
1212 @commits = @repository.paginated_commits(params[:id], params[:page])
1313 @atom_auto_discovery_url = project_repository_formatted_log_feed_path(@project, @repository, params[:id], :atom)
14 case $application_mode
15 when MODE_GITLAB
16 @title = "&lsquo;" << @repository.git.git.name_rev({}, @commits.first.id).split(" ").last << "&rsquo; Commit History"
17 render :action => "ac_show"
18 when MODE_GITORIOUS
19 respond_to do |format|
20 format.html
21 end
22 end
14 @title = "&lsquo;" << @repository.git.git.name_rev({}, @commits.first.id).split(" ").last << "&rsquo; Commit History"
15 render :action => "ac_show"
2316 end
2417
2518 def feed
toggle raw diff

app/controllers/projects_controller.rb

 
44 before_filter :require_user_has_ssh_keys, :only => [:new, :create]
55 before_filter :find_project, :except => [:index, :category, :new, :create]
66
7 after_filter :increment_project_view if $application_mode == MODE_GITLAB
7 after_filter :increment_project_view
88
99 def index
10 case $application_mode
11 when MODE_GITORIOUS
12 @projects = Project.paginate(:all, :order => "projects.created_at desc",
13 :page => params[:page], :include => [:tags])
14 @atom_auto_discovery_url = formatted_projects_path(:atom)
15 respond_to do |format|
16 format.html { @tags = Project.top_tags }
17 format.xml { render :xml => @projects }
18 format.atom { }
19 end
20 when MODE_GITLAB
21 @title = "Projects"
22 @public_projects = Project.find_all_active_public_projects(current_user)
23 #flash[:error] = "No public projects exist." if @public_projects.size == 0
24 @member_projects = Project.find_all_active_member_projects(current_user) if logged_in?
25 render :action => "ac_list"
26 end
10 @title = "Projects"
11 @public_projects = Project.find_all_active_public_projects(current_user)
12 #flash[:error] = "No public projects exist." if @public_projects.size == 0
13 @member_projects = Project.find_all_active_member_projects(current_user) if logged_in?
14 render :action => "ac_list"
2715 end
2816
2917 def category
3030 end
3131
3232 def show
33 case $application_mode
34 when MODE_GITORIOUS
35 @repositories = @project.repositories.find(:all)
36 respond_to do |format|
37 format.html
38 format.xml { render :xml => @project }
39 end
40 when MODE_GITLAB
41 @wiki = @project.wiki
42 @title = @wiki.title
43 @url_suffix = ""
44 render :action => "ac_show"
45 end
33 @wiki = @project.wiki
34 @title = @wiki.title
35 @url_suffix = ""
36 render :action => "ac_show"
4637 end
4738
4839 def new
toggle raw diff

app/controllers/repositories_controller.rb

 
77 session :off, :only => [:writable_by]
88
99 def index
10 case $application_mode
11 when MODE_GITLAB
12 if params[:project_id] != nil
13 @project = Project.find_by_slug(params[:project_id], current_user)
14 if @project != nil
15 @repositories = @project.repositories.find(:all)
16 @title, @url_suffix = Project.tab_settings(PRJ_TAB_REPOS)
17 render :action => "ac_index"
18 else
19 flash[:error] = "Project not found."
20 redirect_to projects_path
21 end
10 if params[:project_id] != nil
11 @project = Project.find_by_slug(params[:project_id], current_user)
12 if @project != nil
13 @repositories = @project.repositories.find(:all)
14 @title, @url_suffix = Project.tab_settings(PRJ_TAB_REPOS)
15 render :action => "ac_index"
2216 else
23 flash[:error] = "No project specified."
17 flash[:error] = "Project not found."
2418 redirect_to projects_path
2519 end
26 when MODE_GITORIOUS
27 redirect_to(project_path(@project))
20 else
21 flash[:error] = "No project specified."
22 redirect_to projects_path
2823 end
2924 end
3025
3232 else
3333 @commits = []
3434 end
35 case $application_mode
36 when MODE_GITORIOUS
37 @atom_auto_discovery_url = formatted_project_repository_path(@project, @repository, :atom)
38 respond_to do |format|
39 format.html
40 format.xml { render :xml => @repository }
41 format.atom { render :template => "logs/feed.atom.builder" }
42 end
43 when MODE_GITLAB
44 #PRJ_TAB_REPOS
45 @title = "Repo: &lsquo;" << @repository.name << "&rsquo;"
46 render :action => "ac_show"
47 end
35 @title = "Repo: &lsquo;" << @repository.name << "&rsquo;"
36 render :action => "ac_show"
4837 end
4938
5039 # note the #new+#create actions are members in the routes, hence they require
toggle raw diff

app/controllers/searches_controller.rb

 
99 @results = @search.results
1010 end
1111
12 case $application_mode
13 when MODE_GITLAB
14 render :action => 'ac_search'
15 end
12 render :action => 'ac_search'
1613 end
1714
1815end
toggle raw diff

app/controllers/sessions_controller.rb

 
22class SessionsController < ApplicationController
33 # render new.rhtml
44 def new
5 render :action => session_mode_page
5 render :action => "ac_new"
66 end
77
88 def create
1616 flash[:notice] = "Logged in successfully"
1717 else
1818 flash.now[:error] = "Username/password didn't match, please try again."
19 render :action => session_mode_page
19 render :action => "ac_new"
2020 end
2121 end
2222
2828 redirect_back_or_default('/')
2929 end
3030
31 def session_mode_page
32 case $application_mode
33 when MODE_GITORIOUS
34 "new"
35 when MODE_GITLAB
36 "ac_new"
37 end
38 end
39
4031end
toggle raw diff

app/controllers/site_controller.rb

 
22 before_filter :login_required, :only => [:dashboard]
33
44 def index
5 case $application_mode
6 when MODE_GITORIOUS
7 @projects = Project.find(:all, :limit => 10, :order => "id desc")
8 when MODE_GITLAB
9 @articles = Article.find_home(current_user)
10 render :action => 'gitlab_index'
11 end
5 @articles = Article.find_home(current_user)
6 render :action => 'gitlab_index'
127 end
138
149 def dashboard
1919 end
2020
2121 def about
22 case $application_mode
23 when MODE_GITLAB
24 # Main wiki - default page
25 @wiki = Wiki.find_by_slug("about")
26 @wiki_breadcrumb = false
27 @title = "About"
28 render :action => 'ac_about'
29 end
22 # Main wiki - default page
23 @wiki = Wiki.find_by_slug("about")
24 @wiki_breadcrumb = false
25 @title = "About"
26 render :action => 'ac_about'
3027 end
3128
3229 def faq
toggle raw diff

app/controllers/trees_controller.rb

 
1717 end
1818 path = params[:path].blank? ? [] : ["#{params[:path].join("/")}/"] # FIXME: meh, this sux
1919 @tree = @git.tree(@commit.tree.id, path)
20
21 case $application_mode
22 when MODE_GITLAB
23 @title = "&lsquo;" << @repository.git.git.name_rev({}, @commit.id).split(" ").last << "&rsquo; Source Tree"
24 render :action => "ac_show"
25 when MODE_GITORIOUS
26 end
20 @title = "&lsquo;" << @repository.git.git.name_rev({}, @commit.id).split(" ").last << "&rsquo; Source Tree"
21 render :action => "ac_show"
2722 end
2823
2924 def archive
toggle raw diff

app/helpers/members_helper.rb

 
11module MembersHelper
22
3 include ProjectsHelper #if $application_mode == MODE_GITLAB
3 include ProjectsHelper
44
55 #
66 # FIXME pointless, and should be in model
toggle raw diff

app/helpers/projects_helper.rb

 
11module ProjectsHelper
22
3 # Gitlab
4 include BlueclothHelper if $application_mode == MODE_GITLAB
3 include BlueclothHelper
54
6 #
7 # Gitlab specific
8 #
95 def get_project_audience_suffix (project)
106 project.audience == :members_only ? " (Private)" : ""
117 end
toggle raw diff

app/helpers/repositories_helper.rb

 
11module RepositoriesHelper
22
3 # Gitlab
4 include ProjectsHelper if $application_mode == MODE_GITLAB
5 include RepotreeHelper if $application_mode == MODE_GITLAB
3 include ProjectsHelper
4 include RepotreeHelper
65
76 def log_path(objectish = "master", options = {})
87 if options.blank? # just to avoid the ? being tacked onto the url
toggle raw diff

app/helpers/site_helper.rb

 
11module SiteHelper
22
3 # Gitlab
4 include ArticlesHelper if $application_mode == MODE_GITLAB
3 include ArticlesHelper
54
65end
toggle raw diff

app/helpers/tickets_helper.rb

 
11module TicketsHelper
22
3 # Gitlab
4 include ProjectsHelper if $application_mode == MODE_GITLAB
3 include ProjectsHelper
54
65 def render_project_tickets
76 end
toggle raw diff

app/helpers/wikis_helper.rb

 
11module WikisHelper
22
3 include ProjectsHelper #if $application_mode == MODE_GITLAB
3 include ProjectsHelper
44 include BlueclothHelper
55
66end
toggle raw diff

app/models/project.rb

 
1010 has_many :repository_clones, :conditions => ["mainline = ?", false],
1111 :class_name => "Repository"
1212
13 # Gitlab membership system
14 if $application_mode == MODE_GITLAB then
15 belongs_to :wiki
16 has_many :members, :dependent => :destroy
17 has_many :users, :through => :members
18 has_many :articles
19 end
20
13 belongs_to :wiki
14 has_many :members, :dependent => :destroy
15 has_many :users, :through => :members
16 has_many :articles
2117
2218 is_indexed :fields => ["title", "description", "slug"],
2319 :concatenate => [
toggle raw diff

app/views/layouts/application.html.erb

 
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3<html lang="en">
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
3<% if request.env['HTTP_HOST'] != "88.97.241.226" %>
4<html>
45<head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <title><%= @page_title ? @page_title + " - " : "" -%>Gitorious</title>
7 <meta name="author" content="Johan Sørensen">
8 <%= stylesheet_link_tag "base" -%>
9 <%= syntax_themes_css -%>
10 <%= javascript_include_tag :defaults, :cache => true -%>
11 <% if @atom_auto_discovery_url -%>
12 <%= auto_discovery_link_tag(:atom, @atom_auto_discovery_url) -%>
13 <% end -%>
14 <%= GitoriousConfig["extra_html_head_data"] -%>
6<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
7<link rel="icon" href="/favicon.ico" type="image/ico">
8<link rel="shortcut icon" href="/favicon.ico">
9<link rel='alternate' type='application/rss+xml' title='RSS Feed' href='/rss.xml'/>
10<title><%= yield(:title) %> - <%= SITENAME %></title>
11<%= stylesheet_link_tag 'gitlab' %>
1512</head>
1613
17<body id="<%= controller.controller_name -%>">
14<body>
15<div id='page'>
16
1817 <% unless GitoriousConfig["system_message"].blank? -%>
1918 <div id="system_message">
2019 <p><strong>System notice:</strong> <%= GitoriousConfig["system_message"] -%></p>
2120 </div>
2221 <% end -%>
23 <div id="header">
24 <h1 id="logo">
25 <%= link_to image_tag("logo-white.png"), root_path -%>
26 <!-- <h1><%= link_to "Gitorious", root_path -%></h1> -->
27 </h1>
28 <ul id="menu">
29 <% unless logged_in? -%>
30 <li><%= link_to "Home", root_path -%></li>
31 <% end -%>
32 <% if logged_in? -%>
33 <li><%= link_to "Dashboard", dashboard_path -%></li>
34 <% end -%>
35 <li><%= link_to "Projects", projects_path -%></li>
36 <li><%= link_to "Search", search_path -%></li>
37 <% if logged_in? -%>
38 <li><%= link_to "FAQ", faq_path -%></li>
39 <% else -%>
40 <li><%= link_to "About", about_path -%></li>
41 <% end -%>
42 <%- if logged_in? -%>
43 <li class="secondary">( <%= link_to "My account", account_path -%></li>
44 <li class="secondary"><%= link_to "Logout", logout_path -%> )</li>
45 <%- else -%>
46 <li class="secondary"><%= link_to "Register", new_user_path -%></li>
47 <li class="secondary"><%= link_to "Login", login_path -%></li>
48 <%- end -%>
49 </ul>
50 <ul id="submenu">
51 <% if @project -%>
52 <li class="<%= selected_if_current_page(project_path(@project)) -%>">
53 <%= link_to h(@project.title), project_path(@project) -%>
54 </li>
55 <% if @repository -%>
56 <!-- <li class="menu_title"><%= h(@repository.name) -%>:</li> -->
57 <li class="<%= selected_if_current_page(project_repository_path(@project, @repository)) -%>">
58 <%= link_to "#{h(@repository.name)} repository", project_repository_path(@project, @repository) -%>
59 </li>
60 <li class="<%= selected_if_current_page(project_repository_logs_path(@project, @repository)) -%>">
61 <%= link_to "Commits", project_repository_logs_path(@project, @repository) -%>
62 </li>
63 <% if @repository.head_candidate -%>
64 <li class="<%= selected_if_current_page(project_repository_tree_path(@project, @repository, @repository.head_candidate.name)) -%>">
65 <%= link_to "Source Tree", project_repository_tree_path(@project, @repository, @repository.head_candidate.name) -%>
66 </li>
67 <% end -%>
68 <% end -%>
69 <% end -%>
70 <%= yield :submenu -%>
71 </ul>
22
23 <div id="system_message">
24 <p><strong>Notice:</strong> **BROKEN DURING REFACTOR** This site is unstable work-in-progress, source for it is available on <a href='http://gitorious.org/projects/gitlab/'>gitorious.org</a>. Contact <a href='mailto:mtkd@prj2.com'>mtkd@prj2.com</a></p>
7225 </div>
73 <div id="container">
74 <% unless @content_for_sidebar.blank? -%>
75 <div id="main">
76 <% end -%>
77 <div id="content">
78 <%= flashes %>
79 <%= yield -%>
80 </div>
81 <% unless @content_for_sidebar.blank? -%>
82 </div>
83 <div id="sidebar">
84 <%= yield :sidebar -%>
85 </div>
86 <div class="clear"></div>
87 <% end -%>
88 <div id="footer">
89 <ul>
90 <li><%= link_to "Home", root_path -%> | </li>
91 <li><%= link_to "About", about_path -%> | </li>
92 <li><%= link_to "FAQ", faq_path -%> | </li>
93 <li><%= link_to "Discussion group", "http://groups.google.com/group/gitorious" -%></li>
26
27 <div id='header'>
28 <div id='menu'>
29 <ul class='item'>
30 <li><%= link_to("Home", root_path) %></li>
31 <li><%= link_to("Projects", projects_path) %></li>
32 <li><%= link_to("Archive", articles_path) %></li>
33 <li><%= link_to("Forum", forums_path) %></li>
34 <li><%= link_to("Wiki", wikis_path) %></li>
35 <li><%= link_to("Search", search_path) %></li>
36 <li><%= link_to("About", about_path) %></li>
9437 </ul>
9538 </div>
9639 </div>
40
41 <% if flash[:error] %><div id='flash_error'><%= flash[:error] %></div><% end %>
42 <% if flash[:notice] %><div id='flash_notice'><%= flash[:notice] %></div><% end %>
43
44 <%= yield %>
45
46 <div id='footer'>
47 <div class='text'>
48 All content and applications are <a href='/wikis/gnu-agpl-license'>GNU AGPL</a> unless stated otherwise. This site is built using <a href='/projects/<%= APPNAME.downcase %>'><%= APPNAME %></a> for Rails.
49 </div>
50 </div>
51
52</div>
9753</body>
54
55</html>
56<% else %>
57
58<html>
59No site
9860</html>
61
62<% end %>
toggle raw diff

app/views/layouts/gitlab.html.erb

 
0<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
1
2<% if request.env['HTTP_HOST'] != "88.97.241.226" %>
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
6<link rel="icon" href="/favicon.ico" type="image/ico">
7<link rel="shortcut icon" href="/favicon.ico">
8<link rel='alternate' type='application/rss+xml' title='RSS Feed' href='/rss.xml'/>
9<title><%= yield(:title) %> - <%= SITENAME %></title>
10<%= stylesheet_link_tag 'gitlab' %>
11</head>
12
13<body>
14<div id='page'>
15
16 <% unless GitoriousConfig["system_message"].blank? -%>
17 <div id="system_message">
18 <p><strong>System notice:</strong> <%= GitoriousConfig["system_message"] -%></p>
19 </div>
20 <% end -%>
21
22 <div id="system_message">
23 <p><strong>Notice:</strong> **BROKEN DURING REFACTOR** This site is unstable work-in-progress, source for it is available on <a href='http://gitorious.org/projects/gitlab/'>gitorious.org</a>. Contact <a href='mailto:mtkd@prj2.com'>mtkd@prj2.com</a></p>
24 </div>
25
26 <div id='header'>
27 <div id='menu'>
28 <ul class='item'>
29 <li><%= link_to("Home", root_path) %></li>
30 <li><%= link_to("Projects", projects_path) %></li>
31 <li><%= link_to("Archive", articles_path) %></li>
32 <li><%= link_to("Forum", forums_path) %></li>
33 <li><%= link_to("Wiki", wikis_path) %></li>
34 <li><%= link_to("Search", search_path) %></li>
35 <li><%= link_to("About", about_path) %></li>
36 </ul>
37 </div>
38 </div>
39
40 <% if flash[:error] %><div id='flash_error'><%= flash[:error] %></div><% end %>
41 <% if flash[:notice] %><div id='flash_notice'><%= flash[:notice] %></div><% end %>
42
43 <%= yield %>
44
45 <div id='footer'>
46 <div class='text'>
47 All content and applications are <a href='/wikis/gnu-agpl-license'>GNU AGPL</a> unless stated otherwise. This site is built using <a href='/projects/<%= APPNAME.downcase %>'><%= APPNAME %></a> for Rails.
48 </div>
49 </div>
50
51</div>
52</body>
53
54</html>
55<% else %>
56
57<html>
58