Merge branch '369-bootstrap' of abf.rosalinux.ru:abf/rosa-build into 369-bootstrap

This commit is contained in:
Alexander Machehin 2014-11-20 22:41:05 +05:00
commit 9113373ee1
28 changed files with 223 additions and 345 deletions

View File

@ -20,10 +20,10 @@ class Projects::WikiController < Projects::BaseController
end
def show
@name = CGI.unescape(params['id'])
@name = CGI.unescape(params[:id])
redirect_to project_wiki_index_path(@project) and return if @name == 'Home'
ref = params['ref'] ? params['ref'] : @wiki.ref
ref = params[:ref].presence || @wiki.ref
@page = @wiki.page(@name, ref)
if !@page && @wiki.page(@name)
flash[:error] = t('flash.wiki.ref_not_exist')
@ -45,13 +45,13 @@ class Projects::WikiController < Projects::BaseController
end
def update
@name = CGI.unescape(params[:id])
@page = @wiki.page(@name)
name = params[:rename] || @name
@name = CGI.unescape(params[:id])
@page = @wiki.page(@name)
name = wiki_page_params[:rename] || @name
update_wiki_page(@wiki, @page, params[:content], {committer: committer}, name, params[:format])
update_wiki_page(@wiki, @page.footer, params[:footer], {committer: committer}) if params[:footer]
update_wiki_page(@wiki, @page.sidebar, params[:sidebar], {committer: committer}) if params[:sidebar]
update_wiki_page(@wiki, @page, wiki_page_params[:content], {committer: committer}, name, wiki_page_params[:format])
update_wiki_page(@wiki, @page.footer, wiki_page_params[:footer], {committer: committer}) if wiki_page_params[:footer]
update_wiki_page(@wiki, @page.sidebar, wiki_page_params[:sidebar], {committer: committer}) if wiki_page_params[:sidebar]
committer.commit
@ -61,17 +61,18 @@ class Projects::WikiController < Projects::BaseController
def new
@name = ''
@new = true
end
def create
@name = CGI.unescape(params['page'])
format = params['format'].intern
@name = CGI.unescape(wiki_page_params[:page])
format = wiki_page_params[:format].intern
begin
@wiki.write_page(@name, format, params['content'] || '', {committer: committer}).commit
@wiki.write_page(@name, format, wiki_page_params[:content] || '', {committer: committer}).commit
redirect_to project_wiki_path(@project, CGI.escape(@name))
rescue Gollum::DuplicatePageError => e
flash[:error] = t("flash.wiki.duplicate_page", name: @name)
render action: :new
render :new
end
end
@ -183,8 +184,8 @@ class Projects::WikiController < Projects::BaseController
end
def preview
@name = params['page']
@page = @wiki.preview_page(@name, params['content'], params['format'])
@name = wiki_page_params[:page]
@page = @wiki.preview_page(@name, wiki_page_params[:content], wiki_page_params[:format])
@content = @page.formatted_data
@editable = false
render :show
@ -234,9 +235,8 @@ class Projects::WikiController < Projects::BaseController
end
def commit_message
if params['message'] and !params['message'].empty?
msg = params['message']
else
msg = wiki_page_params[:message].presence
unless msg
msg = case action_name.to_s
when 'create' then "Created page #{@name.to_s}"
when 'update' then "Updated page #{@name.to_s}"
@ -244,7 +244,7 @@ class Projects::WikiController < Projects::BaseController
when 'revert' then "Reverted page #{@name.to_s}"
when 'revert_wiki' then "Reverted wiki"
end
msg << " (#{params['format']})" if params['format']
msg << " (#{wiki_page_params[:format]})" if wiki_page_params[:format]
end
msg = 'Unhandled action' if !msg || msg.empty?
{ message: msg }
@ -274,6 +274,10 @@ class Projects::WikiController < Projects::BaseController
end
end
def wiki_page_params
@wiki_page_params ||= params[:wiki_page] || {}
end
def authorize_read_actions
authorize! :show, @project
end

View File

