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 | 46 | |
| 47 | 47 | if @version |
| 48 | 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 | 53 | end |
| 52 | 54 | |
| 53 | 55 | if request.xhr? && params[:toolbar] |
| ... | ... | @@ -135,6 +137,11 @@ class ContentViewerController < ApplicationController |
| 135 | 137 | end |
| 136 | 138 | end |
| 137 | 139 | |
| 140 | +# def article_versions | |
| 141 | +# @page = profile.articles.find(params[:page]) | |
| 142 | +# @versions = @page.versions | |
| 143 | +# end | |
| 144 | + | |
| 138 | 145 | protected |
| 139 | 146 | |
| 140 | 147 | def per_page | ... | ... |
app/helpers/article_helper.rb
| ... | ... | @@ -42,7 +42,15 @@ module ArticleHelper |
| 42 | 42 | 'div', |
| 43 | 43 | check_box(:article, :display_hits) + |
| 44 | 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 | 55 | end |
| 48 | 56 | ... | ... |
app/models/article.rb
| ... | ... | @@ -604,6 +604,16 @@ class Article < ActiveRecord::Base |
| 604 | 604 | false |
| 605 | 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 | 617 | def author(version_number = nil) |
| 608 | 618 | if version_number |
| 609 | 619 | version = versions.find_by_version(version_number) | ... | ... |
app/models/text_article.rb
app/views/content_viewer/_article_versions.rhtml
app/views/content_viewer/versioned_article.rhtml
| 1 | 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 | 12 | <div id="article-header"> |
| 4 | 13 | <h1 class='title'><%= @versioned_article.name %></h1> |
| 5 | 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 | 85 | </div> |
| 86 | 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 | 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 | 97 | <div class="comments" id="comments_list"> |
| 95 | 98 | |
| 96 | 99 | <% if @page.accept_comments? || @comments_count > 0 %> | ... | ... |
public/designs/icons/tango/style.css
| ... | ... | @@ -104,6 +104,7 @@ |
| 104 | 104 | .icon-deactivate-user { background-image: url(Tango/16x16/emblems/emblem-unreadable.png) } |
| 105 | 105 | .icon-set-admin-role { background-image: url(mod/16x16/apps/user.png) } |
| 106 | 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 | 109 | /******************LARGE ICONS********************/ |
| 109 | 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 | 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 | + | ... | ... |