Actualizar plugin Private Wiki a 0.2.0-mistraloz

This commit is contained in:
Manuel Cillero 2020-11-30 11:11:31 +01:00
parent b37d1305f1
commit fd78375294
10 changed files with 43 additions and 59 deletions

View file

@ -29,7 +29,7 @@ To set public/private wiki page :
$bundle exec rake redmine:plugins:migrate RAILS_ENV=production $bundle exec rake redmine:plugins:migrate RAILS_ENV=production
## Compatibility : ## Compatibility :
Tested for RedMine 3.3.* (Manually) Tested for RedMine 4.0.3 (Manually)
## License : ## License :
This plugin is licensed under the MIT license. This plugin is licensed under the MIT license.

View file

@ -3,7 +3,7 @@
<!--If the wiki is private, set PRIVATE flag--> <!--If the wiki is private, set PRIVATE flag-->
<% if @page.private? and User.current.allowed_to?(:view_privates_wiki, @project) %> <% if @page.private? and User.current.allowed_to?(:view_privates_wiki, @project) %>
<span class="private_page_flag" title="<%= l(:private_title) %>"><%= l(:private_flag) %></span> <span class="private_wiki_flag private_wiki_head"><%= l(:private_flag) %></span>
<% end %> <% end %>
<!--If authorized, allow user to see changing privacy buttons--> <!--If authorized, allow user to see changing privacy buttons-->
@ -11,7 +11,7 @@
<%= link_to_if_authorized(l(:button_setpublic_wiki), {:action => 'change_privacy', :id => @page.title, :private => 0}, :method => :post, :class => 'icon icon-setpublic') if @page.private? %> <%= link_to_if_authorized(l(:button_setpublic_wiki), {:action => 'change_privacy', :id => @page.title, :private => 0}, :method => :post, :class => 'icon icon-setpublic') if @page.private? %>
<script type="text/javascript"> <script type="text/javascript">
$('.contextual:first').prepend($('.private_page_flag')); $('.contextual:first').prepend($('.private_wiki_flag.private_wiki_head'));
$('.contextual:first').append($('.icon-setprivate')); $('.contextual:first').append($('.icon-setprivate'));
$('.contextual:first').append($('.icon-setpublic')); $('.contextual:first').append($('.icon-setpublic'));
</script> </script>

View file

@ -27,7 +27,7 @@
<% if !page.private? %> <% if !page.private? %>
<li><%= link_to page.pretty_title, :action => 'show', :id => page.title, :project_id => page.project %></li> <li><%= link_to page.pretty_title, :action => 'show', :id => page.title, :project_id => page.project %></li>
<% elsif User.current.allowed_to?(:view_privates_wiki, @project) %> <% elsif User.current.allowed_to?(:view_privates_wiki, @project) %>
<li><%= link_to page.pretty_title, :action => 'show', :id => page.title, :project_id => page.project %> <span class="private_wiki_flag" style="display:inline-block;" title="<%= l(:private_title) %>"><%= l(:private_flag) %></span></li> <li><%= link_to page.pretty_title, :action => 'show', :id => page.title, :project_id => page.project %>&nbsp;&nbsp;&nbsp;&nbsp;<span class="private_wiki_flag" style="display:inline-block;"><%= l(:private_flag) %></span></li>
<% end %> <% end %>
<% end %> <% end %>
</ul> </ul>
@ -35,7 +35,7 @@
<h3><%= format_date(date) %></h3> <h3><%= format_date(date) %></h3>
<ul> <ul>
<% @pages_by_date[date].each do |page| %> <% @pages_by_date[date].each do |page| %>
<li><%= link_to page.pretty_title, :action => 'show', :id => page.title, :project_id => page.project %> <span class="private_wiki_flag" style="display:inline-block;" title="<%= l(:private_title) %>"><%= l(:private_flag) %></span></li> <li><%= link_to page.pretty_title, :action => 'show', :id => page.title, :project_id => page.project %>&nbsp;&nbsp;&nbsp;&nbsp;<span class="private_wiki_flag" style="display:inline-block;"><%= l(:private_flag) %></span></li>
<% end %> <% end %>
</ul> </ul>
<% end %> <% end %>

View file

