This repository has been archived by the owner on Aug 15, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added versioning to the content sections plugin. It's still a bit bug…
…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
Showing
15 changed files
with
79 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
24 changes: 24 additions & 0 deletions
24
vendor/plugins/ansuz_content_section/app/views/admin/content_sections/_edit.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
1 change: 1 addition & 0 deletions
1
vendor/plugins/ansuz_content_section/app/views/admin/content_sections/_get_dropdown.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= rollback_dropdown(@content_section) %> |
File renamed without changes.
6 changes: 0 additions & 6 deletions
6
vendor/plugins/ansuz_content_section/app/views/content_sections/_edit.html.erb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
resources :content_sections | ||
namespace :admin do |admin| | ||
admin.resources :content_sections, :member => [:rollback, :get_dropdown] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,7 +94,7 @@ def next_page collection | |
end | ||
|
||
def admin? | ||
current_user.is_admin? | ||
logged_in? && current_user.is_admin? | ||
end | ||
|
||
end |