Commit 658ecf81eaee37b3720a88a9bc0b9e0aeed3f438
1 parent
d7da0420
Exists in
master
and in
22 other branches
Trying to make it prettier :)
Showing
9 changed files
with
58 additions
and
7 deletions
Show diff stats
app/controllers/public/content_viewer_controller.rb
| @@ -46,8 +46,10 @@ class ContentViewerController < ApplicationController | @@ -46,8 +46,10 @@ class ContentViewerController < ApplicationController | ||
| 46 | 46 | ||
| 47 | if @version | 47 | if @version |
| 48 | @versioned_article = @page.versions.find_by_version(@version) | 48 | @versioned_article = @page.versions.find_by_version(@version) |
| 49 | - render :template => 'content_viewer/versioned_article.rhtml' | ||
| 50 | - return | 49 | + unless @versioned_article == @page.versions.latest |
| 50 | + render :template => 'content_viewer/versioned_article.rhtml' | ||
| 51 | + return | ||
| 52 | + end | ||
| 51 | end | 53 | end |
| 52 | 54 | ||
| 53 | if request.xhr? && params[:toolbar] | 55 | if request.xhr? && params[:toolbar] |
| @@ -135,6 +137,11 @@ class ContentViewerController < ApplicationController | @@ -135,6 +137,11 @@ class ContentViewerController < ApplicationController | ||
| 135 | end | 137 | end |
| 136 | end | 138 | end |
| 137 | 139 | ||
| 140 | +# def article_versions | ||
| 141 | +# @page = profile.articles.find(params[:page]) | ||
| 142 | +# @versions = @page.versions | ||
| 143 | +# end | ||
| 144 | + | ||
| 138 | protected | 145 | protected |
| 139 | 146 | ||
| 140 | def per_page | 147 | def per_page |
app/helpers/article_helper.rb
| @@ -42,7 +42,15 @@ module ArticleHelper | @@ -42,7 +42,15 @@ module ArticleHelper | ||
| 42 | 'div', | 42 | 'div', |
| 43 | check_box(:article, :display_hits) + | 43 | check_box(:article, :display_hits) + |
| 44 | content_tag('label', _('I want this article to display the number of hits it received'), :for => 'article_display_hits') | 44 | content_tag('label', _('I want this article to display the number of hits it received'), :for => 'article_display_hits') |
| 45 | + ) : '') + | ||
| 46 | + | ||
| 47 | + (article.can_display_versions? ? | ||
| 48 | + content_tag( | ||
| 49 | + 'div', | ||
| 50 | + check_box(:article, :display_versions) + | ||
| 51 | + content_tag('label', _('I want this article to display a link to older versions'), :for => 'article_display_versions') | ||
| 45 | ) : '') | 52 | ) : '') |
| 53 | + | ||
| 46 | ) | 54 | ) |
| 47 | end | 55 | end |
| 48 | 56 |
app/models/article.rb
| @@ -604,6 +604,16 @@ class Article < ActiveRecord::Base | @@ -604,6 +604,16 @@ class Article < ActiveRecord::Base | ||
| 604 | false | 604 | false |
| 605 | end | 605 | end |
| 606 | 606 | ||
| 607 | + settings_items :display_versions, :type => :boolean, :default => false | ||
| 608 | + | ||
| 609 | + def can_display_versions? | ||
| 610 | + false | ||
| 611 | + end | ||
| 612 | + | ||
| 613 | + def display_versions? | ||
| 614 | + can_display_versions? && display_versions | ||
| 615 | + end | ||
| 616 | + | ||
| 607 | def author(version_number = nil) | 617 | def author(version_number = nil) |
| 608 | if version_number | 618 | if version_number |
| 609 | version = versions.find_by_version(version_number) | 619 | version = versions.find_by_version(version_number) |
app/models/text_article.rb
app/views/content_viewer/_article_versions.rhtml
| 1 | +<h3><%= _('Versions') %></h3> | ||
| 1 | <ul class='article-versions'> | 2 | <ul class='article-versions'> |
| 2 | <% @page.versions.each do |v| %> | 3 | <% @page.versions.each do |v| %> |
| 3 | - <li><%= link_to("r#{v.version}", @page.url.merge(:rev => v.version)) %></li> | 4 | + <li><%= link_to("#{v.version}", @page.url.merge(:rev => v.version)) %></li> |
| 4 | <% end %> | 5 | <% end %> |
| 5 | <ul> | 6 | <ul> |
app/views/content_viewer/versioned_article.rhtml
| 1 | <div id="article" class="<%= @page.css_class_name %>"> | 1 | <div id="article" class="<%= @page.css_class_name %>"> |
| 2 | 2 | ||
| 3 | + <% if @page.allow_edit?(user) && !remove_content_button(:edit) %> | ||
| 4 | + <div id="article-revert-version"> | ||
| 5 | + <% content = content_tag('span', _('Revert to this version')) %> | ||
| 6 | + <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'edit', :id => @page.id, :article => @versioned_article.attributes }) %> | ||
| 7 | + <%= expirable_button @page, :edit, content, url %> | ||
| 8 | + <% end %> | ||
| 9 | + | ||
| 10 | + </div> | ||
| 11 | + | ||
| 3 | <div id="article-header"> | 12 | <div id="article-header"> |
| 4 | <h1 class='title'><%= @versioned_article.name %></h1> | 13 | <h1 class='title'><%= @versioned_article.name %></h1> |
| 5 | <%= _("Version %{version} - %{author} on %{date}") % {:version => @version, :author => @page.author_name(@version), :date => show_time(@versioned_article.updated_at) } %> | 14 | <%= _("Version %{version} - %{author} on %{date}") % {:version => @version, :author => @page.author_name(@version), :date => show_time(@versioned_article.updated_at) } %> |
app/views/content_viewer/view_page.rhtml
| @@ -85,12 +85,15 @@ | @@ -85,12 +85,15 @@ | ||
| 85 | </div> | 85 | </div> |
| 86 | <% end %> | 86 | <% end %> |
| 87 | 87 | ||
| 88 | -<div id="article-versions"> | ||
| 89 | - <%= @page.versions.map {|v| link_to("r#{v.version}", @page.url.merge(:rev => v.version))} %> | ||
| 90 | -</div> | ||
| 91 | - | ||
| 92 | <%= display_source_info(@page) %> | 88 | <%= display_source_info(@page) %> |
| 93 | 89 | ||
| 90 | +<% if @page.display_versions? %> | ||
| 91 | + <div id="article-versions"> | ||
| 92 | + <%= render :partial => 'article_versions' %> | ||
| 93 | + <%#= button(:clock, _('See older versions'), :controller => 'content_viewer', :profile => profile.identifier, :action => 'article_versions', :page => @page.id) %> | ||
| 94 | + </div> | ||
| 95 | +<% end %> | ||
| 96 | + | ||
| 94 | <div class="comments" id="comments_list"> | 97 | <div class="comments" id="comments_list"> |
| 95 | 98 | ||
| 96 | <% if @page.accept_comments? || @comments_count > 0 %> | 99 | <% if @page.accept_comments? || @comments_count > 0 %> |
public/designs/icons/tango/style.css
| @@ -104,6 +104,7 @@ | @@ -104,6 +104,7 @@ | ||
| 104 | .icon-deactivate-user { background-image: url(Tango/16x16/emblems/emblem-unreadable.png) } | 104 | .icon-deactivate-user { background-image: url(Tango/16x16/emblems/emblem-unreadable.png) } |
| 105 | .icon-set-admin-role { background-image: url(mod/16x16/apps/user.png) } | 105 | .icon-set-admin-role { background-image: url(mod/16x16/apps/user.png) } |
| 106 | .icon-reset-admin-role { background-image: url(/images/icons-app/person-icon.png) } | 106 | .icon-reset-admin-role { background-image: url(/images/icons-app/person-icon.png) } |
| 107 | +.icon-clock { background-image: url(Tango/16x16/actions/appointment.png) } | ||
| 107 | 108 | ||
| 108 | /******************LARGE ICONS********************/ | 109 | /******************LARGE ICONS********************/ |
| 109 | .image-gallery-item .folder { background-image: url(mod/96x96/places/folder.png) } | 110 | .image-gallery-item .folder { background-image: url(mod/96x96/places/folder.png) } |
public/stylesheets/application.css
| @@ -6539,3 +6539,12 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img { | @@ -6539,3 +6539,12 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img { | ||
| 6539 | z-index: 1; | 6539 | z-index: 1; |
| 6540 | } | 6540 | } |
| 6541 | 6541 | ||
| 6542 | +ul.article-versions { | ||
| 6543 | + padding: 0px; | ||
| 6544 | +} | ||
| 6545 | + | ||
| 6546 | +ul.article-versions li { | ||
| 6547 | + display: inline; | ||
| 6548 | + font-size: 13px; | ||
| 6549 | +} | ||
| 6550 | + |