[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
# 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
@ -77,11 +78,12 @@ class WikiController < ApplicationController
@name = params['page']
format = params['format'].intern
committer = Gollum::Committer.new(@wiki, commit_message.merge({:name => current_user.name, :email => current_user.email}))
commit = {:committer => committer}
# committer = Gollum::Committer.new(@wiki, commit_message.merge({:name => current_user.name, :email => current_user.email}))
# commit = {:committer => committer}
commit = commit_message.merge({:name => current_user.name, :email => current_user.email})
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)
rescue Gollum::DuplicatePageError => e
@message = "Duplicate page: #{@name}"
@ -146,9 +148,12 @@ class WikiController < ApplicationController
end
def history
@name = params[:name]
@page = @wiki.page(@name)
@versions = @page.versions.paginate :page => params[:page] #try to use will_paginate
@name = params['id']
if @page = @wiki.page(@name)
@versions = @page.versions(:page => params['page'], :per_page => 25)#.paginate :page => params[:page] #try to use will_paginate
else
redirect_to :back
end
end
def search

View File

@ -1,46 +1,42 @@
%h2.title
= t("layout.wiki.create_page")
#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
%fieldset#gollum-editor-fields
- if @new
#gollum-editor-title-field.singleline
= label_tag :page, t("layout.wiki.page_title"), :class => 'jaws'
= text_field_tag :page, @name, :id => "gollum-editor-page-title"
- else
= hidden_field_tag :page, @name, :id => "gollum-editor-page-title"
.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
%fieldset#gollum-editor-fields
- if @new
#gollum-editor-title-field.singleline
= label_tag :page, t("layout.wiki.page_title"), :class => 'jaws'
= text_field_tag :page, @name, :id => "gollum-editor-page-title"
- else
= hidden_field_tag :page, @name, :id => "gollum-editor-page-title"
= render :partial => 'editor_toolbar'
= render :partial => 'editor_toolbar'
= text_area_tag :content, @content, :id => "gollum-editor-body", :'data-markup-lang' => format
= text_area_tag :content, @content, :id => "gollum-editor-body", :'data-markup-lang' => format
- if has_footer?
#gollum-editor-edit-footer.collapsed
= link_to "#", :class => "button" do
%span= t("layout.wiki.expand_collapse")
%h4
Footer
= text_area_tag :footer, footer, :id => "gollum-editor-footer"
- if has_footer?
#gollum-editor-edit-footer.collapsed
= link_to "#", :class => "button" do
%span= t("layout.wiki.expand_collapse")
%h4
Footer
= text_area_tag :footer, footer, :id => "gollum-editor-footer"
- if has_sidebar?
#gollum-editor-edit-sidebar.collapsed
= link_to "#", :class => "button" do
%span= t("layout.wiki.expand_collapse")
%h4
Sidebar
= text_area_tag :sidebar, sidebar, :id => "gollum-editor-sidebar"
- if has_sidebar?
#gollum-editor-edit-sidebar.collapsed
= link_to "#", :class => "button" do
%span= t("layout.wiki.expand_collapse")
%h4
Sidebar
= text_area_tag :sidebar, sidebar, :id => "gollum-editor-sidebar"
#gollum-editor-edit-summary.singleline
= label_tag :message, t("layout.wiki.edit_commit_message"), :class => "jaws"
= text_field_tag :message, t("layout.wiki.commit_message_placeholder"), :id => "gollum-editor-message-field"
#gollum-editor-edit-summary.singleline
= label_tag :message, t("layout.wiki.edit_commit_message"), :class => "jaws"
= text_field_tag :message, t("layout.wiki.commit_message_placeholder"), :id => "gollum-editor-message-field"
%span.jaws
%br
%span.jaws
%br
= submit_tag 'Save', :id => "gollum-editor-submit", :title => "Save current changes"
= link_to t("layout.wiki.preview"), "javascript:void(0)", :id => "gollum-editor-preview", :class => "minibutton", :title => t("layout.wiki.preview_title")
= 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")
- content_for :javascripts do
= javascript_include_tag 'gollum/editor/gollum.editor.js'

View File

@ -1,37 +1,21 @@
.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)
#wiki-content
.wrap{:class => "#{has_footer? ? 'has-footer' : ''} #{has_sidebar? ? 'has-rightbar' : ''}"}
#wiki-body{:class => "gollum-#{format}-content"}
#template
= raw @content
- if has_sidebar?
#wiki-rightbar{:class => "gollum-#{sidebar_format}-content"}
= raw sidebar_content
- if has_footer?
#wiki-footer{:class => "gollum-#{footer_format}-content"}
#footer-content
= raw footer_content
#gollum-footer
%p#last-edit
= t("layout.wiki.last_edited_by")
%b
= author
= time_ago_in_words date.to_time - 4.hours, true
= t("layout.time.ago")
= render :partial => 'searchbar'
#wiki-content
.wrap{:class => "#{has_footer? ? 'has-footer' : ''} #{has_sidebar? ? 'has-rightbar' : ''}"}
#wiki-body{:class => "gollum-#{format}-content"}
#template
= raw @content
- if has_sidebar?
#wiki-rightbar{:class => "gollum-#{sidebar_format}-content"}
= raw sidebar_content
- if has_footer?
#wiki-footer{:class => "gollum-#{footer_format}-content"}
#footer-content
= raw footer_content
#gollum-footer
%p#last-edit
= t("layout.wiki.last_edited_by")
%b
= author
= time_ago_in_words date.to_time - 4.hours, true
= t("layout.time.ago")
= javascript_include_tag 'autocomplete-rails.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,7 +36,12 @@
%li= link_to t("layout.wiki.pages"), pages_project_wiki_index_path(@project)
.content
= render :partial => "editor"
#wiki-wrapper.inner
#head
%h1= t("layout.wiki.create_page")
#wiki-content
= render :partial => "editor"
:javascript
jQuery(document).ready(function() {

View File

@ -38,7 +38,21 @@
%li= link_to t("layout.wiki.git_access"), '#'
.content
= render :partial => "page"
.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"
- content_for :sidebar do
- render :partial => 'projects/sidebar'

View File

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

View File

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

View File

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