[issue #64] Some changes in views and routes.

This commit is contained in:
George Vinogradov 2012-01-18 02:28:59 +04:00
parent 62922c30a3
commit 51e9b5d1f6
9 changed files with 155 additions and 82 deletions

View File

@ -3,7 +3,8 @@ require 'cgi'
class WikiController < ApplicationController class WikiController < ApplicationController
# WIKI_OPTIONS = {:page_file_dir => '/', :ref => 'master', :page_class => Gollum::PageImproved} # WIKI_OPTIONS = {:page_file_dir => '/', :ref => 'master', :page_class => Gollum::PageImproved}
WIKI_OPTIONS = { :page_class => Gollum::PageImproved} # WIKI_OPTIONS = { :page_class => Gollum::PageImproved}
WIKI_OPTIONS = {}
load_and_authorize_resource :project load_and_authorize_resource :project
@ -77,11 +78,12 @@ class WikiController < ApplicationController
@name = params['page'] @name = params['page']
format = params['format'].intern format = params['format'].intern
committer = Gollum::Committer.new(@wiki, commit_message.merge({:name => current_user.name, :email => current_user.email})) # committer = Gollum::Committer.new(@wiki, commit_message.merge({:name => current_user.name, :email => current_user.email}))
commit = {:committer => committer} # commit = {:committer => committer}
commit = commit_message.merge({:name => current_user.name, :email => current_user.email})
begin begin
@wiki.write_page(@name, format, params['content'], commit).commit @wiki.write_page(@name, format, params['content'], commit)
redirect_to project_wiki_path(@project, @name) redirect_to project_wiki_path(@project, @name)
rescue Gollum::DuplicatePageError => e rescue Gollum::DuplicatePageError => e
@message = "Duplicate page: #{@name}" @message = "Duplicate page: #{@name}"
@ -146,9 +148,12 @@ class WikiController < ApplicationController
end end
def history def history
@name = params[:name] @name = params['id']
@page = @wiki.page(@name) if @page = @wiki.page(@name)
@versions = @page.versions.paginate :page => params[:page] #try to use will_paginate @versions = @page.versions(:page => params['page'], :per_page => 25)#.paginate :page => params[:page] #try to use will_paginate
else
redirect_to :back
end
end end
def search def search

View File

@ -1,8 +1,4 @@
%h2.title #gollum-editor{:class => "#{@new ? 'create' : 'edit'}", :'data-escaped-name' => escaped_name}
= t("layout.wiki.create_page")
.inner
#gollum-editor{:class => "#{@new ? 'create' : 'edit'}", :'data-escaped-name' => escaped_name}
= form_tag editor_path(@project, @name), :name => 'gollum-editor', :method => @new ? :post : :put do = form_tag editor_path(@project, @name), :name => 'gollum-editor', :method => @new ? :post : :put do
%fieldset#gollum-editor-fields %fieldset#gollum-editor-fields
- if @new - if @new
@ -39,7 +35,7 @@
%span.jaws %span.jaws
%br %br
= submit_tag 'Save', :id => "gollum-editor-submit", :title => "Save current changes" = submit_tag t("layout.wiki.save_button"), :id => "gollum-editor-submit", :title => t("layout.wiki.save_changes")
= link_to t("layout.wiki.preview"), "javascript:void(0)", :id => "gollum-editor-preview", :class => "minibutton", :title => t("layout.wiki.preview_title") = link_to t("layout.wiki.preview"), "javascript:void(0)", :id => "gollum-editor-preview", :class => "minibutton", :title => t("layout.wiki.preview_title")
- content_for :javascripts do - content_for :javascripts do

View File

@ -1,19 +1,4 @@
.inner #wiki-content
#wiki-wrapper.page
#head
%h1.title= @name
%ul.actions
%li.minibutton.jaws
= link_to t("layout.wiki.new_page"), '#', :'data-url' => project_wiki_index_path(@project),
:id => 'minibutton-new-page'
- if @editable
%li.minibutton
= link_to t("layout.wiki.edit_page"), edit_project_wiki_path(@project, escaped_name), :class => "action-edit-page"
%li.minibutton= link_to t("layout.wiki.page_history"), history_project_wiki_path(@project, escaped_name)
= render :partial => 'searchbar'
#wiki-content
.wrap{:class => "#{has_footer? ? 'has-footer' : ''} #{has_sidebar? ? 'has-rightbar' : ''}"} .wrap{:class => "#{has_footer? ? 'has-footer' : ''} #{has_sidebar? ? 'has-rightbar' : ''}"}
#wiki-body{:class => "gollum-#{format}-content"} #wiki-body{:class => "gollum-#{format}-content"}
#template #template
@ -25,7 +10,7 @@
#wiki-footer{:class => "gollum-#{footer_format}-content"} #wiki-footer{:class => "gollum-#{footer_format}-content"}
#footer-content #footer-content
= raw footer_content = raw footer_content
#gollum-footer #gollum-footer
%p#last-edit %p#last-edit
= t("layout.wiki.last_edited_by") = t("layout.wiki.last_edited_by")
%b %b
@ -33,5 +18,4 @@
= time_ago_in_words date.to_time - 4.hours, true = time_ago_in_words date.to_time - 4.hours, true
= t("layout.time.ago") = t("layout.time.ago")
= javascript_include_tag 'autocomplete-rails.js'
=#javascript_include_tag 'MathJax/MathJax.js' =#javascript_include_tag 'MathJax/MathJax.js'

View File

@ -0,0 +1,62 @@
- content_for :javascripts do
= javascript_include_tag 'gollum/gollum.js', 'gollum/gollum.dialog.js', 'gollum/gollum.placeholder.js'
- content_for :stylesheets do
= stylesheet_link_tag 'gollum/gollum.css', 'gollum/dialog.css', 'gollum/ie7.css', 'gollum/template.css'
.block
.secondary-navigation
%ul.wat-cf
%li.first= link_to t("layout.projects.list"), projects_path
%li= link_to t("layout.projects.new"), new_project_path
%li.active= link_to t("layout.projects.show"), project_path(@project)
%li= link_to t("layout.git.repositories.source"), project_repo_path(@project)
%li= link_to t("layout.projects.build"), new_project_build_list_path(@project)
%li= link_to t("layout.projects.issues"), project_issues_path(@project)
.content
.inner
%p
%b
= t("activerecord.attributes.project.name")
\:
= @project.name
%p
%b
= t("activerecord.attributes.project.owner")
\:
= link_to @project.owner.try(:name), url_for(@project.owner)
%a{ :name => "wiki"}
.block
.secondary-navigation
%ul.wat-cf
%li.first= link_to t("layout.wiki.home"), project_wiki_index_path(@project)
%li= link_to t("layout.wiki.new"), new_project_wiki_path(@project)
%li= link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project)
.content
#wiki-wrapper.inner
#head
%h1
= t("layout.wiki.editing_page")
%strong= @name
%ul.actions
%li.minibutton
= link_to t("layout.wiki.view_page"), view_path(@project, escaped_name),
:class => 'action-view-page'
%li.minibutton
= link_to t("layout.wiki.page_history"), history_project_wiki_path(@project, escaped_name),
:class => 'aciton-view-history'
#wiki-content
= render :partial => "editor"
:javascript
jQuery(document).ready(function() {
$.GollumEditor();
});
- content_for :sidebar do
- render :partial => 'projects/sidebar'