@ -41,14 +41,14 @@ module WikiHelper
end
def footer
if @footer.nil?
if @footer.nil? && @page
@footer = !!@page.footer ? @page.footer : false
end
@footer
end
def sidebar
if @sidebar.nil?
if @sidebar.nil? && @page
@sidebar = !!@page.sidebar ? @page.sidebar : false
end
@sidebar
@ -101,6 +101,6 @@ module WikiHelper
end
def format
@new ? 'markdown' : @page.format
@page.try(:format) || 'markdown'
end
end

11
app/models/wiki_page.rb Normal file
View File

@ -0,0 +1,11 @@
class WikiPage < Struct.new(:page, :format, :content, :footer, :sidebar)
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_accessor :message, :rename
def rename
@rename ||= page
end
end

View File

@ -1,23 +0,0 @@
- revert_button = capture do
= link_to t("wiki.revert_page#{action_name == 'revert' ? '' : 's'}"), '#', class: "gollum-revert-button button width100"
- if action_name != 'revert'
= form_tag revert_path(@project, @versions.first[0..6], (@versions.size == 1) ? 'prev' : @versions.last[0..6], @name), name: "gollum-revert", id: "gollum-revert-form" do
= revert_button if can? :write, @project
%br
%br
= render partial: 'diff_data', collection: @diffs, as: :diff
.spacer
%br
%br
- if action_name != 'revert'
= revert_button if can? :write, @project
%br
%br
= link_to t("wiki.back_to_top"), '#wiki'

View File

@ -1,37 +0,0 @@
#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("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 'editor_toolbar'
= 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("wiki.expand_collapse")
%h4= t("wiki.footer")
= text_area_tag :footer, footer.text_data
- if has_sidebar?
#gollum-editor-edit-sidebar.collapsed
= link_to "#", class: "button" do
%span= t("wiki.expand_collapse")
%h4= t("wiki.sidebar")
= text_area_tag :sidebar, sidebar.text_data
#gollum-editor-edit-summary.singleline
= label_tag :message, t("wiki.edit_commit_message"), class: "jaws"
= text_field_tag :message, t("wiki.commit_message_placeholder"), id: "gollum-editor-message-field"
%span.jaws
%br
= submit_tag t('wiki.save_button'), id: 'gollum-editor-submit', title: t('wiki.save_changes'), data: {'disable-with' => t('layout.saving')}
= link_to t("wiki.preview"), "javascript:void(0)", id: "gollum-editor-preview", class: "minibutton", title: t("wiki.preview_title"), :'data-url' => preview_project_wiki_index_path(@project)

View File

@ -0,0 +1,19 @@
- wiki_page = WikiPage.new(@name, format, @content, footer.try(:text_data), sidebar.try(:text_data))
= simple_form_for wiki_page, url: editor_path(@project, @name), html: { method: @new ? :post : :put } do |f|
- if @new
= f.input :page
- else
= f.hidden_field :page
= f.input :rename
= f.input :format, collection: wiki_formats, include_blank: false
= f.input :content, as: :text, input_html: { rows: 15 }
- if has_footer?
= f.input :footer, as: :text
- if has_sidebar?
= f.input :sidebar, as: :text
= f.input :message, as: :text
hr
= f.button :submit, t('wiki.save_button')

View File

