spud_cms 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. data/README.markdown +71 -0
  2. data/app/assets/images/spud/admin/menus_thumb.png +0 -0
  3. data/app/assets/images/spud/admin/pages_thumb.png +0 -0
  4. data/app/assets/images/spud/admin/posts_thumb.png +0 -0
  5. data/app/assets/images/spud/admin/templates_thumb.png +0 -0
  6. data/app/assets/javascripts/pages.js +2 -0
  7. data/app/assets/javascripts/spud/admin/cms/application.js +24 -0
  8. data/app/assets/javascripts/spud/admin/templates.js +2 -0
  9. data/app/assets/javascripts/spud/cms/sitemaps.js +2 -0
  10. data/app/assets/stylesheets/pages.css +4 -0
  11. data/app/assets/stylesheets/spud/admin/cms/application.css +4 -0
  12. data/app/assets/stylesheets/spud/cms/sitemaps.css +4 -0
  13. data/app/controllers/pages_controller.rb +29 -0
  14. data/app/controllers/spud/admin/menu_items_controller.rb +118 -0
  15. data/app/controllers/spud/admin/menus_controller.rb +50 -0
  16. data/app/controllers/spud/admin/pages_controller.rb +149 -0
  17. data/app/controllers/spud/admin/templates_controller.rb +55 -0
  18. data/app/controllers/spud/cms/sitemaps_controller.rb +6 -0
  19. data/app/helpers/pages_helper.rb +2 -0
  20. data/app/helpers/spud/admin/contacts_helper.rb +2 -0
  21. data/app/helpers/spud/admin/media_helper.rb +2 -0
  22. data/app/helpers/spud/admin/menu_items_helper.rb +2 -0
  23. data/app/helpers/spud/admin/menus_helper.rb +2 -0
  24. data/app/helpers/spud/admin/pages_helper.rb +2 -0
  25. data/app/helpers/spud/admin/posts_helper.rb +2 -0
  26. data/app/helpers/spud/admin/templates_helper.rb +2 -0
  27. data/app/helpers/spud/admin/users_helper.rb +2 -0
  28. data/app/helpers/spud/cms/application_helper.rb +102 -0
  29. data/app/helpers/spud/cms/sitemaps_helper.rb +2 -0
  30. data/app/helpers/spud/user_sessions_helper.rb +2 -0
  31. data/app/models/spud_custom_field.rb +7 -0
  32. data/app/models/spud_menu.rb +6 -0
  33. data/app/models/spud_menu_item.rb +37 -0
  34. data/app/models/spud_page.rb +59 -0
  35. data/app/models/spud_page_partial.rb +3 -0
  36. data/app/models/spud_template.rb +7 -0
  37. data/app/views/layouts/spud/admin/cms/detail.html.erb +6 -0
  38. data/app/views/pages/show.html.erb +25 -0
  39. data/app/views/spud/admin/contacts/index.html.erb +0 -0
  40. data/app/views/spud/admin/menu_items/_form.html.erb +34 -0
  41. data/app/views/spud/admin/menu_items/_menu_item_row.html.erb +18 -0
  42. data/app/views/spud/admin/menu_items/edit.html.erb +13 -0
  43. data/app/views/spud/admin/menu_items/index.html.erb +12 -0
  44. data/app/views/spud/admin/menu_items/new.html.erb +13 -0
  45. data/app/views/spud/admin/menus/_form.html.erb +9 -0
  46. data/app/views/spud/admin/menus/edit.html.erb +13 -0
  47. data/app/views/spud/admin/menus/index.html.erb +24 -0
  48. data/app/views/spud/admin/menus/new.html.erb +13 -0
  49. data/app/views/spud/admin/pages/_form.html.erb +71 -0
  50. data/app/views/spud/admin/pages/_page_partials_form.html.erb +18 -0
  51. data/app/views/spud/admin/pages/_page_row.html.erb +18 -0
  52. data/app/views/spud/admin/pages/edit.html.erb +13 -0
  53. data/app/views/spud/admin/pages/index.html.erb +12 -0
  54. data/app/views/spud/admin/pages/new.html.erb +12 -0
  55. data/app/views/spud/admin/pages/show.html.erb +25 -0
  56. data/app/views/spud/admin/templates/_form.html.erb +31 -0
  57. data/app/views/spud/admin/templates/edit.html.erb +11 -0
  58. data/app/views/spud/admin/templates/index.html.erb +17 -0
  59. data/app/views/spud/admin/templates/new.html.erb +13 -0
  60. data/app/views/spud/cms/sitemaps/show.xml.builder +16 -0
  61. data/config/application.rb +48 -0
  62. data/config/boot.rb +6 -0
  63. data/config/routes.rb +22 -0
  64. data/lib/spud_cms.rb +7 -0
  65. data/lib/spud_cms/configuration.rb +15 -0
  66. data/lib/spud_cms/engine.rb +29 -0
  67. metadata +133 -0
