smithycms 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/smithy/application.js +1 -0
  3. data/app/assets/javascripts/smithy/assets.js.coffee +7 -5
  4. data/app/assets/javascripts/smithy/copy_link.js.coffee.erb +19 -0
  5. data/app/assets/javascripts/smithy/{templates.js → editor.js} +8 -6
  6. data/app/assets/javascripts/smithy/nested_forms.js +2 -2
  7. data/app/assets/stylesheets/smithy/bootstrap_and_overrides.css.scss +1 -0
  8. data/app/assets/stylesheets/smithy/templates.css.scss +3 -0
  9. data/app/controllers/smithy/assets_controller.rb +4 -2
  10. data/app/controllers/smithy/{content_pieces_controller.rb → content_resources_controller.rb} +9 -4
  11. data/app/helpers/smithy/application_helper.rb +2 -2
  12. data/app/helpers/smithy/templates_helper.rb +12 -0
  13. data/app/helpers/smithy/upload_helper.rb +2 -0
  14. data/app/models/smithy/asset.rb +4 -1
  15. data/app/models/smithy/page.rb +1 -1
  16. data/app/models/smithy/page_proxy.rb +1 -1
  17. data/app/models/smithy/site.rb +1 -0
  18. data/app/views/layouts/smithy/shared/_flash.html.erb +1 -1
  19. data/app/views/layouts/smithy/shared/_footer.html.erb +1 -1
  20. data/app/views/layouts/smithy/shared/_nav.html.erb +4 -1
  21. data/app/views/smithy/assets/_asset.html.erb +8 -5
  22. data/app/views/smithy/assets/_form.html.erb +5 -4
  23. data/app/views/smithy/assets/create.js.erb +2 -1
  24. data/app/views/smithy/assets/index.html.erb +2 -2
  25. data/app/views/smithy/content_blocks/edit.html.erb +1 -1
  26. data/app/views/smithy/{content_pieces → content_resources}/edit.html.erb +6 -1
  27. data/app/views/smithy/{content_pieces → content_resources}/index.html.erb +4 -0
  28. data/app/views/smithy/content_resources/new.html.erb +13 -0
  29. data/app/views/smithy/pages/_form.html.erb +1 -2
  30. data/config/initializers/dragonfly.rb +3 -5
  31. data/db/migrate/20141113220013_change_page_keywords_to_text.rb +5 -0
  32. data/lib/smithy/{content_pieces → content_resources}/base.rb +2 -2
  33. data/lib/smithy/content_resources/registry.rb +31 -0
  34. data/lib/smithy/content_resources.rb +2 -0
  35. data/lib/smithy/dependencies.rb +1 -1
  36. data/lib/smithy/dragonfly/asset_helper.rb +2 -2
  37. data/lib/smithy/engine.rb +4 -0
  38. data/lib/smithy/liquid/filters/smithy_helpers.rb +42 -0
  39. data/lib/smithy/liquid/rendering.rb +6 -4
  40. data/lib/smithy/liquid/tags/html.rb +8 -2
  41. data/lib/smithy/liquid/tags/include_file.rb +1 -1
  42. data/lib/smithy/liquid/tags/nav.rb +3 -2
  43. data/lib/smithy/liquid.rb +1 -0
  44. data/lib/smithy/version.rb +1 -1
  45. data/lib/smithy.rb +1 -2
  46. data/vendor/assets/images/ZeroClipboard.swf +0 -0
  47. data/vendor/assets/javascripts/zeroclipboard-2.2.0/ZeroClipboard.js +2581 -0
  48. data/vendor/assets/javascripts/zeroclipboard-2.2.0/ZeroClipboard.min.js +10 -0
  49. data/vendor/assets/javascripts/zeroclipboard-2.2.0/ZeroClipboard.min.map +1 -0
  50. metadata +75 -19
  51. data/app/views/smithy/content_pieces/new.html.erb +0 -8
  52. data/lib/smithy/content_pieces/registry.rb +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19b597920083bd8dc8cf02cc0aa10841cdfacb3f