@ -1,61 +0,0 @@
#gollum-editor-function-bar
#gollum-editor-function-buttons
= link_to "#", id: "function-bold", class: "function-button", title: t("wiki.editor.bold") do
%span= t("wiki.editor.bold")
= link_to "#", id: "function-italic", class: "function-button", title: t("wiki.editor.italic") do
%span= t("wiki.editor.italic")
= link_to "#", id: "function-code", class: "function-button", title: t("wiki.editor.code") do
%span= t("wiki.editor.code")
%span.function-divider &nbsp;
= link_to "#", id: "function-ul", class: "function-button", title: t("wiki.editor.unordered_list") do
%span= t("wiki.editor.unordered_list")
= link_to "#", id: "function-ol", class: "function-button", title: t("wiki.editor.ordered_list") do
%span= t("wiki.editor.ordered_list")
= link_to "#", id: "function-blockquote", class: "function-button", title: t("wiki.editor.blockquote") do
%span= t("wiki.editor.blockquote")
= link_to "#", id: "function-hr", class: "function-button", title: t("wiki.editor.horizontal_rule") do
%span= t("wiki.editor.horizontal_rule")
%span.function-divider &nbsp;
= link_to "#", id: "function-h1", class: "function-button", title: t("wiki.editor.h1") do
%span= t("wiki.editor.h1")
= link_to "#", id: "function-h2", class: "function-button", title: t("wiki.editor.h2") do
%span= t("wiki.editor.h2")
= link_to "#", id: "function-h3", class: "function-button", title: t("wiki.editor.h3") do
%span= t("wiki.editor.h3")
%span.function-divider &nbsp;
= link_to "#", id: "function-link", class: "function-button", title: t("wiki.editor.link") do
%span= t("wiki.editor.link")
= link_to "#", id: "function-image", class: "function-button", title: t("wiki.editor.image") do
%span= t("wiki.editor.image")
%span.function-divider &nbsp;
= link_to "#", id: "function-help", class: "function-button", title: t("wiki.editor.help") do
%span= t("wiki.editor.help")
#gollum-editor-format-selector
= select_tag :format, options_for_select(wiki_formats, format), id: "wiki_format"
= label_tag :format, t("wiki.editor.format")
#gollum-editor-help.jaws
%ul#gollum-editor-help-parent
%li= link_to "help_1", "javascript:void(0);", class: "selected"
%li= link_to "help_1", "javascript:void(0);"
%li= link_to "help_1", "javascript:void(0);"
%ul#gollum-editor-help-list
%li= link_to "help_2", "javascript:void(0);"
%li= link_to "help_3", "javascript:void(0);"
%li= link_to "help_4", "javascript:void(0);"
%li= link_to "help_5", "javascript:void(0);"
%li= link_to "help_6", "javascript:void(0);"
%li= link_to "help_7", "javascript:void(0);"
%li= link_to "help_8", "javascript:void(0);"
#gollum-editor-help-wrapper
#gollum-editor-help-content
%p

View File

@ -1,18 +0,0 @@
.name
= link_to t("wiki.clones.http"), git_repo_url(@project.wiki_repo_name), :'data-permissions' => (can? :write, @project) ? 'Read+Write' : 'Read'
#url-field{style: 'display: inline'}
.role
:javascript
$(document).ready(function() {
var link = $('.name a').first();
$('.name #url-field').text(link.attr('href'));
$('.role').text(link.attr('data-permissions'));
$('.name a').on('click', function(e) {
e.preventDefault();
$('.name #url-field').text($(this).attr('href'));
$('.role').text($(this).attr('data-permissions'));
});
});

View File

@ -1,11 +1,12 @@
= form_tag compare_path(@project, @name), name: "compare-versions", id: "version-form" do
table.table
input.btn.btn-primary name='commit' type='submit' value=t('wiki.compare_revisions') ng-disabled='selected != 2'
hr
table.table ng-init='selected = 0'
- @versions.each do |v|
tr
td
/ span#niceCheckbox1.niceCheck-main onclick="changeCheck(this)"
/ = check_box_tag "versions[]", v.id, html: {class: 'history_cbx'}
input type='checkbox' id='versions_' name='versions[]' value=v.id class='history_cbx'
input type='checkbox' id='versions_' name='versions[]' value=v.id class='history_cbx' ng-model="versions.#{v.id}" ng-change='versions.#{v.id} ? (selected = selected + 1) : (selected = selected - 1)'
td
- user = User.where(email: v.author.email).first
=> link_to user_path_by_user(user) do
@ -15,23 +16,10 @@
span.username
= user.present? ? user.fullname : v.author.name
td
= datetime_moment v.committed_date, tag: :span, class: 'wiki-gray'
= v.message
=> v.message
- if @name
= raw "[#{link_to v.id[0..6], versioned_project_wiki_path(@project, escaped_name, v.id), title: t("wiki.view_commit")}]"
- else
= "[#{v.id[0..6]}]"
/ - content_for :javascript do
/ coffee:
/ $('.niceCheck-main').click ->
/ count = 0
/ $('input.history_cbx').each (i,el) ->
/ if $(el).is(':checked')
/ count = count + 1
/ if count > 2
/ cbx = $( $(this).find('input.history_cbx')[0] )
/ if cbx.is(':checked')
/ $(this).css('background-position', '0pt 0px')
/ cbx.removeAttr('checked')
.help-block
= datetime_moment v.committed_date, tag: :span, class: 'wiki-gray'