@@ -0,0 +1,12 @@
1
+ <%=content_for :data_controls do%>
2
+ <%=link_to "New Menu Item",new_spud_admin_menu_menu_item_path(),:class => "button",:title => "New Menu Item"%>
3
+ <%end%>
4
+ <%=content_for :detail do%>
5
+ <div class="page_list">
6
+ <%@menu_items.each do |menu_item|%>
7
+ <%=render :partial => "menu_item_row",:locals => {:menu_item => menu_item}%>
8
+ <%end%>
9
+ <%=will_paginate @menu_items%>
10
+ </div>
11
+
12
+ <%end%>
@@ -0,0 +1,13 @@
1
+
2
+
3
+
4
+ <%=form_for @menu_item,:url => spud_admin_menu_menu_items_path,:html=>{:class=>"right_aligned_form"} do |f|%>
5
+ <%=render :partial => "form",:locals => {:f => f}%>
6
+ <fieldset class="submit"><%=f.submit%> or <%=link_to "cancel",request.referer%></fieldset>
7
+ <%end%>
8
+
9
+ <script type="text/javascript">
10
+ $('input[type=submit],.close_dialog').button();
11
+
12
+ </script>
13
+
@@ -0,0 +1,9 @@
1
+ <fieldset>
2
+ <ol>
3
+ <li><%=f.label :name, :required=>true%>
4
+ <%=f.text_field :name,:title => "",:size=>40%>
5
+ <%=error_message_on "menu","name"%>
6
+ </li>
7
+ </ol>
8
+ </fieldset>
9
+
@@ -0,0 +1,13 @@
1
+
2
+
3
+
4
+ <%=form_for @menu,:url => spud_admin_menu_path(:id => @menu.id),:html=>{:class=>"right_aligned_form"} do |f|%>
5
+ <%=render :partial => "form",:locals => {:f => f}%>
6
+ <fieldset class="submit"><%=f.submit%> or <%=link_to "cancel",request.referer%></fieldset>
7
+ <%end%>
8
+
9
+ <script type="text/javascript">
10
+ $('input[type=submit],.close_dialog').button();
11
+
12
+ </script>
13
+
@@ -0,0 +1,24 @@
1
+ <%=content_for :data_controls do%>
2
+ <%=link_to "New Menu",new_spud_admin_menu_path(),:class => "button",:title => "New Menu"%>
3
+ <%end%>
4
+ <%=content_for :detail do%>
5
+ <div class="page_list">
6
+ <%@menus.each do |menu|%>
7
+ <div class="page_row">
8
+
9
+ <span class="row_meta"><%=link_to menu.name,spud_admin_menu_menu_items_path(:menu_id => menu.id)%></span>
10
+
11
+ <span class="edit_controls">
12
+ <%=link_to "Edit",edit_spud_admin_menu_path(:id => menu.id),:class => 'button'%>
13
+ <%=link_to "Remove",spud_admin_menu_path(:id => menu.id),:method => :delete,:class => 'button',:confirm => "Are you sure you want to remove this menu and all items associated with it?"%>
14
+ </span>
15
+ <br style="clear:both;"/>
16
+ </div>
17
+ <%end%>
18
+ <%=will_paginate @menus%>
19
+
20
+ </div>
21
+
22
+
23
+
24
+ <%end%>
@@ -0,0 +1,13 @@
1
+
2
+
3
+
4
+ <%=form_for @menu,:url => spud_admin_menus_path,:html=>{:class=>"right_aligned_form"} do |f|%>
5
+ <%=render :partial => "form",:locals => {:f => f}%>
6
+ <fieldset class="submit"><%=f.submit%> or <%=link_to "cancel",request.referer%></fieldset>
7
+ <%end%>
8
+
9
+ <script type="text/javascript">
10
+ $('input[type=submit],.close_dialog').button();
11
+
12
+ </script>
13
+
@@ -0,0 +1,71 @@
1
+ <fieldset>
2
+ <legend>Page Title</legend>
3
+ <p>
4
+ <%=error_message_on "page","name"%>
5
+ <%=f.label :name, :required=>true, :style => "display:none;" %>
6
+ <%=f.text_field :name, :class => "full-width" %>
7
+ </p>
8
+ </fieldset>
9
+ <div id="page_partials_form" class="formtabs">
10
+ <ul class="formtab_buttons">
11
+ </ul>
12
+ <%=f.fields_for :spud_page_partials do |b|%>
13
+ <div class="formtab">
14
+ <%=b.hidden_field :name,:class => "tab_name"%>
15
+ <%=b.text_area :content,:class => "wysiwym"%>
16
+ </div>
17
+ <%end%>
18
+ </div>
19
+ <br />
20
+ <fieldset>
21
+ <legend>Advanced Settings (optional)</legend>
22
+ <ol>
23
+ <%if Spud::Cms.templates_enabled%>
24
+ <li>
25
+ <%=error_message_on "page","template_id"%>
26
+ <%=f.label :template_id, "Template"%>
27
+ <%=f.select :template_id, options_for_select(SpudTemplate.all.collect{|tp| [tp.name,tp.id]},@page.template_id), {:include_blank => 'Default'},{:title => "", 'data-source' => page_parts_spud_admin_pages_path(:page => @page.id) }%>
28
+ </li>
29
+ <%end%>
30
+ <li>
31
+ <%=error_message_on "page","spud_page_id"%>
32
+ <%=f.label :spud_page_id, "Parent Page"%>
33
+ <%=f.select :spud_page_id,options_for_select(SpudPage.options_tree_for_page(@page),@page.spud_page_id),{:include_blank => 'None'},{:title => ""}%>
34
+ </li>
35
+ <li>
36
+ <%=error_message_on "page","url_name"%>
37
+ <%=f.label :url_name, "Perma Link",:disabled => true%>
38
+ <%=root_url%><%=f.text_field :url_name,:title => "",:size=>20%><%=f.check_box :use_custom_url_name,:onchange => "$('#spud_page_url_name').attr('disabled',!this.checked);"%>
39
+ </li>
40
+ </ol>
41
+ </fieldset>
42
+ <fieldset>
43
+ <legend>Meta Information (optional)</legend>
44
+ <p>These fields are used to notify search engines about important keywords and the appropriate description to display in a search result.</p>
45
+ <ol>
46
+ <li>
47
+ <%=f.label :meta_keywords,"Keywords"%>
48
+ <%=f.text_field :meta_keywords,:title => "" %>
49
+ <%=error_message_on "page","meta_keywords"%>
50
+ </li>
51
+ <li>
52
+ <%=f.label :meta_description,"Description"%>
53
+ <%=f.text_area :meta_description,:rows => 4,:cols=>75%>
54
+ <%=error_message_on "page","meta_description"%>
55
+ </li>
56
+ <li>
57
+ <%=f.label :visibility%>
58
+ <%=f.select :visibility, [["Public",0],["Private",1]]%>
59
+ </li>
60
+ <li>
61
+ <%=f.label :published%>
62
+ <%=f.check_box :published%>
63
+ </li>
64
+ <li>
65
+ <%=error_message_on "page","notes"%>
66
+ <%=f.label :notes,"Notes"%>
67
+ <%=f.text_area :notes,:rows => 4,:cols=>75 %>
68
+ </li>
69
+ </ol>
70
+ </fieldset>
71
+
@@ -0,0 +1,18 @@
1
+ <div id="page_partials_form" class="formtabs">
2
+ <ul class="formtab_buttons">
3
+ </ul>
4
+ <% last_index = 0 %>
5
+ <% spud_page_partials.each_with_index do |spud_page_partial, index| %>
6
+ <div class="formtab">
7
+ <input type="hidden" class="tab_name" name="spud_page[spud_page_partials_attributes][<%= index %>][name]" value="<%= spud_page_partial.name %>" />
8
+ <textarea class="wysiwym" name="spud_page[spud_page_partials_attributes][<%= index %>][content]">
9
+ <%= spud_page_partial.content %>
10
+ </textarea>
11
+ </div>
12
+ <% last_index = index + 1 %>
13
+ <% end %>
14
+ <% remove_page_partials.each_with_index do |spud_page_partial, index| %>
15
+ <input type="hidden" name="spud_page[spud_page_partials_attributes][<%= last_index + index %>][id]" value="<%= spud_page_partial.id %>" />
16
+ <input type="hidden" name="spud_page[spud_page_partials_attributes][<%= last_index + index %>][_destroy]", value="1" />
17
+ <% end %>
18
+ </div>
@@ -0,0 +1,18 @@
1
+ <div class="page_row">
2
+
3
+ <span class="row_meta"><%=prefix if defined? prefix%><%=link_to page.name,spud_admin_page_path(:id => page.id)%></span>
4
+
5
+ <span class="edit_controls"><%=link_to "Edit",edit_spud_admin_page_path(:id => page.id), :title => "Edit Page",:class => 'button'%>&nbsp;&nbsp;<%=link_to "Remove",spud_admin_page_path(:id => page.id),:method => :delete,:class => 'button',:confirm => "Are you sure you want to remove this page?"%></span>
6
+ <br style="clear:both;"/>
7
+ </div>
8
+ <%if !page.spud_pages.all.blank?%>
9
+
10
+ <div class="left_guide">
11
+
12
+ <%page.spud_pages.each do |spud_page|%>
13
+ <%=render :partial => 'page_row',:locals => {:page => spud_page}%>
14
+ <%end%>
15
+
16
+ </div>
17
+
18
+ <%end%>
@@ -0,0 +1,13 @@
1
+ <%=form_for @page,:url => spud_admin_page_path(:id => @page.id),:html=>{:class=>"right_aligned_form"} do |f|%>
2
+ <%=render :partial => "form",:locals => {:f => f}%>
3
+ <fieldset class="submit">
4
+ <%=f.submit :class => "wymupdate"%> or <%=link_to "cancel",request.referer%>
5
+ </fieldset>
6
+ <%end%>
7
+ <br />
8
+
9
+ <script type="text/javascript">
10
+ $('input[type=submit],.close_dialog').button();
11
+
12
+ </script>
13
+
@@ -0,0 +1,12 @@
1
+ <%=content_for :data_controls do%>
2
+ <%=link_to "New Page",new_spud_admin_page_path(),:class => "button",:title => "New Page"%>
3
+ <%end%>
4
+ <%=content_for :detail do%>
5
+ <div class="page_list">
6
+ <%@pages.each do |page|%>
7
+ <%=render :partial => "page_row",:locals => {:page => page}%>
8
+ <%end%>
9
+ <%=will_paginate @pages%>
10
+ </div>
11
+
12
+ <%end%>
@@ -0,0 +1,12 @@
1
+ <%=form_for @page,:url => spud_admin_pages_path(),:html=>{:class=>"right_aligned_form"} do |f|%>
2
+ <%=render :partial => "form",:locals => {:f => f}%>
3
+ <fieldset class="submit">
4
+ <%=f.submit :class => "wymupdate"%> or <%=link_to "cancel",request.referer%>
5
+ </fieldset>
6
+ <%end%>
7
+ <br />
8
+
9
+ <script type="text/javascript">
10
+ $('input[type=submit],.close_dialog').button();
11
+ </script>
12
+
@@ -0,0 +1,25 @@
1
+
2
+ <%=content_for :head do%>
3
+ <meta name="description" content="<%=@page.meta_description%>" />
4
+
5
+ <meta name="keywords" content="<%=@page.meta_keywords%>" />
6
+ <%end%>
7
+
8
+ <%if !@inline.blank?%>
9
+ <%=render :inline => @inline%>
10
+ <%else%>
11
+ <h2><%=@page.name%></h2>
12
+ <%end%>
13
+ <%@page.spud_page_partials.each do |page_partial|%>
14
+
15
+ <%if(page_partial.name.downcase == 'body' && Spud::Cms.yield_body_as_content_block == false)%>
16
+ <%=page_partial.content.html_safe%>
17
+ <%else%>
18
+ <%=content_for page_partial.name.parameterize.underscore.to_sym do%>
19
+ <%=page_partial.content.html_safe%>
20
+ <%end%>
21
+ <%end%>
22
+ <%end%>
23
+ <span class="spud_admin_edit_controls">
24
+ <%=link_to 'Edit',edit_spud_admin_page_path(:id => @page.id)%>&nbsp;|&nbsp;<%=link_to 'Back',spud_admin_pages_path()%>
25
+ </span>
@@ -0,0 +1,31 @@
1
+ <fieldset>
2
+ <ol>
3
+ <li><%=f.label :name, :required=>true%>
4
+ <%=f.text_field :name,:title => "",:size=>40%>
5
+ <%=error_message_on "template","name"%>
6
+ </li>
7
+
8
+
9
+ <li><%=f.label :base_layout, "Base Layout"%>
10
+ <%=f.text_field :base_layout%>
11
+ </li>
12
+ <li><%=f.label :content, "Content"%>
13
+ <%=f.text_area :content, :rows => 20,:cols => 110%>
14
+ </li>
15
+ <li><%=f.label :page_parts, "Page Parts"%>
16
+ <%=f.text_field :page_parts%>
17
+ </li>
18
+
19
+
20
+ </ol>
21
+ </fieldset>
22
+
23
+
24
+ <script type="text/javascript">
25
+ var editor = CodeMirror.fromTextArea(document.getElementById("spud_template_content"), {
26
+ lineNumbers: true,
27
+ mode: "application/x-ejs",
28
+ matchBrackets: true,
29
+ theme:'night'
30
+ });
31
+ </script>
@@ -0,0 +1,11 @@
1
+
2
+ <%=form_for @template,:url => spud_admin_template_path(:id => @template.id),:html=>{:class=>"right_aligned_form"} do |f|%>
3
+ <%=render :partial => "form",:locals => {:f => f}%>
4
+ <fieldset class="submit"><%=f.submit%> or <%=link_to "cancel",request.referer%></fieldset>
5
+ <%end%>
6
+
7
+ <script type="text/javascript">
8
+ $('input[type=submit],.close_dialog').button();
9
+
10
+ </script>
11
+
@@ -0,0 +1,17 @@
1
+ <%=content_for :data_controls do%>
2
+ <%=link_to "New Template",new_spud_admin_template_path(),:class => "button",:title => "New Template"%>
3
+ <%end%>
4
+ <%=content_for :detail do%>
5
+ <div class="page_list">
6
+ <%@templates.each do |template|%>
7
+ <div class="page_row">
8
+ <span class="row_meta"><%=link_to template.name,edit_spud_admin_template_path(:id => template.id)%></span>
9
+
10
+ <span class="edit_controls"><%=link_to "Edit",edit_spud_admin_template_path(:id => template.id), :title => "Edit Template",:class => 'button'%>&nbsp;&nbsp;<%=link_to "Remove",spud_admin_template_path(:id => template.id),:method => :delete,:class => 'button',:confirm => "Are you sure you want to remove this template?"%></span>
11
+ <br style="clear:both;"/>
12
+ </div>
13
+ <%end%>
14
+ <%=will_paginate @templates%>
15
+ </div>
16
+
17
+ <%end%>
@@ -0,0 +1,13 @@
1
+
2
+
3
+
4
+ <%=form_for @template,:url => spud_admin_templates_path(),:html=>{:class=>"right_aligned_form"} do |f|%>
5
+ <%=render :partial => "form",:locals => {:f => f}%>
6
+ <fieldset class="submit"><%=f.submit%> or <%=link_to "cancel",request.referer%></fieldset>
7
+ <%end%>
8
+
9
+ <script type="text/javascript">
10
+ $('input[type=submit],.close_dialog').button();
11
+
12
+ </script>
13
+
@@ -0,0 +1,16 @@
1
+
2
+ xml.instruct! :xml, :version => '1.0', :encoding => 'UTF-8'
3
+
4
+ # create the urlset
5
+ xml.urlset :xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9' do
6
+ @pages.each do |page|
7
+ xml.url do
8
+ if page.url_name == Spud::Cms.root_page_name
9
+ xml.loc root_url()
10
+ else
11
+ xml.loc page_url(:id => page.url_name)
12
+ end
13
+ xml.lastmod page.updated_at.strftime('%Y-%m-%d')
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,48 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ if defined?(Bundler)
6
+ # If you precompile assets before deploying to production, use this line
7
+ Bundler.require *Rails.groups(:assets => %w(development test))
8
+ # If you want your assets lazily compiled in production, use this line
9
+ # Bundler.require(:default, :assets, Rails.env)
10
+ end
11
+
12
+ module SpudTest
13
+ class Application < Rails::Application
14
+ # Settings in config/environments/* take precedence over those specified here.
15
+ # Application configuration should go into files in config/initializers
16
+ # -- all .rb files in that directory are automatically loaded.
17
+
18
+ # Custom directories with classes and modules you want to be autoloadable.
19
+ # config.autoload_paths += %W(#{config.root}/extras)
20
+
21
+ # Only load the plugins named here, in the order given (default is alphabetical).
22
+ # :all can be used as a placeholder for all plugins not explicitly named.
23
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
24
+
25
+ # Activate observers that should always be running.
26
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
27
+
28
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
29
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
30
+ # config.time_zone = 'Central Time (US & Canada)'
31
+
32
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
33
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
34
+ # config.i18n.default_locale = :de
35
+
36
+ # Configure the default encoding used in templates for Ruby 1.9.
37
+ config.encoding = "utf-8"
38
+
39
+ # Configure sensitive parameters which will be filtered from the log file.
40
+ config.filter_parameters += [:password]
41
+
42
+ # Enable the asset pipeline
43
+ config.assets.enabled = true
44
+
45
+ # Version of your assets, change this if you want to expire all your assets
46
+ config.assets.version = '1.0'
47
+ end
48
+ end
data/config/boot.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5
+
6
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
data/config/routes.rb ADDED
@@ -0,0 +1,22 @@
1
+ Rails.application.routes.draw do
2
+ namespace :spud do
3
+ namespace :admin do
4
+ resources :pages do
5
+ get :page_parts, :on => :collection
6
+ end
7
+ resources :templates
8
+
9
+ resources :menus do
10
+ resources :menu_items
11
+ end
12
+ resources :contacts
13
+ end
14
+ namespace :cms do
15
+ resource :sitemap,:only => "show"
16
+ end
17
+ end
18
+ root :to => 'pages#show'
19
+ match ":id", :controller => "pages",:action => "show", :as => "page"
20
+
21
+ end
22
+