@ -1,21 +1,14 @@
.private_page_flag,
.private_wiki_flag { .private_wiki_flag {
background: #d22; background: #D22;
color: white; color: white;
padding: 1px 2px; padding: 2px 2px 2px 2px;
border-radius: 2px; border-radius: 2px;
cursor: default;
}
.private_wiki_flag {
margin-left: .44em;
background: rgb(255, 50, 0, 0.5);
line-height: 1em;
} }
.icon-setprivate{ .icon-setprivate{
background-image: url(../images/hide.png); background-image: url(../images/hide.png);
} }
.icon-setpublic{ .icon-setpublic{
background-image: url(../images/reveal.png); background-image: url(../images/reveal.png);
} }

View file

@ -2,5 +2,4 @@
en: en:
button_setprivate_wiki: Set Private button_setprivate_wiki: Set Private
button_setpublic_wiki: Set Public button_setpublic_wiki: Set Public
private_flag: P! private_flag: PRIVATE
private_title: Private page

View file

@ -1,6 +0,0 @@
# Spanish strings go here for Rails i18n
es:
button_setprivate_wiki: Priv.
button_setpublic_wiki: Pub.
private_flag: P!
private_title: Página privada

View file

@ -2,5 +2,4 @@
fr: fr:
button_setprivate_wiki: Rendre Privé button_setprivate_wiki: Rendre Privé
button_setpublic_wiki: Rendre Public button_setpublic_wiki: Rendre Public
private_flag: P! private_flag: PRIVÉ
private_title: Privé

View file

@ -1,4 +1,4 @@
class AddPrivateWikiAttribute < ActiveRecord::Migration class AddPrivateWikiAttribute < ActiveRecord::Migration[4.2]
def change def change
#Add a "Private" attribute used to identify visibility of wikis #Add a "Private" attribute used to identify visibility of wikis
add_column(:wiki_pages, "private", :boolean, :default => false) add_column(:wiki_pages, "private", :boolean, :default => false)

View file

@ -3,36 +3,35 @@ module WikiPatches
module ApplicationHelperPatch module ApplicationHelperPatch
def self.included(base) def self.included(base)
base.class_eval do base.class_eval do
#Override application's method to not display hidden wikis or to display it with the PRIVATE flag #Override application's method to not display hidden wikis or to display it with the PRIVATE flag
def render_page_hierarchy_with_wiki_hidding(pages, node=nil, options={}) def render_page_hierarchy(pages, node=nil, options={})
content = '' content = +''
if pages[node] if pages[node]
content << "<ul class=\"pages-hierarchy\">\n" content << "<ul class=\"pages-hierarchy\">\n"
pages[node].each do |page| pages[node].each do |page|
if !page.private? then if page.private and !User.current.allowed_to?(:view_privates_wiki, @project) then
content << "<li>" next
content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'show', :project_id => page.project, :id => page.title, :version => nil}, end
:title => (options[:timestamp] && page.updated_on ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil)) content << "<li>"
content << "\n" + render_page_hierarchy(pages, page.id, options) if pages[page.id] if controller.controller_name == 'wiki' && controller.action_name == 'export'
content << "</li>\n" href = "##{page.title}"
elsif User.current.allowed_to?(:view_privates_wiki, @project) then else
content << "<li>" href = {:controller => 'wiki', :action => 'show', :project_id => page.project, :id => page.title, :version => nil}
content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'show', :project_id => page.project, :id => page.title, :version => nil}, end
:title => (options[:timestamp] && page.updated_on ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil)) content << link_to(h(page.pretty_title), href,
content << ' <span class="private_wiki_flag" style="display:inline-block;" title="' + l(:private_title) + '">' + l(:private_flag) + '</span>' :title => (options[:timestamp] && page.updated_on ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil))
content << "\n" + render_page_hierarchy(pages, page.id, options) if pages[page.id] if page.private then
content << "</li>\n" content << "&nbsp;&nbsp;&nbsp;&nbsp;<span class=\"private_wiki_flag\" style=\"display:inline-block;\">" + l(:private_flag) + "</span>"
end end
end content << "\n" + render_page_hierarchy(pages, page.id, options) if pages[page.id]
content << "</ul>\n" content << "</li>\n"
end end
content.html_safe content << "</ul>\n"
end end
content.html_safe
alias_method_chain :render_page_hierarchy, :wiki_hidding end
end end
end end
end end
end end

View file

@ -5,7 +5,7 @@ module WikiPatches
base.class_eval do base.class_eval do
unloadable unloadable
#Test :valide before :show action on wiki_controller #Test :valide before :show action on wiki_controller
before_filter :validate, :only => [:show,:edit,:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy] before_action :validate, :only => [:show,:edit,:rename, :protect, :history, :diff, :annotate, :add_attachment, :destroy]
end end
end end