smithycms 0.0.1
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.
- data/MIT-LICENSE +20 -0
- data/README.md +142 -0
- data/Rakefile +27 -0
- data/app/assets/images/smithy/logo.png +0 -0
- data/app/assets/images/smithy/logo2.png +0 -0
- data/app/assets/javascripts/smithy/application.js +13 -0
- data/app/assets/javascripts/smithy/assets.js.coffee +35 -0
- data/app/assets/javascripts/smithy/guides.js +23 -0
- data/app/assets/javascripts/smithy/jquery-ui.min.js +5 -0
- data/app/assets/javascripts/smithy/nested_forms.js +55 -0
- data/app/assets/javascripts/smithy/page_contents.js +4 -0
- data/app/assets/javascripts/smithy/pages.js +41 -0
- data/app/assets/javascripts/smithy/settings.js +0 -0
- data/app/assets/javascripts/smithy/templates.js +25 -0
- data/app/assets/stylesheets/smithy/application.css.scss +29 -0
- data/app/assets/stylesheets/smithy/assets.css.scss +3 -0
- data/app/assets/stylesheets/smithy/bootstrap_and_overrides.css.scss +12 -0
- data/app/assets/stylesheets/smithy/content_blocks.css.scss +2 -0
- data/app/assets/stylesheets/smithy/forms.css.scss +3 -0
- data/app/assets/stylesheets/smithy/guides.css.scss +5 -0
- data/app/assets/stylesheets/smithy/layout.css.scss +113 -0
- data/app/assets/stylesheets/smithy/pages.css.scss +35 -0
- data/app/assets/stylesheets/smithy/templates.css.scss +14 -0
- data/app/controllers/smithy/assets_controller.rb +50 -0
- data/app/controllers/smithy/base_controller.rb +14 -0
- data/app/controllers/smithy/caches_controller.rb +13 -0
- data/app/controllers/smithy/content_blocks_controller.rb +50 -0
- data/app/controllers/smithy/content_pieces_controller.rb +97 -0
- data/app/controllers/smithy/contents_controller.rb +41 -0
- data/app/controllers/smithy/guides_controller.rb +9 -0
- data/app/controllers/smithy/images_controller.rb +41 -0
- data/app/controllers/smithy/page_contents_controller.rb +90 -0
- data/app/controllers/smithy/pages_controller.rb +110 -0
- data/app/controllers/smithy/settings_controller.rb +46 -0
- data/app/controllers/smithy/sitemap_controller.rb +13 -0
- data/app/controllers/smithy/templates_controller.rb +79 -0
- data/app/helpers/smithy/application_helper.rb +36 -0
- data/app/helpers/smithy/assets_helper.rb +9 -0
- data/app/helpers/smithy/pages_helper.rb +12 -0
- data/app/helpers/smithy/settings_helper.rb +4 -0
- data/app/helpers/smithy/templates_helper.rb +4 -0
- data/app/helpers/smithy/upload_helper.rb +110 -0
- data/app/models/smithy/asset.rb +64 -0
- data/app/models/smithy/content.rb +35 -0
- data/app/models/smithy/content_block.rb +41 -0
- data/app/models/smithy/content_block_template.rb +26 -0
- data/app/models/smithy/image.rb +41 -0
- data/app/models/smithy/page.rb +94 -0
- data/app/models/smithy/page_content.rb +62 -0
- data/app/models/smithy/page_list.rb +61 -0
- data/app/models/smithy/page_proxy.rb +63 -0
- data/app/models/smithy/setting.rb +6 -0
- data/app/models/smithy/site.rb +30 -0
- data/app/models/smithy/template.rb +53 -0
- data/app/models/smithy/template_container.rb +16 -0
- data/app/views/layouts/smithy/application.html.erb +27 -0
- data/app/views/layouts/smithy/guides.html.erb +16 -0
- data/app/views/layouts/smithy/modal.html.erb +10 -0
- data/app/views/layouts/smithy/shared/_flash.html.erb +6 -0
- data/app/views/layouts/smithy/shared/_footer.html.erb +3 -0
- data/app/views/layouts/smithy/shared/_head.html.erb +8 -0
- data/app/views/layouts/smithy/shared/_nav.html.erb +37 -0
- data/app/views/layouts/smithy/shared/_tail.html.erb +4 -0
- data/app/views/layouts/smithy/wide.html.erb +24 -0
- data/app/views/smithy/assets/_asset.html.erb +10 -0
- data/app/views/smithy/assets/_form.html.erb +13 -0
- data/app/views/smithy/assets/_upload_form.html.erb +13 -0
- data/app/views/smithy/assets/create.js.erb +5 -0
- data/app/views/smithy/assets/edit.html.erb +5 -0
- data/app/views/smithy/assets/index.html.erb +13 -0
- data/app/views/smithy/assets/new.html.erb +13 -0
- data/app/views/smithy/caches/show.html.erb +8 -0
- data/app/views/smithy/content_blocks/_content_block.html.erb +1 -0
- data/app/views/smithy/content_blocks/_secondary_nav.html.erb +12 -0
- data/app/views/smithy/content_blocks/_template_fields.html.erb +19 -0
- data/app/views/smithy/content_blocks/edit.html.erb +31 -0
- data/app/views/smithy/content_blocks/index.html.erb +17 -0
- data/app/views/smithy/content_blocks/new.html.erb +12 -0
- data/app/views/smithy/content_pieces/edit.html.erb +13 -0
- data/app/views/smithy/content_pieces/index.html.erb +21 -0
- data/app/views/smithy/content_pieces/new.html.erb +1 -0
- data/app/views/smithy/contents/_form.html.erb +6 -0
- data/app/views/smithy/contents/_form_fields.html.erb +12 -0
- data/app/views/smithy/contents/edit.html.erb +3 -0
- data/app/views/smithy/contents/new.html.erb +3 -0
- data/app/views/smithy/guides/markdown.html.erb +150 -0
- data/app/views/smithy/images/_form.html.erb +6 -0
- data/app/views/smithy/images/_form_fields.html.erb +28 -0
- data/app/views/smithy/images/edit.html.erb +3 -0
- data/app/views/smithy/images/new.html.erb +3 -0
- data/app/views/smithy/page_contents/edit.html.erb +18 -0
- data/app/views/smithy/page_contents/new.html.erb +28 -0
- data/app/views/smithy/page_lists/_form_fields.html.erb +6 -0
- data/app/views/smithy/pages/_container.html.erb +24 -0
- data/app/views/smithy/pages/_form.html.erb +57 -0
- data/app/views/smithy/pages/_page.html.erb +6 -0
- data/app/views/smithy/pages/_page_nav.html.erb +6 -0
- data/app/views/smithy/pages/_page_related.html.erb +21 -0
- data/app/views/smithy/pages/_parent.html.erb +10 -0
- data/app/views/smithy/pages/_root.html.erb +5 -0
- data/app/views/smithy/pages/edit.html.erb +7 -0
- data/app/views/smithy/pages/index.html.erb +17 -0
- data/app/views/smithy/pages/new.html.erb +7 -0
- data/app/views/smithy/settings/_form.html.erb +7 -0
- data/app/views/smithy/settings/_setting.html.erb +6 -0
- data/app/views/smithy/settings/edit.html.erb +3 -0
- data/app/views/smithy/settings/index.html.erb +9 -0
- data/app/views/smithy/settings/new.html.erb +3 -0
- data/app/views/smithy/settings/show.html.erb +10 -0
- data/app/views/smithy/sitemap/show.xml.erb +10 -0
- data/app/views/smithy/templates/_secondary_nav.html.erb +21 -0
- data/app/views/smithy/templates/_template.html.erb +1 -0
- data/app/views/smithy/templates/edit.html.erb +36 -0
- data/app/views/smithy/templates/index.html.erb +17 -0
- data/app/views/smithy/templates/new.html.erb +13 -0
- data/config/initializers/aws.rb +5 -0
- data/config/initializers/dragonfly.rb +48 -0
- data/config/initializers/formtastic.rb +77 -0
- data/config/initializers/kaminari_config.rb +10 -0
- data/config/initializers/liquid.rb +2 -0
- data/config/routes.rb +38 -0
- data/db/migrate/20120911193140_create_smithy_templates.rb +11 -0
- data/db/migrate/20120911203618_create_smithy_settings.rb +10 -0
- data/db/migrate/20121018182146_create_smithy_pages.rb +27 -0
- data/db/migrate/20121019145543_create_smithy_template_containers.rb +11 -0
- data/db/migrate/20121019160426_create_smithy_page_contents.rb +21 -0
- data/db/migrate/20121024213357_create_smithy_content_blocks.rb +10 -0
- data/db/migrate/20121025011733_create_smithy_content_block_templates.rb +12 -0
- data/db/migrate/20121029175812_create_smithy_contents.rb +9 -0
- data/db/migrate/20121105222537_create_smithy_assets.rb +16 -0
- data/db/migrate/20121115215053_create_smithy_images.rb +15 -0
- data/db/migrate/20121127205022_add_external_link_to_smithy_pages.rb +5 -0
- data/db/migrate/20130115190505_add_markdown_content_to_smithy_contents.rb +5 -0
- data/db/migrate/20130123170918_set_defaults_for_show_in_navigation_and_cache_length.rb +6 -0
- data/db/migrate/20130311203806_create_smithy_page_lists.rb +15 -0
- data/db/migrate/20130312161116_remove_description_from_content_block.rb +5 -0
- data/db/migrate/20130326191051_add_html_attributes_to_images.rb +5 -0
- data/db/migrate/20131003210228_add_publishable_to_smithy_page_contents.rb +11 -0
- data/db/migrate/20131220160755_add_content_to_images.rb +5 -0
- data/db/migrate/20131223145710_add_position_to_smithy_template_containers.rb +5 -0
- data/lib/smithy/content_blocks/model.rb +16 -0
- data/lib/smithy/content_blocks/registry.rb +30 -0
- data/lib/smithy/content_blocks.rb +2 -0
- data/lib/smithy/content_pieces/base.rb +10 -0
- data/lib/smithy/content_pieces/registry.rb +39 -0
- data/lib/smithy/dependencies.rb +19 -0
- data/lib/smithy/dragonfly/asset_helper.rb +67 -0
- data/lib/smithy/dragonfly/remote_data_store.rb +33 -0
- data/lib/smithy/dragonfly.rb +30 -0
- data/lib/smithy/engine.rb +48 -0
- data/lib/smithy/formatter.rb +46 -0
- data/lib/smithy/liquid/database.rb +12 -0
- data/lib/smithy/liquid/drops/base.rb +16 -0
- data/lib/smithy/liquid/drops/page.rb +78 -0
- data/lib/smithy/liquid/filters/asset_tag.rb +33 -0
- data/lib/smithy/liquid/filters/resize.rb +12 -0
- data/lib/smithy/liquid/rendering.rb +50 -0
- data/lib/smithy/liquid/tags/asset.rb +54 -0
- data/lib/smithy/liquid/tags/csrf.rb +30 -0
- data/lib/smithy/liquid/tags/html.rb +61 -0
- data/lib/smithy/liquid/tags/nav.rb +76 -0
- data/lib/smithy/liquid.rb +8 -0
- data/lib/smithy/logger.rb +12 -0
- data/lib/smithy/version.rb +3 -0
- data/lib/smithy.rb +21 -0
- data/lib/smithycms.rb +1 -0
- data/lib/tasks/smithy_tasks.rake +4 -0
- data/lib/templates/erb/scaffold/_form.html.erb +11 -0
- metadata +871 -0
@@ -0,0 +1,10 @@
|
|
1
|
+
<% content_for :title, "Settings" %>
|
2
|
+
|
3
|
+
<dl>
|
4
|
+
<dt>Name</dt>
|
5
|
+
<dd><%= @setting.name %></dd>
|
6
|
+
<dt>Value</dt>
|
7
|
+
<dd><%= @setting.value %></dd>
|
8
|
+
</dl>
|
9
|
+
|
10
|
+
<%= link_to "<i class=\"icon-arrow-left\"></i> Return to Settings".html_safe, settings_path, :class => "btn" %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
|
3
|
+
<%- @pages.find_each do |page| %>
|
4
|
+
<url>
|
5
|
+
<loc>
|
6
|
+
<%= "#{request.protocol}#{request.host_with_port}#{page.path}" %></loc>
|
7
|
+
<lastmod><%= page.updated_at.to_date %></lastmod>
|
8
|
+
</url>
|
9
|
+
<% end -%>
|
10
|
+
</urlset>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<% content_for :secondary_nav do %>
|
2
|
+
<ul class="nav nav-list">
|
3
|
+
<li class="nav-header">Templates</li>
|
4
|
+
<%= render @templates %>
|
5
|
+
<li class="nav-header">Includes</li>
|
6
|
+
<%= render @includes %>
|
7
|
+
<li class="nav-header">Javascripts</li>
|
8
|
+
<%= render @javascripts %>
|
9
|
+
<li class="nav-header">Stylesheets</li>
|
10
|
+
<%= render @stylesheets %>
|
11
|
+
</ul>
|
12
|
+
|
13
|
+
<div class="btn-group actions pull-right">
|
14
|
+
<%= link_to "<i class=\"icon-plus\"></i> Add Template <span class=\"caret\"></span>".html_safe, new_template_path, :class => 'dropdown-toggle btn btn-inverse', 'data-toggle' => 'dropdown', 'data-target' => '#', :role => 'button' %>
|
15
|
+
<ul class="dropdown-menu" role="menu">
|
16
|
+
<% Smithy::Template.types.each do |tt| %>
|
17
|
+
<li><%= link_to tt.capitalize, new_template_path(:template => { :template_type => tt }) %></li>
|
18
|
+
<% end %>
|
19
|
+
</ul>
|
20
|
+
</div>
|
21
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<li<%= raw ' class="active"' if action_name == "edit" && @template == template %>><%= link_to template.name, [:edit, template] %></li>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<% content_for :browser_title, "#{@template.name} | Templates" %>
|
2
|
+
<% content_for :title, "Templates" %>
|
3
|
+
|
4
|
+
<%= render :partial => "secondary_nav" %>
|
5
|
+
|
6
|
+
<%= semantic_form_for @template do |f| %>
|
7
|
+
<%= f.inputs do %>
|
8
|
+
<%= f.input :content, :label => "Template Content", :input_html => { :id => "template_content-#{@template.id}" } %>
|
9
|
+
<div id="template_content_editor-<%= @template.id %>" class="template_content_editor"></div>
|
10
|
+
<% end %>
|
11
|
+
<%= f.actions do %>
|
12
|
+
<%= f.text_field :name %>
|
13
|
+
<%= f.action :submit, :label => "Save this #{@template.template_type.capitalize}" %>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<% content_for :javascript do %>
|
18
|
+
<%= javascript_tag do %>
|
19
|
+
ace_edit(<%= @template.id %>, '<%= @template_editor_type %>');
|
20
|
+
<% end %>
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
<% content_for :related do %>
|
24
|
+
<% unless @template.pages.empty? %>
|
25
|
+
<div class="well well-small">
|
26
|
+
Pages using this template:
|
27
|
+
<ul>
|
28
|
+
<% @template.pages.each do |page| %>
|
29
|
+
<li><%= link_to page.title, edit_page_path(page.id) %></li>
|
30
|
+
<% end %>
|
31
|
+
</ul>
|
32
|
+
</div>
|
33
|
+
<% end %>
|
34
|
+
|
35
|
+
<p><%= link_to "Delete #{@template.template_type.capitalize}", @template, :method => :delete, :confirm => "Are you sure you want to delete this #{@template.template_type}?", :class => 'btn btn-danger' %></p>
|
36
|
+
<% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% content_for :title, "Templates" %>
|
2
|
+
|
3
|
+
<div class="hero-unit">
|
4
|
+
<%- if @templates.empty? -%>
|
5
|
+
<p>Be the first to add a Template to your site. Templates are the basic building blocks for your pages. A page's look and feel is defined in the templates that you create.</p>
|
6
|
+
<% else %>
|
7
|
+
<p>Add a template or select one from your left to edit.</p>
|
8
|
+
<% end %>
|
9
|
+
<p>
|
10
|
+
<%= link_to "Add Template", new_template_path, :class => 'btn btn-primary btn-large' %>
|
11
|
+
</p>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<%= render :partial => "secondary_nav" %>
|
15
|
+
|
16
|
+
<% content_for :related do %>
|
17
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<% content_for :title, "Templates" %>
|
2
|
+
|
3
|
+
<%= semantic_form_for @template, :html => { :class => 'form-horizontal' } do |f| %>
|
4
|
+
<%= f.inputs "New #{@template.template_type.capitalize}" do %>
|
5
|
+
<%= f.input :name %>
|
6
|
+
<%= f.input :template_type, :as => :hidden %>
|
7
|
+
<% end %>
|
8
|
+
<%= f.actions :submit %>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<%= render :partial => "secondary_nav" %>
|
12
|
+
|
13
|
+
<% content_for :related, nil %>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'dragonfly'
|
3
|
+
begin
|
4
|
+
require 'rack/cache'
|
5
|
+
rescue LoadError => e
|
6
|
+
puts "Couldn't find rack-cache - make sure you have it in your Gemfile:"
|
7
|
+
puts " gem 'rack-cache', :require => 'rack/cache'"
|
8
|
+
puts " or configure dragonfly manually instead of using 'dragonfly/rails/images'"
|
9
|
+
raise e
|
10
|
+
end
|
11
|
+
|
12
|
+
## initialize Dragonfly ##
|
13
|
+
app = Dragonfly[:files]
|
14
|
+
app.configure_with(:rails)
|
15
|
+
app.configure_with(:imagemagick)
|
16
|
+
|
17
|
+
# set the cache lifetime
|
18
|
+
app.cache_duration = 3600*24*365*3 # 3 years in seconds
|
19
|
+
|
20
|
+
### Extend active record ###
|
21
|
+
app.define_macro(ActiveRecord::Base, :image_accessor)
|
22
|
+
app.define_macro(ActiveRecord::Base, :file_accessor)
|
23
|
+
|
24
|
+
## configure it ##
|
25
|
+
Dragonfly[:files].configure do |c|
|
26
|
+
# Convert absolute location needs to be specified
|
27
|
+
# to avoid issues with Phusion Passenger not using $PATH
|
28
|
+
c.convert_command = `which convert`.strip.presence || "/usr/local/bin/convert"
|
29
|
+
c.identify_command = `which identify`.strip.presence || "/usr/local/bin/identify"
|
30
|
+
|
31
|
+
c.allow_fetch_url = true
|
32
|
+
c.allow_fetch_file = true
|
33
|
+
|
34
|
+
c.url_format = '/uploads/assets/:job/:basename.:format'
|
35
|
+
end
|
36
|
+
|
37
|
+
app.datastore = Smithy::Asset.dragonfly_datastore
|
38
|
+
|
39
|
+
# ### Insert the middleware ###
|
40
|
+
rack_cache_already_inserted = Rails.application.config.action_controller.perform_caching && Rails.application.config.action_dispatch.rack_cache
|
41
|
+
|
42
|
+
Rails.application.middleware.insert 0, Rack::Cache, {
|
43
|
+
:verbose => true,
|
44
|
+
:metastore => URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/meta"), # URI encoded in case of spaces
|
45
|
+
:entitystore => URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/body")
|
46
|
+
} unless rack_cache_already_inserted
|
47
|
+
|
48
|
+
Rails.application.middleware.insert_after Rack::Cache, Dragonfly::Middleware, :files
|
@@ -0,0 +1,77 @@
|
|
1
|
+
Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
|
2
|
+
|
3
|
+
# encoding: utf-8
|
4
|
+
|
5
|
+
# Set the default text field size when input is a string. Default is nil.
|
6
|
+
# Formtastic::FormBuilder.default_text_field_size = 50
|
7
|
+
|
8
|
+
# Set the default text area height when input is a text. Default is 20.
|
9
|
+
# Formtastic::FormBuilder.default_text_area_height = 5
|
10
|
+
|
11
|
+
# Set the default text area width when input is a text. Default is nil.
|
12
|
+
# Formtastic::FormBuilder.default_text_area_width = 50
|
13
|
+
|
14
|
+
# Should all fields be considered "required" by default?
|
15
|
+
# Defaults to true.
|
16
|
+
# Formtastic::FormBuilder.all_fields_required_by_default = true
|
17
|
+
|
18
|
+
# Should select fields have a blank option/prompt by default?
|
19
|
+
# Defaults to true.
|
20
|
+
# Formtastic::FormBuilder.include_blank_for_select_by_default = true
|
21
|
+
|
22
|
+
# Set the string that will be appended to the labels/fieldsets which are required
|
23
|
+
# It accepts string or procs and the default is a localized version of
|
24
|
+
# '<abbr title="required">*</abbr>'. In other words, if you configure formtastic.required
|
25
|
+
# in your locale, it will replace the abbr title properly. But if you don't want to use
|
26
|
+
# abbr tag, you can simply give a string as below
|
27
|
+
# Formtastic::FormBuilder.required_string = "(required)"
|
28
|
+
|
29
|
+
# Set the string that will be appended to the labels/fieldsets which are optional
|
30
|
+
# Defaults to an empty string ("") and also accepts procs (see required_string above)
|
31
|
+
# Formtastic::FormBuilder.optional_string = "(optional)"
|
32
|
+
|
33
|
+
# Set the way inline errors will be displayed.
|
34
|
+
# Defaults to :sentence, valid options are :sentence, :list, :first and :none
|
35
|
+
# Formtastic::FormBuilder.inline_errors = :sentence
|
36
|
+
# Formtastic uses the following classes as default for hints, inline_errors and error list
|
37
|
+
|
38
|
+
# If you override the class here, please ensure to override it in your stylesheets as well
|
39
|
+
# Formtastic::FormBuilder.default_hint_class = "inline-hints"
|
40
|
+
# Formtastic::FormBuilder.default_inline_error_class = "inline-errors"
|
41
|
+
# Formtastic::FormBuilder.default_error_list_class = "errors"
|
42
|
+
|
43
|
+
# Set the method to call on label text to transform or format it for human-friendly
|
44
|
+
# reading when formtastic is used without object. Defaults to :humanize.
|
45
|
+
# Formtastic::FormBuilder.label_str_method = :humanize
|
46
|
+
|
47
|
+
# Set the array of methods to try calling on parent objects in :select and :radio inputs
|
48
|
+
# for the text inside each @<option>@ tag or alongside each radio @<input>@. The first method
|
49
|
+
# that is found on the object will be used.
|
50
|
+
# Defaults to ["to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
|
51
|
+
# Formtastic::FormBuilder.collection_label_methods = [
|
52
|
+
# "to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
|
53
|
+
|
54
|
+
# Specifies if labels/hints for input fields automatically be looked up using I18n.
|
55
|
+
# Default value: true. Overridden for specific fields by setting value to true,
|
56
|
+
# i.e. :label => true, or :hint => true (or opposite depending on initialized value)
|
57
|
+
# Formtastic::FormBuilder.i18n_lookups_by_default = false
|
58
|
+
|
59
|
+
# Specifies if I18n lookups of the default I18n Localizer should be cached to improve performance.
|
60
|
+
# Defaults to true.
|
61
|
+
# Formtastic::FormBuilder.i18n_cache_lookups = false
|
62
|
+
|
63
|
+
# Specifies the class to use for localization lookups. You can create your own
|
64
|
+
# class and use it instead by subclassing Formtastic::Localizer (which is the default).
|
65
|
+
# Formtastic::FormBuilder.i18n_localizer = MyOwnLocalizer
|
66
|
+
|
67
|
+
# You can add custom inputs or override parts of Formtastic by subclassing Formtastic::FormBuilder and
|
68
|
+
# specifying that class here. Defaults to Formtastic::FormBuilder.
|
69
|
+
|
70
|
+
# You can opt-in to Formtastic's use of the HTML5 `required` attribute on `<input>`, `<select>`
|
71
|
+
# and `<textarea>` tags by setting this to false (defaults to true).
|
72
|
+
# Formtastic::FormBuilder.use_required_attribute = true
|
73
|
+
|
74
|
+
# You can opt-in to new HTML5 browser validations (for things like email and url inputs) by setting
|
75
|
+
# this to false. Doing so will add a `novalidate` attribute to the `<form>` tag.
|
76
|
+
# See http://diveintohtml5.org/forms.html#validation for more info.
|
77
|
+
# Formtastic::FormBuilder.perform_browser_validations = true
|
data/config/routes.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
Smithy::Engine.routes.draw do
|
2
|
+
root :to => 'pages#show'
|
3
|
+
scope "/smithy" do
|
4
|
+
match '/' => redirect('/smithy/pages')
|
5
|
+
match '/login' => redirect('/'), :as => :login
|
6
|
+
match '/logout' => redirect('/'), :as => :logout, :via => :delete
|
7
|
+
# CMS admin
|
8
|
+
resources :assets
|
9
|
+
resources :content_blocks
|
10
|
+
resources :guides, :only => :show
|
11
|
+
resources :pages do
|
12
|
+
collection do
|
13
|
+
get :order
|
14
|
+
end
|
15
|
+
resources :contents, :controller => "PageContents", :except => [ :index ] do
|
16
|
+
member do
|
17
|
+
get :preview
|
18
|
+
end
|
19
|
+
collection do
|
20
|
+
get :order
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
resources :templates
|
25
|
+
resources :settings
|
26
|
+
resource :cache
|
27
|
+
|
28
|
+
# Content Pieces
|
29
|
+
# scope "/content_pieces" do
|
30
|
+
# # ie. /smithy/content_pieces/locations/1/edit
|
31
|
+
# end
|
32
|
+
end
|
33
|
+
# Sitemap
|
34
|
+
resource :sitemap, :controller => "Sitemap", :only => [ :show ]
|
35
|
+
match '/templates/javascripts/*javascript' => 'templates#javascript', :defaults => { :format => 'js' }
|
36
|
+
match '/templates/stylesheets/*stylesheet' => 'templates#stylesheet', :format => 'css'
|
37
|
+
match '*path' => 'pages#show'
|
38
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class CreateSmithyPages < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :smithy_pages do |t|
|
4
|
+
t.string :title, :null => false
|
5
|
+
t.string :browser_title
|
6
|
+
t.string :keywords
|
7
|
+
t.string :description
|
8
|
+
t.integer :cache_length
|
9
|
+
t.datetime :published_at
|
10
|
+
t.boolean :show_in_navigation
|
11
|
+
t.string :permalink, :null => false
|
12
|
+
t.string :path, :null => false
|
13
|
+
t.belongs_to :template
|
14
|
+
t.belongs_to :parent
|
15
|
+
t.integer :lft
|
16
|
+
t.integer :rgt
|
17
|
+
t.integer :depth
|
18
|
+
|
19
|
+
t.timestamps
|
20
|
+
end
|
21
|
+
add_index :smithy_pages, :template_id
|
22
|
+
add_index :smithy_pages, :parent_id
|
23
|
+
add_index :smithy_pages, :lft
|
24
|
+
add_index :smithy_pages, :rgt
|
25
|
+
add_index :smithy_pages, :path, :unique => true
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class CreateSmithyPageContents < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :smithy_page_contents do |t|
|
4
|
+
t.belongs_to :page
|
5
|
+
t.string :label
|
6
|
+
t.string :container
|
7
|
+
t.string :content_block_type
|
8
|
+
t.integer :content_block_id
|
9
|
+
t.belongs_to :content_block_template
|
10
|
+
t.integer :position
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
add_index :smithy_page_contents, :page_id
|
15
|
+
add_index :smithy_page_contents, :container
|
16
|
+
add_index :smithy_page_contents, :content_block_type
|
17
|
+
add_index :smithy_page_contents, :content_block_id
|
18
|
+
add_index :smithy_page_contents, :content_block_template_id
|
19
|
+
add_index :smithy_page_contents, :position
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateSmithyContentBlockTemplates < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :smithy_content_block_templates do |t|
|
4
|
+
t.belongs_to :content_block
|
5
|
+
t.string :name
|
6
|
+
t.text :content
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
add_index :smithy_content_block_templates, :content_block_id
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateSmithyAssets < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :smithy_assets do |t|
|
4
|
+
t.string :name
|
5
|
+
t.string :uploaded_file_url
|
6
|
+
t.string :content_type
|
7
|
+
t.string :file_uid
|
8
|
+
t.string :file_name
|
9
|
+
t.integer :file_size
|
10
|
+
t.integer :file_width
|
11
|
+
t.integer :file_height
|
12
|
+
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateSmithyImages < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :smithy_images do |t|
|
4
|
+
t.belongs_to :asset
|
5
|
+
t.string :alternate_text
|
6
|
+
t.integer :width
|
7
|
+
t.integer :height
|
8
|
+
t.string :image_scaling
|
9
|
+
t.string :link_url
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
add_index :smithy_images, :asset_id
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateSmithyPageLists < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :smithy_page_lists do |t|
|
4
|
+
t.belongs_to :parent
|
5
|
+
t.belongs_to :page_template
|
6
|
+
t.boolean :include_children
|
7
|
+
t.integer :count
|
8
|
+
t.string :sort
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
add_index :smithy_page_lists, :parent_id
|
13
|
+
add_index :smithy_page_lists, :page_template_id
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class AddPublishableToSmithyPageContents < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
add_column :smithy_page_contents, :publishable, :boolean, :default => false
|
4
|
+
Smithy::PageContent.reset_column_information
|
5
|
+
Smithy::PageContent.all.each{|pc| pc.update_attribute(:publishable, true) }
|
6
|
+
end
|
7
|
+
|
8
|
+
def down
|
9
|
+
remove_column :smithy_page_contents, :publishable
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Smithy
|
2
|
+
module ContentBlocks
|
3
|
+
module Model
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
included do
|
6
|
+
has_many :page_contents, :as => :content_block
|
7
|
+
Smithy::ContentBlocks::Registry.register self
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
def content_block_description
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
require_dependency Smithy::Engine.root.join('app', 'models', 'smithy', 'content_block').to_s
|
3
|
+
|
4
|
+
module Smithy
|
5
|
+
module ContentBlocks
|
6
|
+
class Registry
|
7
|
+
@@content_blocks = []
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def clear
|
11
|
+
@@content_blocks = []
|
12
|
+
end
|
13
|
+
|
14
|
+
def content_blocks
|
15
|
+
@@content_blocks
|
16
|
+
end
|
17
|
+
|
18
|
+
def register(content_block)
|
19
|
+
return unless ActiveRecord::Base.connection.table_exists?(Smithy::ContentBlock.table_name)
|
20
|
+
return unless ActiveRecord::Base.connection.table_exists?(content_block.table_name)
|
21
|
+
content_block_name = content_block.to_s.demodulize
|
22
|
+
@@content_blocks << content_block_name unless @@content_blocks.include?(content_block_name)
|
23
|
+
cb = Smithy::ContentBlock.find_or_initialize_by_name(content_block_name)
|
24
|
+
cb.save
|
25
|
+
@@content_blocks
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module Smithy
|
4
|
+
module ContentPieces
|
5
|
+
class Registry
|
6
|
+
@@content_pieces = []
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def clear
|
10
|
+
@@content_pieces = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def content_pieces
|
14
|
+
@@content_pieces
|
15
|
+
end
|
16
|
+
|
17
|
+
def register(content_piece)
|
18
|
+
content_piece = content_piece.to_sym
|
19
|
+
return if @@content_pieces.include?(content_piece)
|
20
|
+
@@content_pieces << content_piece
|
21
|
+
Smithy::Engine.routes.prepend do
|
22
|
+
scope '/smithy/content_pieces' do
|
23
|
+
resources content_piece
|
24
|
+
end
|
25
|
+
end
|
26
|
+
@@content_pieces
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Smithy::Engine.routes.draw do
|
34
|
+
namespace :smithy do
|
35
|
+
scope "/content_pieces" do
|
36
|
+
resources :store_locations
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|