View File

@ -1,13 +0,0 @@
- act = action_name.intern
.sub-menu
.left= @project.name
%nav
%ul
%li{class: ((act == :show and @name == 'Home') or act == :index) ? 'active' : ''}
= link_to t("wiki.home"), project_wiki_index_path(@project)
%li{class: (act == :pages) ? 'active' : ''}
= link_to t("wiki.pages"), pages_project_wiki_index_path(@project)
%li{class: (act == :wiki_history or act == :compare_wiki) ? 'active' : ''}
= link_to t("wiki.wiki_history"), history_project_wiki_index_path(@project)
%li{class: (act == :git) ? 'active' : ''}
= link_to t("wiki.git_access"), git_project_wiki_index_path(@project)

View File

@ -1,23 +1,19 @@
#wiki-content
/ .wrap{class: "#{has_footer? ? 'has-footer' : ''} #{has_sidebar? ? 'has-rightbar' : ''}"}
.wrap
#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
.both
.col-md-12
= raw @content
- if has_sidebar?
.col-md-12
= raw sidebar_content
- if has_footer?
.col-md-12
= raw footer_content
hr
.help-block
=> t("wiki.last_edited_by")
b>
= user_link_by_user User.where(email: author_email).first
= datetime_moment date, tag: :span
- unless action_name == 'preview' or cannot? :write, @project
a.btn.btn-danger href=project_wiki_path(@project, escaped_name) data-method='delete' data-confirm=t('layout.confirm')
= t("wiki.delete_page")
.col-md-12
hr
.help-block
=> t("wiki.last_edited_by")
b>
= user_link_by_user User.where(email: author_email).first
= datetime_moment date, tag: :span
- unless action_name == 'preview' or cannot? :write, @project
a.btn.btn-danger href=project_wiki_path(@project, escaped_name) data-method='delete' data-confirm=t('layout.confirm')
= t("wiki.delete_page")

View File

@ -1,17 +0,0 @@
%p
- if @results.present?
- @results.each do |result|
- if action_name == 'search'
= link_to result[:name], project_wiki_path(@project, CGI.escape(result[:name]))
%span.count= "(#{result.count} #{t("wiki.matches")})"
-else
= link_to result.name, project_wiki_path(@project, CGI.escape(result.name))
%br
- else
%p#no-results
- @st_ref = capture do
%strong= @ref || @query
- if action_name == 'search'
= raw t("wiki.no_results_for_search", query: @st_ref)
- else
= raw t("wiki.no_pages_in", ref: @st_ref)

View File

@ -0,0 +1,20 @@
- if @results.present?
ul.list-unstyled
- @results.each do |result|
li
- if action_name == 'search'
a> href=project_wiki_path(@project, CGI.escape(result[:name]))
= result[:name]
span
= "(#{result.count} #{t("wiki.matches")})"
- else
a href=project_wiki_path(@project, CGI.escape(result.name))
= result.name
- else
p
- @st_ref = capture do
strong= @ref || @query
- if action_name == 'search'
= raw t("wiki.no_results_for_search", query: @st_ref)
- else
= raw t("wiki.no_pages_in", ref: @st_ref)

View File

