Commit f5936cfed5d6e1edb929a6fe8d0ab5eb726e0fee
- Date: Fri May 02 16:04:37 +0000 2008
- Committer: mtkd (mtkd@prj2.com)
- Author: mtkd (mtkd@prj2.com)
- Commit SHA1: f5936cfed5d6e1edb929a6fe8d0ab5eb726e0fee
- Tree SHA1: 37acbaea6cd25e93feb005e117d1ed036f258abd
- app/controllers/wikis_controller.rb 5 --+++
- app/models/article.rb 9 --+++++++
- app/controllers/projects_controller.rb 1 +
- app/controllers/site_controller.rb 3 -++
- app/controllers/sessions_controller.rb 1 +
- app/controllers/repositories_controller.rb 17 -----------++++++
- app/controllers/articles_controller.rb 10 ----++++++
- app/controllers/committers_controller.rb 1 +
- test/fixtures/tickets.yml 6 ++++++
- app/controllers/application.rb 8 ++++++++
Commit diff
- Diff rendering mode:
- inline
- side by side
app/controllers/application.rb
|   | ||
| 2 | 2 | # Likewise, all the methods added will be available for all controllers. |
| 3 | 3 | |
| 4 | 4 | class ApplicationController < ActionController::Base |
| 5 | ||
| 5 | 6 | session :session_key => '_ks1_session_id', :secret => GitlabConfig["cookie_secret"] |
| 6 | 7 | include AuthenticatedSystem |
| 7 | 8 | include ExceptionNotifiable |
| … | … | |
| 63 | 63 | def render_not_found |
| 64 | 64 | render :file => "#{RAILS_ROOT}/public/ac_404.html", :status => 404 |
| 65 | 65 | end |
| 66 | ||
| 67 | def authorised | |
| 68 | if !@is_member | |
| 69 | flash[:error] = "Access denied." | |
| 70 | redirect_to root_path | |
| 71 | end | |
| 72 | end | |
| 66 | 73 | |
| 67 | 74 | end |
| toggle raw diff | ||
app/controllers/articles_controller.rb
|   | ||
| 3 | 3 | # |
| 4 | 4 | class ArticlesController < ApplicationController |
| 5 | 5 | |
| 6 | ||
| 7 | ||
| 6 | after_filter :after_article, :only => [ :find_by_permalink ] | |
| 7 | before_filter :find_project, :except => [ :find_by_date, :find_by_permalink, :find_by_type, :find_by_category, | |
| 8 | :find_by_user, :find_by_sitename, :find_by_sitename_and_type, :find_by_project_and_type ] | |
| 9 | before_filter :authorised, :only => [ :update, :edit, :destroy, :new, :create ] | |
| 8 | 10 | |
| 9 | 11 | # Show all articles, render grouped by year, month |
| 10 | 12 | def index |
| … | … | |
| 36 | 36 | def edit |
| 37 | 37 | if @project |
| 38 | 38 | # Project article |
| 39 | ||
| 39 | @article = Article.find_by_id!(params[:id]) | |
| 40 | 40 | if @article |
| 41 | 41 | @title = "Editing: " + @project.title + ": " + @article.title |
| 42 | 42 | render :action => "ac_project_edit" |
| … | … | |
| 239 | 239 | |
| 240 | 240 | # Increase view count for a permalink page |
| 241 | 241 | def after_article |
| 242 | ||
| 242 | if @article | |
| 243 | 243 | @article.views = @article.views + 1 |
| 244 | 244 | @article.save! |
| 245 | 245 | end |
| toggle raw diff | ||
app/controllers/committers_controller.rb
|   | ||
| 1 | 1 | class CommittersController < ApplicationController |
| 2 | ||
| 2 | 3 | before_filter :login_required, :only => [:new, :create, :destroy, :list] |
| 3 | 4 | before_filter :find_project |
| 4 | 5 | before_filter :find_repository, |
| toggle raw diff | ||
app/controllers/projects_controller.rb
|   | ||
| 3 | 3 | before_filter :login_required, :only => [:create, :update, :destroy, :new] |
| 4 | 4 | before_filter :require_user_has_ssh_keys, :only => [:new, :create] |
| 5 | 5 | before_filter :find_project, :except => [:index, :category, :new, :create] |
| 6 | before_filter :authorised, :only => [ :update, :edit, :destroy, :new, :create ] | |
| 6 | 7 | |
| 7 | 8 | after_filter :increment_project_view |
| 8 | 9 | |
| toggle raw diff | ||
app/controllers/repositories_controller.rb
|   | ||
| 7 | 7 | session :off, :only => [:writable_by] |
| 8 | 8 | |
| 9 | 9 | def index |
| 10 | ||
| 11 | ||
| 12 | ||
| 13 | ||
| 14 | ||
| 15 | ||
| 16 | ||
| 17 | ||
| 18 | ||
| 19 | ||
| 10 | if @project | |
| 11 | @repositories = @project.repositories.find(:all) | |
| 12 | @title, @url_suffix = Project.tab_settings(PRJ_TAB_REPOS) | |
| 13 | render :action => "ac_index" | |
| 20 | 14 | else |
| 21 | ||
| 15 | flash[:error] = "Project not found." | |
| 22 | 16 | redirect_to projects_path |
| 23 | 17 | end |
| 24 | 18 | end |
| … | … | |
| 101 | 101 | end |
| 102 | 102 | |
| 103 | 103 | private |
| 104 | ||
| 104 | 105 | def require_adminship |
| 105 | 106 | unless @project.admin?(current_user) |
| 106 | 107 | respond_to do |format| |
| toggle raw diff | ||
app/controllers/sessions_controller.rb
|   | ||
| 1 | 1 | # This controller handles the login/logout function of the site. |
| 2 | 2 | class SessionsController < ApplicationController |
| 3 | ||
| 3 | 4 | # render new.rhtml |
| 4 | 5 | def new |
| 5 | 6 | render :action => "ac_new" |
| toggle raw diff | ||
app/controllers/site_controller.rb
|   | ||
| 1 | 1 | class SiteController < ApplicationController |
| 2 | ||
| 2 | ||
| 3 | before_filter :login_required, :only => [ :dashboard ] | |
| 3 | 4 | |
| 4 | 5 | def index |
| 5 | 6 | @articles = Article.find_home(current_user) |
| toggle raw diff | ||
app/controllers/wikis_controller.rb
|   | ||
| 1 | 1 | class WikisController < ApplicationController |
| 2 | 2 | |
| 3 | 3 | before_filter :find_project |
| 4 | ||
| 4 | before_filter :authorised, :only => [ :update, :edit, :destroy, :new, :create ] | |
| 5 | after_filter :after_wiki, :only => [ :show ] | |
| 5 | 6 | |
| 6 | 7 | def index |
| 7 | 8 | if @project |
| … | … | |
| 165 | 165 | |
| 166 | 166 | # Increase view count for a wiki page |
| 167 | 167 | def after_wiki |
| 168 | ||
| 168 | if @wiki | |
| 169 | 169 | @wiki.views = @wiki.views + 1 |
| 170 | 170 | @wiki.save! |
| 171 | 171 | end |
| toggle raw diff | ||
app/models/article.rb
|   | ||
| 88 | 88 | find(:first, :conditions => ["status = '#{:published}' AND id = '#{id}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"]) |
| 89 | 89 | end |
| 90 | 90 | |
| 91 | # No membership test version | |
| 92 | def self.find_by_id! (id) | |
| 93 | find(:first, :conditions => ["id = '#{id}'"]) | |
| 94 | end | |
| 95 | ||
| 91 | 96 | # finds articles for a user based on the user slug e.g. /profiles/test-user/articles |
| 92 | 97 | def self.find_by_user (user_id, curruser) |
| 93 | 98 | @projects = Project.list_for_user(curruser) |
| … | … | |
| 110 | 110 | @projects = Project.list_for_user(curruser) |
| 111 | 111 | find(:first, :conditions => ["status = '#{:published}' AND permalink = '#{permalink}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"]) |
| 112 | 112 | end |
| 113 | ||
| 113 | ||
| 114 | 114 | # |
| 115 | 115 | def self.find_by_type (article_type, curruser) |
| 116 | 116 | @projects = Project.list_for_user(curruser) |
| … | … | |
| 134 | 134 | find(:all, :conditions => ["status = '#{:published}' AND project_id = '#{project_id}' AND ( audience = '#{:public}' OR project_id IN (" << projects_allowed << ") )"], :order => "created_at DESC") |
| 135 | 135 | end |
| 136 | 136 | |
| 137 | ||
| 137 | # No membership test version | |
| 138 | 138 | def self.find_by_project! (project_id) |
| 139 | 139 | find(:all, :conditions => ["project_id = '#{project_id}'"], :order => "created_at DESC") |
| 140 | 140 | end |
| toggle raw diff | ||
test/fixtures/tickets.yml
|   | ||
| 15 | 15 | # |
| 16 | 16 | # Add message box prompt on delete wiki and article |
| 17 | 17 | # |
| 18 | # Add delete wiki to actions box | |
| 19 | # | |
| 20 | # Change edit and del links to images on lists (like article and wiki) | |
| 21 | # | |
| 22 | # Can't edit a deleted wiki / article etc. | |
| 23 | # | |
| 18 | 24 | |
| 19 | 25 | |
| 20 | 26 | # |
| toggle raw diff | ||
