Permalink
Browse files

moving references to Snippets into an extension

  • Loading branch information...
1 parent 1bcb2b1 commit 290d6c4aaf6202325be187e92ebf8043c3cb2e0b @saturnflyer saturnflyer committed Mar 2, 2012
@@ -1,8 +0,0 @@
-class Admin::SnippetsController < Admin::ResourceController
- paginate_models
- only_allow_access_to :index, :show, :new, :create, :edit, :update, :remove, :destroy,
- :when => [:designer, :admin],
- :denied_url => { :controller => 'admin/pages', :action => 'index' },
- :denied_message => 'You must have designer privileges to perform this action.'
-
-end
@@ -1,41 +0,0 @@
-module Admin::SnippetsHelper
- def snippet_edit_javascripts
- <<-CODE
-
- var tagReferenceWindows = {};
- function loadTagReference() {
- var pageType = 'Page';
- if (!tagReferenceWindows[pageType])
- tagReferenceWindows[pageType] = new Popup.AjaxWindow("#{admin_reference_path('tags')}?class_name=" + encodeURIComponent(pageType), {reload: false});
- var window = tagReferenceWindows[pageType];
- if('Page' != pageType) {
- $('tag_reference_link').highlight();
- window.show();
- } else {
- window.toggle();
- }
- lastPageType = pageType;
- return false;
- }
-
- var lastFilter = '#{@snippet.filter_id}';
- var filterWindows = {};
- function loadFilterReference() {
- var filter = $F("snippet_filter_id");
- if (filter != "") {
- if (!filterWindows[filter]) filterWindows[filter] = new Popup.AjaxWindow("#{admin_reference_path('filters')}?filter_name="+encodeURIComponent(filter), {reload: false});
- var window = filterWindows[filter];
- if(lastFilter != filter) {
- window.show();
- } else {
- window.toggle();
- }
- lastFilter = filter;
- } else {
- alert('No documentation for filter.');
- }
- return false;
- }
- CODE
- end
-end
View
@@ -1,23 +0,0 @@
-class Snippet < ActiveRecord::Base
-
- # Default Order
- default_scope :order => 'name'
-
- # Associations
- belongs_to :created_by, :class_name => 'User'
- belongs_to :updated_by, :class_name => 'User'
-
- # Validations
- validates_presence_of :name
- validates_length_of :name, :maximum => 100
- validates_length_of :filter_id, :maximum => 25, :allow_nil => true
- validates_format_of :name, :with => %r{^\S*$}
- validates_uniqueness_of :name
-
- object_id_attr :filter, TextFilter
-
- def after_initialize
- self.filter_id ||= Radiant::Config['defaults.snippet.filter'] if new_record?
- end
-
-end
@@ -833,81 +833,6 @@ class RequiredAttributeError < StandardError; end
end
desc %{
- Renders the snippet specified in the @name@ attribute within the context of a page.
-
- *Usage:*
-
- <pre><code><r:snippet name="snippet_name" /></code></pre>
-
- When used as a double tag, the part in between both tags may be used within the
- snippet itself, being substituted in place of @<r:yield/>@.
-
- *Usage:*
-
- <pre><code><r:snippet name="snippet_name">Lorem ipsum dolor...</r:snippet></code></pre>
- }
- tag 'snippet' do |tag|
- required_attr(tag, 'name')
- name = tag['name']
-
- snippet = snippet_cache(name.strip)
-
- if snippet
- tag.locals.yield = tag.expand if tag.double?
- tag.globals.page.render_snippet(snippet)
- else
- raise TagError.new("snippet '#{name}' not found")
- end
- end
-
- def snippet_cache(name)
- @snippet_cache ||= {}
-
- snippet = @snippet_cache[name]
- unless snippet
- snippet = Snippet.find_by_name(name)
- @snippet_cache[name] = snippet
- end
- snippet
- end
- private :snippet_cache
-
- desc %{
- Used within a snippet as a placeholder for substitution of child content, when
- the snippet is called as a double tag.
-
- *Usage (within a snippet):*
-
- <pre><code>
- <div id="outer">
- <p>before</p>
- <r:yield/>
- <p>after</p>
- </div>
- </code></pre>
-
- If the above snippet was named "yielding", you could call it from any Page,
- Layout or Snippet as follows:
-
- <pre><code><r:snippet name="yielding">Content within</r:snippet></code></pre>
-
- Which would output the following:
-
- <pre><code>
- <div id="outer">
- <p>before</p>
- Content within
- <p>after</p>
- </div>
- </code></pre>
-
- When called in the context of a Page or a Layout, @<r:yield/>@ outputs nothing.
- }
- tag 'yield' do |tag|
- tag.locals.yield
- end
-
- desc %{
Inside this tag all page related tags refer to the page found at the @path@ attribute.
@path@s may be relative or absolute paths.
@@ -1,5 +1,5 @@
class UserActionObserver < ActiveRecord::Observer
- observe User, Page, Layout, Snippet
+ observe User, Page, Layout
def current_user=(user)
self.class.current_user = user
@@ -1,33 +0,0 @@
-- form_for [:admin, @snippet], :html => {'data-onsubmit_status' => onsubmit_status(@snippet)} do |f|
- = f.hidden_field :lock_version
- = render_region :form_top, :locals => {:f => f}
- .form_area
- - render_region :form, :locals => {:f => f} do |form|
- - form.edit_title do
- %p.title
- = f.label :name, t('name')
- = f.text_field :name, :class => 'textbox activate', :maxlength => 100
- - form.edit_content do
- %p.content
- = f.label :content, t('body')
- ~ f.text_area :content, :class => "textarea large", :style => "width: 100%"
- - form.edit_filter do
- .set
- %p
- = f.label :filter_id, t('filter')
- = f.select :filter_id, filter_options_for_select(f.object.filter_id), :id => 'snippet_filter'
- %span.reference_links
- == #{t('reference')}:
- %span{:id => "filter_reference_link"}
- = link_to_function t('filter'), "loadFilterReference();"
- %span{:id => "tag_reference_link"}
- = link_to_function t('available_tags'), "loadTagReference('Page');"
- - render_region :form_bottom, :locals => {:f => f} do |form_bottom|
- - form_bottom.edit_buttons do
- .buttons{:style=>"clear: left"}
- = save_model_button(@snippet)
- = save_model_and_continue_editing_button(@snippet)
- = t('or')
- = link_to t('cancel'), admin_snippets_url
- - form_bottom.edit_timestamp do
- = updated_stamp @snippet
@@ -1,9 +0,0 @@
-- @page_title = @snippet.name + ' ' + t('snippet') + ' - ' + default_page_title
-
-- render_region :main do |main|
- - main.edit_header do
- %h1= t('edit_snippet')
- - main.edit_form do
- = render :partial => 'form'
-
-- content_for 'page_scripts', snippet_edit_javascripts
@@ -1,33 +0,0 @@
-- @page_title = t('snippets') + ' - ' + default_page_title
-
-.outset
- = render_region :top
- %table.index#snippets
- %thead
- %tr
- - render_region :thead do |thead|
- - thead.title_header do
- %th.name= t('snippet')
- - thead.actions_header do
- %th.actions{:style=>"width:9em"}= t('modify')
- %tbody
- - if @snippets.any?
- - @snippets.each do |snippet|
- %tr[snippet]
- - render_region :tbody, :locals => {:snippet => snippet} do |tbody|
- - tbody.title_cell do
- %td.name
- = link_to image('snippet', :alt => '') + ' ' + snippet.name, edit_admin_snippet_url(snippet)
- - tbody.actions_cell do
- %td.actions
- = link_to image('minus') + ' ' + t('remove'), remove_admin_snippet_url(snippet), :class => "action"
- - else
- %tr
- %td.empty{:colspan => admin.snippet.index.tbody.length}= t('no_snippets')
-
-- render_region :bottom do |bottom|
- - bottom.new_button do
- #actions
- = pagination_for(@snippets)
- %ul
- %li= link_to image('plus') + " " + t('new_snippet'), new_admin_snippet_url, :class => 'action_button'
@@ -1,7 +0,0 @@
-- render_region :main do |main|
- - main.edit_header do
- %h1= t('new_snippet')
- - main.edit_form do
- = render :partial => 'form'
-
-- content_for 'page_scripts', snippet_edit_javascripts
@@ -1,17 +0,0 @@
-%h1= t('remove_snippet')
-
-%p
- = t('text.snippets.remove_warning')
-
-%table.index#snippets
- %tbody
- %tr.node.level_1
- %td.snippet
- = image('snippet', :alt => "")
- %span.title= @snippet.name
-
-- form_for [:admin, @snippet], :html => {:method => :delete, 'data-onsubmit_status'=>"Removing snippet&#8230;"} do
- .buttons
- %input.button{:type=>"submit", :value => t('delete_snippet')}/
- = t('or')
- = link_to t('cancel'), admin_snippets_url
View
@@ -51,8 +51,6 @@ en:
filter: "page filter"
parts: "page parts"
status: "page status"
- snippet:
- filter: "snippet filter"
dev:
host: "dev site domain"
local:
@@ -81,7 +79,6 @@ en:
- :day
delete_layout: 'Delete Layout'
delete_pages: 'Delete %{pages}'
- delete_snippet: 'Delete Snippet'
delete_user: 'Delete User'
description: 'Description'
design: 'Design'
@@ -93,7 +90,6 @@ en:
edit_page: 'Edit Page'
edit_preferences: 'Edit Preferences'
edit_settings: 'Edit Settings'
- edit_snippet: 'Edit Snippet'
edit_user: 'Edit User'
email_address: 'E-mail Address'
extension: 'Extension'
@@ -116,12 +112,10 @@ en:
new_layout: 'New Layout'
new_page: 'New Page'
new_password: 'New Password'
- new_snippet: 'New Snippet'
new_user: 'New User'
'no': 'No'
no_layouts: 'No Layouts'
no_pages: 'No Pages'
- no_snippets: 'No Snippets'
normal_page: 'Normal Page'
notes: 'Notes'
optional: 'Optional'
@@ -158,7 +152,6 @@ en:
remove_layout: 'Remove Layout'
remove_page: 'Remove Page'
remove_pages: 'Remove %{pages}'
- remove_snippet: 'Remove Snippet'
remove_tab: 'Remove Tab'
remove_user: 'Remove user'
required: 'Required'
@@ -182,8 +175,6 @@ en:
settings: 'Settings'
show_all: 'Show all'
slug: 'Slug'
- snippet: 'Snippet'
- snippets: 'Snippets'
status: 'Status'
# Warnings and info text:
testing: Testing
@@ -192,8 +183,6 @@ en:
remove_warning: 'Are you sure you want to <strong class="warning">permanently remove</strong> the following layout?'
pages:
remove_warning: 'Are you sure you want to <strong class="warning">permanently remove</strong> the following %{pages}?'
- snippets:
- remove_warning: 'Are you sure you want to <strong class="warning">permanently remove</strong> the following snippet?'
users:
remove_warning: 'Are you sure you want to <strong class="warning">permanently remove</strong> the following user?'
this_file_language: "English"
View
@@ -6,7 +6,6 @@
pages.resources :children, :controller => "pages"
end
admin.resources :layouts
- admin.resources :snippets
admin.resources :users
end
map.preview 'admin/preview', :controller => 'admin/pages', :action => 'preview', :conditions => {:method => [:post, :put]}
@@ -1,4 +1,4 @@
-Feature: Managing snippets
+Feature: Managing layouts
In order to properly display the content
As a designer I want to manage the layouts
Oops, something went wrong.

0 comments on commit 290d6c4

Please sign in to comment.