4
- data.tar.gz: dfae46dd7b135f4c2107a2c2c6a368acb4f2808b
3
+ metadata.gz: 39561e91c08df383f68cdd2ab7ff4696f4ece727
4
+ data.tar.gz: ab0a854d38401f183bec49e954983aac63967480
5
5
  SHA512:
6
- metadata.gz: ce549e7f07cf38306f0bb78ae1e8bca7e1bc3e67dd0ba3a973072aecf19db17160adccb7bd3a9ee86faaa131841b40115d6acb944030aadfc477088993eacfbe
7
- data.tar.gz: 85589c29c6a35a45c92338b760667ebc9c8edacca6ef789eeeed516a5e1868b519d083a64bfcb393d87fb210cf5d1d010329c037150c23160000be6559e1a45e
6
+ metadata.gz: 31cd8bf890e4e25f63b3f57d03ad46c7fa5ee7d9da10959b9ee16cda5d2296a71982540c015b8188b4dbc909e814e1051e570f1b7b4394b132d807a67cad36ef
7
+ data.tar.gz: badd9f440124104d63627981895dc5828621ca9804ee47ef04b4bdbe2579e68d78a78d8a4bfc1c635661a72e08a2f39ae55fd0edfcb6bc2fac5d60566e25cc4d
@@ -10,4 +10,5 @@
10
10
  //= require ace-1.1.3/mode-javascript.js
11
11
  //= require ace-1.1.3/mode-liquid.js
12
12
  //= require ace-1.1.3/mode-markdown.js
13
+ //= require zeroclipboard-2.2.0/ZeroClipboard.min.js
13
14
  //= require_tree .
@@ -4,14 +4,15 @@
4
4
  jQuery ->
5
5
  $('#fileupload').fileupload
6
6
  add: (e, data) ->
7
- types = /(\.|\/)(gif|jpe?g|png|pdf)$/i
7
+ types = /(\.|\/)(gif|jpe?g|png|pdf|svgz?)$/i
8
8
  file = data.files[0]
9
9
  if types.test(file.type) || types.test(file.name)
10
10
  data.context = $(tmpl("template-upload", file))
11
- $('#fileupload').append(data.context)
11
+ $(this).find('#Content-Type').val(file.type)
12
+ $(this).append(data.context)
12
13
  data.submit()
13
14
  else
14
- alert("#{file.name} is not a gif, jpeg, png or pdf file")
15
+ alert("#{file.name} is not a gif, jpeg, png, svg or pdf file")
15
16
 
16
17
  progress: (e, data) ->
17
18
  if data.context
@@ -25,8 +26,9 @@ jQuery ->
25
26
  to = $('#fileupload').data('post') + ".js"
26
27
  content = {}
27
28
  content[$('#fileupload').data('as')] = domain + path
28
- $.post(to, content)
29
-
29
+ setTimeout ->
30
+ $.post(to, content)
31
+ , 1500
30
32
  data.context.remove() if data.context # remove progress bar
31
33
 
32
34
  fail: (e, data) ->