@ -1,7 +0,0 @@
#gollum-searchbar
= form_tag search_project_wiki_index_path(@project), method: :get, id: "gollum-search-form" do
#gollum-searchbar-fauxtext
= text_field_tag :q, t("wiki.search_and_hellip"), id: "search-query", autocomplete: "on"
= link_to "#", id: "search-submit", title: t("wiki.search_popup") do
%span= t("wiki.search")
.both

View File

@ -0,0 +1,3 @@
hr
= form_tag search_project_wiki_index_path(@project), method: :get, class: 'form' do
input.form-control type='text' name='q' placeholder=t('wiki.search_and_hellip') value=params[:q]

View File

@ -1,18 +1,4 @@
- act = action_name.intern
/ %aside
/ .admin-preferences
/ %ul
/ %li{class: ((act == :show and @name == 'Home') or act == :index) ? 'active' : ''}
/ = link_to t("wiki.home"), project_wiki_index_path(@project)
/ %li{class: (act == :pages) ? 'active' : ''}
/ = link_to t("wiki.pages"), pages_project_wiki_index_path(@project)
/ %li{class: (act == :wiki_history or act == :compare_wiki) ? 'active' : ''}
/ = link_to t("wiki.wiki_history"), history_project_wiki_index_path(@project)
/ %li{class: (act == :git) ? 'active' : ''}
/ = link_to t("wiki.git_access"), git_project_wiki_index_path(@project)
/ %br
/ = render 'searchbar'
.panel.panel-default
.panel-body
ul.nav.nav-pills.nav-stacked
@ -32,3 +18,5 @@
li class=('active' if act == :git)
a href=git_project_wiki_index_path(@project)
= t('wiki.git_access')
li
= render 'searchbar'

View File

@ -1,23 +0,0 @@
-set_meta_tags title: [title_object(@project), t('.title')]
= render 'gollum_includes'
/ = render 'project_short'
= render 'submenu'
%h3.wiki
- if @name
= t("wiki.history_for")
%strong= @page.name
- else
= t("wiki.wiki_history")
%br
%br
.r
- if can? :read, @project
= link_to t("wiki.back_to_history"), @name ? history_project_wiki_path(@project, escaped_name) : history_project_wiki_index_path(@project), class: 'button width100'
#wiki-content= render "compare"
- content_for :sidebar do
- render 'sidebar'

View File

@ -0,0 +1,32 @@
- set_meta_tags title: [title_object(@project), t('.title')]
== render 'submenu'
.row
.col-md-2.col-md-offset-1
== render 'sidebar'
.col-md-8
.row
.col-md-6
h3
- if @name
=> t('wiki.history_for')
strong= @page.name
- else
= t('wiki.wiki_history')
.col-md-6.offset20
= simple_form_for :project, url: revert_path(@project, @versions.first[0..6], (@versions.size == 1) ? 'prev' : @versions.last[0..6], @name) do |f|
- if can? :read, @project
a.btn.btn-primary> href=(@name ? history_project_wiki_path(@project, escaped_name) : history_project_wiki_index_path(@project))
= t('wiki.back_to_history')
- if can? :write, @project
= f.button :submit, t("wiki.revert_page#{action_name == 'revert' ? '' : 's'}")
hr
.row
.col-md-12
== render partial: 'diff_data', collection: @diffs, as: :diff
hr
= link_to t("wiki.back_to_top"), '#wiki'

View File

@ -1,24 +0,0 @@
-set_meta_tags title: [title_object(@project), "#{t('wiki.editing_page')} #{@page.name}"]
= render 'gollum_includes'
/ = render 'project_short'
= render 'submenu'
.left
%h3
= t("wiki.editing_page")
%strong= @page.name
- if can? :read, @project
.r= link_to t("wiki.view_page"), view_path(@project, escaped_name), class: 'action-view-page button'
.r= link_to t("wiki.page_history"), history_project_wiki_path(@project, escaped_name), class: 'aciton-view-history button'
.both
#wiki-content= render "editor"
:javascript
jQuery(document).ready(function() {
$.GollumEditor();
});
:css
#gollum-editor { width: 100%; }
- content_for :sidebar do
- render 'sidebar'

View File