View File

@ -36,6 +36,11 @@
%li= link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project) %li= link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project)
.content .content
#wiki-wrapper.inner
#head
%h1= t("layout.wiki.create_page")
#wiki-content
= render :partial => "editor" = render :partial => "editor"
:javascript :javascript

View File

@ -38,6 +38,20 @@
%li= link_to t("layout.wiki.git_access"), '#' %li= link_to t("layout.wiki.git_access"), '#'
.content .content
.inner
#wiki-wrapper.page
#head
%h1.title= @name
%ul.actions
%li.minibutton.jaws
= link_to t("layout.wiki.new_page"), '#', :'data-url' => project_wiki_index_path(@project),
:id => 'minibutton-new-page'
- if @editable
%li.minibutton
= link_to t("layout.wiki.edit_page"), edit_project_wiki_path(@project, escaped_name), :class => "action-edit-page"
%li.minibutton= link_to t("layout.wiki.page_history"), history_project_wiki_path(@project, escaped_name)
= render :partial => 'searchbar'
= render :partial => "page" = render :partial => "page"
- content_for :sidebar do - content_for :sidebar do

View File

@ -172,6 +172,11 @@ ru:
search_and_hellip: Ключевые слова search_and_hellip: Ключевые слова
search: Искать search: Искать
search_popup: Искать в этой Wiki search_popup: Искать в этой Wiki
commit_message_placeholder: Введите сопровождающее сообщение (опционально)
preview_title: Посмотреть в новом окне
preview: Предпросмотр
save_changes: Сохранить текущие изменения
save_button: Сохранить
roles: roles:

View File

@ -89,11 +89,11 @@ Rosa::Application.routes.draw do
get :pages get :pages
end end
member do member do
get :history
get :edit get :edit
match 'revert/:sha1/:sha2' => 'wiki#revert', :as => :revert_page, :via => :get match 'revert/:sha1/:sha2' => 'wiki#revert', :as => :revert_page, :via => :get
match ':ref' => 'wiki#show', :as => :versioned, :via => :get match ':ref' => 'wiki#show', :as => :versioned, :via => :get
get :history
post :compare post :compare
match 'compare/*versions' => 'wiki#compare', :as => :compare_versions, :via => :get match 'compare/*versions' => 'wiki#compare', :as => :compare_versions, :via => :get
end end

View File

@ -18,8 +18,10 @@ module Gollum
def versions(options = {}) def versions(options = {})
options.delete :page options.delete :page
options.delete :per_page options.delete :per_page
puts super(options)
res = PaginatableArray.new(super(options)) res = PaginateableArray.new(super(options))
puts res.inspect
end end
end end
end end