Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
added versioning to the content sections plugin. It's still a bit bug…
Browse files Browse the repository at this point in the history
…gy on the js side if you put more than one content section n a page, for obvious reasons.
  • Loading branch information
Josh Adams committed Nov 19, 2008
1 parent 15a3c99 commit 97d9951
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 23 deletions.
11 changes: 11 additions & 0 deletions README
Expand Up @@ -28,6 +28,17 @@ Ansuz is licensed via the BSD license.

NOTE: SQLite has problems with ansuz, please don't use it for now.

== If you had problems with the above

I was asked to add this to the README.

gem install -v=2.1.0 rails --no-ri --no-rdoc
rake rails:freeze:edge RELEASE=2.1.0
gem sources -a http://gems.github.com
gem install haml --no-ri --no-rdoc

If upgrading to 2.1.2, see: http://engines.lighthouseapp.com/projects/10178/tickets/37-module-activesupportdependencies

== This software is BSD licensed. See the COPYING file for details.

For help, feel free to contact the authors at:
Expand Down
14 changes: 14 additions & 0 deletions app/helpers/content_section_helper.rb
@@ -0,0 +1,14 @@
module ContentSectionHelper
def rollback_dropdown content_section, options={}
options[:id] ||= "rollback_dropdown_for_content_section_" + content_section.id.to_s
versions = versions_array(content_section)
the_options = options_for_select(versions.reverse)
the_id = content_section.id
the_select = content_tag("select", the_options, :onchange => "redirect_to_rollback_link(#{the_id}, this.options[this.selectedIndex].value)")
content_tag("div", the_select, :id => options[:id])
end

def versions_array content_section
(1..content_section.versions.length).to_a
end
end
6 changes: 6 additions & 0 deletions public/stylesheets/base.css
Expand Up @@ -132,3 +132,9 @@ ul.photos.item-list a{
ul.photos.item-list a{
opacity: 1;
}
#lightbox-nav a{
display: none;
}
#lightbox-nav a:hover {
display: inline;
}
2 changes: 1 addition & 1 deletion public/stylesheets/forums.css
Expand Up @@ -518,7 +518,7 @@ table
table.wide { width:100%; }
table tr th
{
background:#333;
background:black;
color:white;
padding:3px 10px;
border:1px solid #222;
Expand Down
5 changes: 3 additions & 2 deletions public/stylesheets/jquery.lightbox-0.5.css
Expand Up @@ -55,7 +55,8 @@
z-index: 10;
}
#lightbox-container-image-box > #lightbox-nav { left: 0; }
#lightbox-nav a { outline: none;}
#lightbox-nav a { outline: none; opacity:0;}
#lightbox-nav a:hover { opacity:1.0;}
#lightbox-nav-btnPrev, #lightbox-nav-btnNext {
width: 49%;
height: 100%;
Expand Down Expand Up @@ -98,4 +99,4 @@
width: 66px;
float: right;
padding-bottom: 0.7em;
}
}
7 changes: 0 additions & 7 deletions themes/default/stylesheets/tables.css
Expand Up @@ -97,45 +97,38 @@ tbody tr th a:link {
}

tbody tr th a:visited {
font: bold 0.9em tahoma, arial, sans-serif;
color: #5E7796;
text-decoration: none;

}

tbody tr th a:hover {
font: bold 0.9em tahoma, arial, sans-serif;
color: #5E7796;
text-decoration: none;

}

tbody tr th a:active {
font: bold 0.9em tahoma, arial, sans-serif;
color: #5E7796;
text-decoration: line-through;
}

tbody td a:link {
font: normal 0.9em tahoma, arial, sans-serif;
color: #0084ff;
text-decoration: underline;
}

tbody td a:visited {
font: normal 0.9em tahoma, arial, sans-serif;
color: #0084ff;
text-decoration: none;
}

tbody td a:hover {
font: normal 0.9em tahoma, arial, sans-serif;
color: #0084ff;
text-decoration: none;
}

tbody td a:active {
font: normal 0.9em tahoma, arial, sans-serif;
color: #0084ff;
text-decoration: underline;
}
Expand Down
@@ -1,8 +1,9 @@
class ContentSectionsController < ApplicationController
class Admin::ContentSectionsController < Admin::BaseController
unloadable # This is required if you subclass a controller provided by the base rails app
layout 'admin'
before_filter :load_admin_plugin_nav
before_filter :load_content_section, :only => [:show, :edit, :update]
before_filter :load_content_section, :only => [:show, :edit, :update, :rollback, :get_dropdown]
helper :content_section

protected
# This method duplicated from admin/base_controller
Expand Down Expand Up @@ -32,4 +33,13 @@ def update
end
end
end

def rollback
@content_section.revert_to(params[:version_number])
render :text => @content_section.contents
end

def get_dropdown
render :text => render_to_string(:partial => 'get_dropdown')
end
end
Expand Up @@ -4,15 +4,15 @@ class ContentSection < ActiveRecord::Base
acts_as_versioned

def self.admin_partial
"/content_sections/edit"
"/admin/content_sections/edit"
end

def edit_path
"/content_sections/#{id}/edit"
"/admin/content_sections/#{id}/edit"
end

def self.view_partial
"/content_sections/content_section"
"/admin/content_sections/content_section"
end
end
end
Expand Down
@@ -0,0 +1,24 @@
<% @content_section = plugin_module if local_assigns.include?(:plugin_module) %>
<% remote_form_for :content_section, @content_section, :url => admin_content_section_path(@content_section), :html => { :method => :put }, :before => fckeditor_before_js(:content_section, :contents), :success => "update_dropdown_for(#{@content_section.id})" do |f| -%>
<%= fckeditor_textarea(:content_section, :contents, :toolbarSet => 'Simple', :width => '100%', :height => '400px', :ajax => true) -%><br />
<%= rollback_dropdown(@content_section) %>
<%= submit_tag("Update Content Section", :id => 'close_modal_and_flash') -%>
<% end -%>
<div class="clear"></div>
<script type='text/javascript'>
function redirect_to_rollback_link(content_id, version){
var url = '/admin/content_sections/' + content_id + '/rollback/';
var params = { version_number: version };
jQuery.get(url, params, function(data){
var oe = FCKeditorAPI.GetInstance('content_section_<%= @content_section.id %>_contents_editor');
oe.SetHTML(data);
});
}

function update_dropdown_for(content_section_id){
var url = '/admin/content_sections/' + content_section_id + '/get_dropdown';
jQuery.get(url, function(data){
jQuery("#rollback_dropdown_for_content_section_" + content_section_id).html(data);
});
}
</script>
@@ -0,0 +1 @@
<%= rollback_dropdown(@content_section) %>

This file was deleted.

4 changes: 3 additions & 1 deletion vendor/plugins/ansuz_content_section/routes.rb
@@ -1 +1,3 @@
resources :content_sections
namespace :admin do |admin|
admin.resources :content_sections, :member => [:rollback, :get_dropdown]
end
Expand Up @@ -94,7 +94,7 @@ def next_page collection
end

def admin?
current_user.is_admin?
logged_in? && current_user.is_admin?
end

end

0 comments on commit 97d9951

Please sign in to comment.