@ -0,0 +1,25 @@
- set_meta_tags title: [title_object(@project), "#{t('wiki.editing_page')} #{@page.name}"]
== render 'submenu'
.row
.col-md-2.col-md-offset-1
== render 'sidebar'
.col-md-8
.row
.col-md-8
h3
=> t('wiki.editing_page')
strong= @page.name
- if can? :read, @project
.col-md-4.offset20
a.btn.btn-primary> href=view_path(@project, escaped_name)
= t('wiki.view_page')
a.btn.btn-primary> href=history_project_wiki_path(@project, escaped_name)
= t('wiki.page_history')
hr
.row
.col-md-12
== render 'editor'

View File

@ -1,6 +1,5 @@
-set_meta_tags title: [title_object(@project), t('wiki.git_access')]
/ = render 'gollum_includes'
/ = render 'project_short'
== render 'submenu'
.row

View File

@ -6,6 +6,5 @@
.col-md-2.col-md-offset-1
== render 'sidebar'
.col-md-8
= link_to t("wiki.compare_revisions"), "javascript:void(0);", class: "action-compare-revision button width100"
== render 'history'

View File

@ -1,21 +0,0 @@
= render 'gollum_includes'
/ = render 'project_short'
= render 'submenu'
%h3.wiki
= t("wiki.create_page")
%strong= @name
%br
#wiki-content= render "editor"
:javascript
jQuery(document).ready(function() {
$.GollumEditor({ NewFile: true });
});
:css
#gollum-editor { width: 100%; }
- content_for :sidebar do
- render 'sidebar'

View File

@ -0,0 +1,17 @@
== render 'submenu'
.row
.col-md-2.col-md-offset-1
== render 'sidebar'
.col-md-8
.row
.col-md-8
h3
=> t('wiki.create_page')
strong= @name
hr
.row
.col-md-12
== render 'editor'

View File

@ -7,7 +7,7 @@
== render 'sidebar'
.col-md-8
- if can? :write, @project
a.btn.btn-primary href=project_wiki_index_path(@project)
a.btn.btn-primary href=new_project_wiki_path(@project)
= t("wiki.new_page")
hr

View File

@ -1,15 +0,0 @@
-set_meta_tags title: [title_object(@project), @query, t('wiki.searching.title')]
= render 'submenu'
- @st_query = capture do
%strong= @query
%h1.title= raw t("wiki.search_results_for", query: @st_query)
%ul.actions
- if can? :read, @project
%li.minibutton= link_to t("wiki.home"), project_wiki_index_path(@project), class: 'action-edit-page'
= render "results"
- content_for :sidebar do
- render 'sidebar'

View File

@ -0,0 +1,23 @@
- set_meta_tags title: [title_object(@project), @query, t('wiki.searching.title')]
== render 'submenu'
.row
.col-md-2.col-md-offset-1
== render 'sidebar'
.col-md-8
.row
.col-md-8
h3
- @st_query = capture do
strong= @query
= raw t("wiki.search_results_for", query: @st_query)
- if can? :read, @project
.col-md-2.offset20
a.btn.btn-primary href=project_wiki_index_path(@project)
= t('wiki.home')
hr
.row
.col-md-12
== render 'results'

View File

@ -7,9 +7,22 @@
== render 'sidebar'
.col-md-8
h3
= @page.name
= "(#{ t("wiki.preview") })" if action_name == 'preview'
- unless action_name == 'preview'
.row
== render 'page'
.col-md-4
h3
= @page.name
= "(#{ t("wiki.preview") })" if action_name == 'preview'
- unless action_name == 'preview'
.col-md-8.offset20
a.btn.btn-primary> href=history_project_wiki_path(@project, escaped_name)
= t('wiki.page_history')
- if @editable
a.btn.btn-primary> href=edit_project_wiki_path(@project, escaped_name)
= t('wiki.edit_page')
- if can? :write, @project
a.btn.btn-primary href=new_project_wiki_path(@project)
= t('wiki.new_page')
hr
.row
.col-md-8
== render 'page'