@@ -0,0 +1,19 @@
1
+ //= depend_on_asset "ZeroClipboard.swf"
2
+ jQuery ->
3
+
4
+ ZeroClipboard.config({
5
+ swfPath: '<%= image_path "ZeroClipboard.swf" %>'
6
+ });
7
+
8
+ ($ 'body').on "click", ".copy-to-clipboard", (e) ->
9
+ e.preventDefault()
10
+ $('.copy-to-clipboard').each ->
11
+ $link = ($ this)
12
+ clip = new ZeroClipboard( this )
13
+ clip.on "copy", (e) ->
14
+ clip.setText($link.data('clipboard-text'))
15
+ saved_text = $link.text()
16
+ $link.text 'Copied!'
17
+ setTimeout ->
18
+ $link.text(saved_text)
19
+ , 2000
@@ -1,17 +1,19 @@
1
1
  var ace_edit = function(id, template_type, name) {
2
2
  if (!name) { name = 'template_content' }
3
- var editor_name = name + '_editor-' + id
4
- $('#'+editor_name).show();
5
- var editor = ace.edit(editor_name);
6
- var textarea = $('textarea[id="' + name + '-'+id+'"]').hide();
3
+ var textarea_id = name + '-' + id
4
+ var editor_id = name + '_editor-' + id
5
+ $('#'+editor_id).show();
6
+ var editor = ace.edit(editor_id);
7
+ var $textarea = $('#'+textarea_id);
8
+ $textarea.hide()
7
9
  var session = editor.getSession();
8
10
  session.setMode("ace/mode/" + template_type);
9
- session.setValue(textarea.val());
11
+ session.setValue($textarea.val());
10
12
  session.setTabSize(2);
11
13
  session.setUseSoftTabs(true);
12
14
  session.setUseWrapMode(true);
13
15
  session.on('change', function(){
14
- textarea.val(editor.getSession().getValue());
16
+ $textarea.val(editor.getSession().getValue());
15
17
  });
16
18
  editor.commands.addCommand({
17
19
  name: 'save',
@@ -47,9 +47,9 @@ $(function() {
47
47
 
48
48
  // replace the remover checkboxes with a link
49
49
  $('form .destroy > label').hide();
50
- $('form .destroy .controls label').each(function(i) {
50
+ $('form .destroy').each(function(i) {
51
51
  link = $('<a href="javascript:void(0);" class="btn btn-danger btn-mini">Delete</a>').addClass("remove_nested_fields");
52
- $(this).empty().append($(link));
52
+ $(this).append($(link));
53
53
  });
54
54
 
55
55
  });
@@ -1,3 +1,4 @@
1
1
  @import "bootstrap-sprockets";
2
2
  @import "bootstrap";
3
+ @import "font-awesome-sprockets";
3
4
  @import "font-awesome";
@@ -11,4 +11,7 @@ textarea[name="content[content]"],
11
11
  min-height:40em;
12
12
  width:97%;
13
13
  position:relative;
14
+ &.short {
15
+ min-height:10em;
16
+ }
14
17
  }
@@ -17,9 +17,11 @@ module Smithy
17
17
  def create
18
18
  @asset = Asset.new(filtered_params)
19
19
  @asset.save
20
- flash.notice = "Your asset was created" if @asset.persisted?
21
20
  respond_with @asset do |format|
22
- format.html { redirect_to assets_path }
21
+ format.html {
22
+ flash.notice = "Your asset was created" if @asset.persisted?
23
+ redirect_to assets_path
24
+ }
23
25
  end
24
26
  end
25
27
 
@@ -1,11 +1,12 @@
1
1
  require_dependency "smithy/base_controller"
2
2
 
3
- class Smithy::ContentPiecesController < Smithy::BaseController
3
+ class Smithy::ContentResourcesController < Smithy::BaseController
4
4
  before_filter :set_controller_path
5
5
  respond_to :html, :json
6
6
 
7
7
  helper_method :accessible_attributes
8
8
  helper_method :klass_name
9
+ helper_method :klass_table_name
9
10
  helper_method :readable_attributes
10
11
 
11
12
  def index
@@ -28,7 +29,7 @@ class Smithy::ContentPiecesController < Smithy::BaseController
28
29
  @record.save
29
30
  flash.notice = "Your #{klass_name} was created" if @record.persisted?
30
31
  respond_with @record do |format|
31
- format.html { @record.persisted? ? redirect_to([:edit, @record]) : render(:action => 'new') }
32
+ format.html { @record.persisted? ? redirect_to(:action => :index) : render(:action => 'new') }
32
33
  end
33
34
  end
34
35
 
@@ -60,13 +61,17 @@ class Smithy::ContentPiecesController < Smithy::BaseController
60
61
 
61
62
  def klass
62
63
  # override to provide an object for each class
63
- raise "You must inherit from this Smithy::ContentPiecesController and provide a private #klass method"
64
+ raise "You must inherit from this Smithy::ContentResourcesController and provide a private #klass method"
64
65
  end
65
66
 
66
67
  def klass_name
67
68
  @klass_name ||= klass.name.sub(/^Smithy::/, '').titleize
68
69
  end
69
70
 
71
+ def klass_table_name
72
+ klass.name.sub(/^Smithy::/, '').underscore.pluralize
73
+ end
74
+
70
75
  def new_record
71
76
  klass.new(filtered_params)
72
77
  end
@@ -92,6 +97,6 @@ class Smithy::ContentPiecesController < Smithy::BaseController
92
97
  end
93
98
 
94
99
  def accessible_attributes
95
- klass.accessible_attributes.select(&:present?).map(&:to_sym)
100
+ permitted_params.send("#{klass.name.sub(/^Smithy::/, '').underscore}_attributes".to_sym)
96
101
  end
97
102
  end
@@ -1,6 +1,6 @@
1
1
  module Smithy
2
2
  module ApplicationHelper
3
- def link_to_add_fields(name, association, form_builder)
3
+ def smithy_link_to_add_fields(name, association, form_builder)
4
4
  html = content_tag(:div, :id => "#{association}_fields_blueprint", :style => "display:none;") do
5
5
  form_builder.semantic_fields_for(association, model_object(form_builder, association), :child_index => "new_#{association}") do |builder|
6
6
  form_builder.template.concat(raw render("#{form_builder.object.class.to_s.tableize}/#{association.to_s.singularize}_fields", :f => builder))
@@ -10,7 +10,7 @@ module Smithy
10
10
  form_builder.template.link_to(name, "javascript:void(0)", :class => "add_nested_fields", "data-association" => association)
11
11
  end
12
12
 
13
- def link_to_remove_fields(name, form_builder)
13
+ def smithy_link_to_remove_fields(name, form_builder)
14
14
  form_builder.hidden_field(:_destroy) + @template.link_to(name, "javascript:void(0)", :class => "remove_nested_fields")
15
15
  end
16
16
 
@@ -1,4 +1,16 @@
1
1
  module Smithy
2
2
  module TemplatesHelper
3
+ include Smithy::Liquid::Rendering
4
+
5
+ def render_smithy_nav(options="")
6
+ context = ::Liquid::Context.new({}, smithy_default_assigns, smithy_default_registers, false)
7
+ ::Liquid::Template.parse("{% nav #{options} %}").render(liquid_context)
8
+ end
9
+
10
+ def render_smithy_partial(partial_name)
11
+ partial_template = Smithy::Template.partials.find_by_name(partial_name)
12
+ return if partial_template.blank?
13
+ partial_template.liquid_template.render(liquid_context)
14
+ end
3
15
  end
4
16
  end
@@ -65,6 +65,7 @@ module Smithy
65
65
  :policy => policy,
66
66
  :signature => signature,
67
67
  "AWSAccessKeyId" => @options[:aws_access_key_id],
68
+ "Content-Type" => nil
68
69
  }
69
70
  end
70
71
 
@@ -86,6 +87,7 @@ module Smithy
86
87
  conditions: [
87
88
  ["starts-with", "$utf8", ""],
88
89
  ["starts-with", "$key", ""],
90
+ ["starts-with", "$Content-Type", ""],
89
91
  ["content-length-range", 0, @options[:max_file_size]],
90
92
  {bucket: @options[:bucket]},
91
93
  {acl: @options[:acl]}
@@ -29,6 +29,8 @@ module Smithy
29
29
  case ext
30
30
  when 'jpg', 'jpeg', 'gif', 'png'
31
31
  :image
32
+ when 'svg', 'svgz'
33
+ :direct_image
32
34
  when 'pdf'
33
35
  :pdf
34
36
  when 'doc', 'docx'
@@ -70,7 +72,8 @@ module Smithy
70
72
  # assuming that jquery-upload and dragonfly are using the same data storage...
71
73
  def set_file_uid_manually
72
74
  if self.uploaded_file_url? # this means it was uploaded via jquery-upload
73
- self.file_uid = URI.parse(self.uploaded_file_url).path.sub(/^\//, '')
75
+ uri = URI.parse(URI.encode(self.uploaded_file_url))
76
+ self.file_uid = self.uploaded_file_url.sub("#{uri.scheme}://#{uri.host}/", '')
74
77
  self.uploaded_file_url = nil
75
78
  end
76
79
  end
@@ -58,7 +58,7 @@ module Smithy
58
58
  end
59
59
 
60
60
  def site
61
- @site ||= Smithy::Site.new
61
+ @site ||= Smithy::Site.instance
62
62
  end
63
63
 
64
64
  def to_liquid
@@ -45,7 +45,7 @@ module Smithy
45
45
  end
46
46
 
47
47
  def site
48
- @site ||= Smithy::Site.new
48
+ @site ||= Smithy::Site.instance
49
49
  end
50
50
 
51
51
  def to_liquid
@@ -1,5 +1,6 @@
1
1
  module Smithy
2
2
  class Site
3
+ include Singleton
3
4
  cattr_accessor :title
4
5
 
5
6
  class << self
@@ -1,5 +1,5 @@
1
1
  <% flash.each do |name, msg| %>
2
- <div class="alert alert-<%= name == :notice ? "success" : "error" %>">
2
+ <div class="alert alert-<%= name == :notice ? "success" : "warning" %>">
3
3
  <button type="button" class="close" data-dismiss="alert">&times;</button>
4
4
  <%= msg %>
5
5
  </div>
@@ -1,3 +1,3 @@
1
1
  <footer id="footer">
2
- Carefully crafted by <a href="http://www.tag.ca">Tag Solutions</a>
2
+ Carefully crafted by <a href="http://www.tagstudios.io">Tag Digital Studios</a>
3
3
  </footer>
@@ -15,6 +15,9 @@
15
15
  <ul class="nav navbar-nav">
16
16
  <li><%= link_to "<i class=\"fa fa-sitemap\"></i> Manage Content".html_safe, pages_path %></li>
17
17
  <li><%= link_to "<i class=\"fa fa-file\"></i> Images &amp; Files".html_safe, assets_path %></li>
18
+ <% Smithy::ContentResources::Registry.content_resources.each do |controller_name, title| %>
19
+ <li><%= link_to title, controller_name.to_sym %></li>
20
+ <% end %>
18
21
  </ul>
19
22
  <ul class="nav navbar-nav navbar-right">
20
23
  <li><%= link_to "<i class=\"fa fa-arrow-right\"></i> View Site".html_safe, root_path %></li>
@@ -23,7 +26,7 @@
23
26
  <ul class="dropdown-menu">
24
27
  <li><%= link_to "<i class=\"fa fa-book\"></i> Templates".html_safe, templates_path %></li>
25
28
  <li><%= link_to "<i class=\"fa fa-list-alt\"></i> Content Blocks".html_safe, content_blocks_path %></li>
26
- <li><%= link_to users_path do %><i class="fa fa-user"></i> Users<% end %></li>
29
+ <% if self.respond_to?(:users_path) %><li><%= link_to users_path do %><i class="fa fa-user"></i> Users<% end %></li><% end %>
27
30
  <li><%= link_to "<i class=\"fa fa-cog\"></i> Settings".html_safe, settings_path %></li>
28
31
  <li><%= link_to "<i class=\"fa fa-refresh\"></i> Site Cache".html_safe, cache_path %></li>
29
32
  </ul>
@@ -1,16 +1,19 @@
1
- <li>
1
+ <div class="col-xs-6 col-md-3">
2
2
  <div class="thumbnail clearfix">
3
- <%= link_to asset.file.remote_url do %>
3
+ <%= link_to [:edit, asset] do %>
4
4
  <% if asset.file_type == :image %>
5
- <%= image_tag asset.file.thumb("170x114#").url, width: 170, height: 114, alt: '' %>
5
+ <%= image_tag asset.file.thumb("340x226#").url, width: 170, height: 114, alt: '' %>
6
+ <% elsif asset.file_type == :direct_image %>
7
+ <%= image_tag asset.file.remote_url, width: 170, alt: '' %>
6
8
  <% else %>
7
9
  <div style="width:170px;height:78px;padding-top:36px;text-align:center;"><%= image_tag file_type_icon(asset), alt: '' %></div>
8
10
  <% end %>
9
11
  <% end %>
10
12
  <p class="name"><strong><%= asset.name %></strong></p>
11
13
  <div class="pull-right">
12
- <%= link_to "Edit", [:edit, asset], class: "btn btn-xs" %>
14
+ <%= link_to "Copy URL", image_url(asset.file.url), class: "btn btn-primary btn-xs copy-to-clipboard", data: { 'clipboard-text' => image_url(asset.file.url) } %>
15
+ <%= link_to "Edit", [:edit, asset], class: "btn btn-primary btn-xs" %>
13
16
  <%= link_to "Delete", asset, class: "btn btn-danger btn-xs", method: :delete, data: { confirm: "Are you sure?" } %>
14
17
  </div>
15
18
  </div>
16
- </li>
19
+ </div>
@@ -5,12 +5,13 @@
5
5
  <%= f.input :retained_file, :as => :hidden %>
6
6
  <% if @asset.file %>
7
7
  <div>
8
- <%= link_to asset.file.remote_url do %>
9
- <% if asset.file_type == :image %>
8
+ <div><%= link_to "Copy URL", image_url(@asset.file.url), class: "btn btn-primary btn-xs copy-to-clipboard", data: { 'clipboard-text' => image_url(@asset.file.url) } %></div>
9
+ <% if @asset.file_type == :image %>
10
10
  <img src="<%= @asset.file.thumb("300x300").url %>" alt="">
11
+ <% elsif @asset.file_type == :direct_image %>
12
+ <%= image_tag @asset.file.remote_url, width: 300, alt: '' %>
11
13
  <% else %>
12
- <%= image_tag file_type_icon(asset), alt: '' %>
13
- <% end %>
14
+ <%= image_tag file_type_icon(@asset), alt: '' %>
14
15
  <% end %>
15
16
  </div>
16
17
  <% end %>
@@ -1,5 +1,6 @@
1
1
  <% if @asset.new_record? %>
2
2
  alert("Failed to upload painting: <%= j @asset.errors.full_messages.join(', ').html_safe %>");
3
3
  <% else %>
4
- $("#asset-thumbnails").append("<%= j render(@asset) %>");
4
+ <%# re-find the asset to load up the proper paths %>
5
+ $("#asset-thumbnails").prepend("<%= j render(Smithy::Asset.find(@asset.id)) %>");
5
6
  <% end %>
@@ -8,6 +8,6 @@
8
8
 
9
9
  <%= paginate @assets %>
10
10
 
11
- <ul class="thumbnails" id="asset-thumbnails">
11
+ <div class="thumbnails row" id="asset-thumbnails">
12
12
  <%= render @assets %>
13
- </ul>
13
+ </div>
@@ -16,7 +16,7 @@
16
16
  </dl>
17
17
  <% end %>
18
18
 
19
- <div><%= link_to_add_fields "Add a Template", :templates, f %></div>
19
+ <div><%= smithy_link_to_add_fields "Add a Template", :templates, f %></div>
20
20
  <%= f.semantic_fields_for(:templates) do |builder| %>
21
21
  <%= render partial: "template_fields", locals: { f: builder } %>
22
22
  <% end %>
@@ -4,7 +4,12 @@
4
4
  <%= f.inputs do %>
5
5
  <%= f.inputs *accessible_attributes %>
6
6
  <% end %>
7
- <%= f.actions :submit %>
7
+ <%= f.actions do %>
8
+ <%= link_to([ klass_table_name ], class: 'btn btn-default') do %>
9
+ <span class="fa fa-arrow-left"></span> <%= "Back to #{klass_name.pluralize}" %>
10
+ <% end %>
11
+ <%= f.action :submit %>
12
+ <% end %>
8
13
  <% end %>
9
14
 
10
15
 
@@ -1,4 +1,7 @@
1
1
  <% content_for :title, "#{klass_name}" %>
2
+
3
+ <%= content_tag :p, link_to("New #{klass_name}", [:new, klass_table_name.singularize ], class: 'btn btn-primary') %></p>
4
+
2
5
  <table border="0" cellpadding="4" class="table table-hover table-bordered">
3
6
  <thead>
4
7
  <tr>
@@ -11,6 +14,7 @@
11
14
  <tr>
12
15
  <td>
13
16
  <%= link_to "Edit", [:edit, record], :class => "btn btn-default btn-xs" %>
17
+ <%= link_to("Delete", record, method: :delete, data: { confirm: "Are you sure you want to delete this #{klass_name}?" }, class: 'btn btn-danger btn-xs') if record.persisted? %>
14
18
  </td>
15
19
  <%- readable_attributes.map(&:to_sym).each do |attribute| %>
16
20
  <td><%= record[attribute] %></td>
@@ -0,0 +1,13 @@
1
+ <% content_for :title, "New #{klass_name}" %>
2
+
3
+ <%= semantic_form_for @record do |f| %>
4
+ <%= f.inputs do %>
5
+ <%= f.inputs *accessible_attributes %>
6
+ <% end %>
7
+ <%= f.actions do %>
8
+ <%= link_to([ klass_table_name ], class: 'btn btn-default') do %>
9
+ <span class="fa fa-arrow-left"></span> <%= "Back to #{klass_name.pluralize}" %>
10
+ <% end %>
11
+ <%= f.action :submit %>
12
+ <% end %>
13
+ <% end %>
@@ -5,7 +5,6 @@
5
5
  <% breadcrumbs.each do |p| %>
6
6
  <li>
7
7
  <%= @page == p ? p.title : link_to(p.title, edit_page_path(p.id)) %>
8
- <%= content_tag :span, :class => 'divider' do %>/<% end %>
9
8
  </li>
10
9
  <% end %>
11
10
  <%= content_tag(:li, @page.title) if @page.persisted? %>
@@ -42,7 +41,7 @@
42
41
  <%= content_tag :div, :id => "page-seo", :class => "collapse" do %>
43
42
  <%= f.inputs do %>
44
43
  <%= f.input :browser_title %>
45
- <%= f.input :keywords %>
44
+ <%= f.input :keywords, as: :string, input_html: { maxlength: nil } %>
46
45
  <%= f.input :description %>
47
46
  <% end %>
48
47
  <% end %>
@@ -2,14 +2,12 @@ require 'dragonfly'
2
2
 
3
3
  # Configure
4
4
  Dragonfly.app.configure do
5
- plugin :imagemagick
5
+ plugin :imagemagick,
6
+ convert_command: `which convert`.strip.presence || "/usr/local/bin/convert",
7
+ identify_command: `which identify`.strip.presence || "/usr/local/bin/identify"
6
8
 
7
- verify_urls true
8
9
  secret "7fb765cbc9f1d92d5d1a56a43193d34d4f9b54dced3e62cb4e42f25d2500dd0f"
9
10
 
10
- convert_command = `which convert`.strip.presence || "/usr/local/bin/convert"
11
- identify_command = `which identify`.strip.presence || "/usr/local/bin/identify"
12
-
13
11
  url_format '/uploads/assets/:job/:name'
14
12
 
15
13
  datastore Smithy::Asset.dragonfly_datastore
@@ -0,0 +1,5 @@
1
+ class ChangePageKeywordsToText < ActiveRecord::Migration
2
+ def change
3
+ change_column(:smithy_pages, :keywords, :text)
4
+ end
5
+ end
@@ -1,9 +1,9 @@
1
1
  module Smithy
2
- module ContentPieces
2
+ module ContentResources
3
3
  module Base
4
4
  extend ActiveSupport::Concern
5
5
  included do
6
- Smithy::ContentPieces::Registry.register self
6
+ Smithy::ContentResources::Registry.register self
7
7
  end
8
8
  end
9
9
  end
@@ -0,0 +1,31 @@
1
+ require 'active_support/concern'
2
+
3
+ module Smithy
4
+ module ContentResources
5
+ class Registry
6
+ @@content_resources = []
7
+
8
+ class << self
9
+ def clear
10
+ @@content_resources = []
11
+ end
12
+
13
+ def content_resources
14
+ @@content_resources
15
+ end
16
+
17
+ def register(content_resource_model_name, navigation_title=nil)
18
+ return if @@content_resources.include?(content_resource_model_name)
19
+ navigation_title ||= content_resource_model_name.to_s.titleize.pluralize
20
+ @@content_resources << [content_resource_model_name.to_s.tableize, navigation_title]
21
+ Smithy::Engine.routes.prepend do
22
+ scope '/smithy/content_resources' do
23
+ resources content_resource_model_name.to_s.tableize
24
+ end
25
+ end
26
+ @@content_resources
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,2 @@
1
+ require 'smithy/content_resources/base'
2
+ require 'smithy/content_resources/registry'
@@ -5,7 +5,7 @@ require 'bootstrap-sass'
5
5
  require 'awesome_nested_set'
6
6
  require 'dragonfly'
7
7
  require 'fog'
8
- require 'font-awesome-sass-rails'
8
+ require 'font-awesome-sass'
9
9
  require 'formtastic'
10
10
  require 'formtastic-bootstrap'
11
11
  require 'friendly_id'
@@ -12,7 +12,7 @@ module Smithy
12
12
  module ClassMethods
13
13
  def content_types
14
14
  {
15
- :image => ['image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png', 'image/jpg', 'image/x-icon'],
15
+ :image => ['image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png', 'image/jpg', 'image/x-icon', 'image/svg+xml'],
16
16
  :media => [/^video/, 'application/x-shockwave-flash', 'application/x-flash-video', 'application/x-swf', /^audio/, 'application/ogg', 'application/x-mp3'],
17
17
  :pdf => ['application/pdf', 'application/x-pdf'],
18
18
  :stylesheet => ['text/css'],
@@ -30,7 +30,7 @@ module Smithy
30
30
  /#{ENV['AWS_S3_BUCKET']}\.s3\.amazonaws\.com/
31
31
  ]
32
32
  end
33
- ::Dragonfly::S3DataStore.new(bucket_name: ENV['AWS_S3_BUCKET'], access_key_id: ENV['AWS_ACCESS_KEY_ID'], secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'])
33
+ ::Dragonfly::S3DataStore.new(bucket_name: ENV['AWS_S3_BUCKET'], access_key_id: ENV['AWS_ACCESS_KEY_ID'], secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'], region: ENV['AWS_S3_REGION'], url_scheme: 'https')
34
34
  else
35
35
  Dragonfly.app.configure { fetch_url_whitelist [] }
36
36
  ::Dragonfly::FileDataStore.new(root_path: Rails.root.join('public/system/dragonfly', Rails.env), server_root: Rails.root.join('public'))
data/lib/smithy/engine.rb CHANGED
@@ -24,6 +24,10 @@ module Smithy
24
24
  g.helper false
25
25
  end
26
26
 
27
+ initializer :assets do |config|
28
+ Rails.application.config.assets.precompile += %w( ZeroClipboard.swf )
29
+ end
30
+
27
31
  config.after_initialize do
28
32
  # We need to reload the routes here due to how Smithy sets them up.
29
33
  # The different facets of Smithy (auth) append/prepend routes to Smithy
@@ -0,0 +1,42 @@
1
+ module Smithy
2
+ module Liquid
3
+ module Filters
4
+ module SmithyHelpers
5
+ def rails_helper(helper, *args)
6
+ options = args_to_options(args)
7
+ helper = helper.to_sym
8
+ return nil if !controller.view_context.respond_to?(helper)
9
+ if options.blank?
10
+ controller.view_context.public_send(helper)
11
+ else
12
+ controller.view_context.public_send(helper, options)
13
+ end
14
+ end
15
+
16
+
17
+ protected
18
+ # Convert an array of properties ('key:value') into a hash
19
+ # Ex: ['width:50', 'height:100'] => { :width => '50', :height => '100' }
20
+ def args_to_options(*args)
21
+ options = {}
22
+ args.flatten.each do |a|
23
+ if (a =~ /^(.*):(.*)$/)
24
+ options[$1.to_sym] = $2
25
+ end
26
+ end
27
+ options
28
+ end
29
+
30
+ def context
31
+ context = self.instance_variable_get(:@context)
32
+ end
33
+
34
+ def controller
35
+ context.registers[:controller]
36
+ end
37
+
38
+ end
39
+ ::Liquid::Template.register_filter(SmithyHelpers)
40
+ end
41
+ end
42
+ end