Skip to content

Commit

Permalink
Merge branch 'master' into refile2
Browse files Browse the repository at this point in the history
Conflicts:
	app/assets/javascripts/smithy/assets.js.coffee
	app/controllers/smithy/assets_controller.rb
	app/views/smithy/assets/_asset.html.erb
	app/views/smithy/assets/_form.html.erb
	app/views/smithy/assets/create.js.erb
	smithycms.gemspec
  • Loading branch information
drobin03 committed Jan 21, 2016
2 parents 8f8b41d + 1fe8969 commit 910fb4b
Show file tree
Hide file tree
Showing 22 changed files with 2,670 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -11,6 +11,7 @@ spec/dummy/tmp/
spec/dummy/.env
spec/dummy/.sass-cache
spec/dummy/.rvmrc
spec/dummy/.env
spec/dummy/public/system/
Gemfile.lock
tmp/
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/smithy/application.js
Expand Up @@ -12,4 +12,5 @@
//= require ace-1.1.3/mode-javascript.js
//= require ace-1.1.3/mode-liquid.js
//= require ace-1.1.3/mode-markdown.js
//= require zeroclipboard-2.2.0/ZeroClipboard.min.js
//= require_tree .
19 changes: 19 additions & 0 deletions app/assets/javascripts/smithy/copy_link.js.coffee.erb
@@ -0,0 +1,19 @@
//= depend_on_asset "ZeroClipboard.swf"
jQuery ->

ZeroClipboard.config({
swfPath: '<%= image_path "ZeroClipboard.swf" %>'
});

($ 'body').on "click", ".copy-to-clipboard", (e) ->
e.preventDefault()
$('.copy-to-clipboard').each ->
$link = ($ this)
clip = new ZeroClipboard( this )
clip.on "copy", (e) ->
clip.setText($link.data('clipboard-text'))
saved_text = $link.text()
$link.text 'Copied!'
setTimeout ->
$link.text(saved_text)
, 2000
@@ -1,6 +1,6 @@
require_dependency "smithy/base_controller"

class Smithy::ContentPiecesController < Smithy::BaseController
class Smithy::ContentResourcesController < Smithy::BaseController
before_filter :set_controller_path
respond_to :html, :json

Expand Down Expand Up @@ -61,7 +61,7 @@ def filtered_params

def klass
# override to provide an object for each class
raise "You must inherit from this Smithy::ContentPiecesController and provide a private #klass method"
raise "You must inherit from this Smithy::ContentResourcesController and provide a private #klass method"
end

def klass_name
Expand Down
3 changes: 3 additions & 0 deletions app/views/layouts/smithy/shared/_nav.html.erb
Expand Up @@ -15,6 +15,9 @@
<ul class="nav navbar-nav">
<li><%= link_to "<i class=\"fa fa-sitemap\"></i> Manage Content".html_safe, pages_path %></li>
<li><%= link_to "<i class=\"fa fa-file\"></i> Images &amp; Files".html_safe, assets_path %></li>
<% Smithy::ContentResources::Registry.content_resources.each do |controller_name, title| %>
<li><%= link_to title, controller_name.to_sym %></li>
<% end %>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><%= link_to "<i class=\"fa fa-arrow-right\"></i> View Site".html_safe, root_path %></li>
Expand Down
1 change: 1 addition & 0 deletions app/views/smithy/assets/_asset.html.erb
Expand Up @@ -13,6 +13,7 @@
<td><strong><%= asset.name %></strong></td>
<td><%= number_to_human_size asset.file_size %></td>
<td>
<%= 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) } %>
<%= link_to "Edit", [:edit, asset], class: "btn btn-primary btn-xs" %>
<%= link_to "Delete", asset, class: "btn btn-danger btn-xs", method: :delete, data: { confirm: "Are you sure?" } %>
</td>
Expand Down
1 change: 1 addition & 0 deletions app/views/smithy/assets/_form.html.erb
Expand Up @@ -9,6 +9,7 @@
</div>
<% if @asset.file %>
<div>
<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>
<%= link_to attachment_url(@asset, :file) do %>
<% if @asset.file_type == :image %>
<%= attachment_image_tag(@asset, :file, :fit, 300, 300, alt: '') %>
Expand Down
3 changes: 1 addition & 2 deletions lib/smithy.rb
Expand Up @@ -8,13 +8,12 @@
require 'smithy/formatter'
#
require 'smithy/content_blocks'
require 'smithy/content_resources'

module Smithy

def self.log(*args)
level = args.size == 1 ? 'info' : args.first
message = args.size == 1 ? args.first : args.last
::Smithy::Logger.send(level.to_sym, message)
end

end
31 changes: 0 additions & 31 deletions lib/smithy/content_pieces/registry.rb

This file was deleted.

2 changes: 2 additions & 0 deletions lib/smithy/content_resources.rb
@@ -0,0 +1,2 @@
require 'smithy/content_resources/base'
require 'smithy/content_resources/registry'
@@ -1,9 +1,9 @@
module Smithy
module ContentPieces
module ContentResources
module Base
extend ActiveSupport::Concern
included do
Smithy::ContentPieces::Registry.register self
Smithy::ContentResources::Registry.register self
end
end
end
Expand Down
31 changes: 31 additions & 0 deletions lib/smithy/content_resources/registry.rb
@@ -0,0 +1,31 @@
require 'active_support/concern'

module Smithy
module ContentResources
class Registry
@@content_resources = []

class << self
def clear
@@content_resources = []
end

def content_resources
@@content_resources
end

def register(content_resource_model_name, navigation_title=nil)
return if @@content_resources.include?(content_resource_model_name)
navigation_title ||= content_resource_model_name.to_s.titleize.pluralize
@@content_resources << [content_resource_model_name.to_s.tableize, navigation_title]
Smithy::Engine.routes.prepend do
scope '/smithy/content_resources' do
resources content_resource_model_name.to_s.tableize
end
end
@@content_resources
end
end
end
end
end
4 changes: 4 additions & 0 deletions lib/smithy/engine.rb
Expand Up @@ -24,6 +24,10 @@ def root
g.helper false
end

initializer :assets do |config|
Rails.application.config.assets.precompile += %w( ZeroClipboard.swf )
end

config.after_initialize do
# We need to reload the routes here due to how Smithy sets them up.
# The different facets of Smithy (auth) append/prepend routes to Smithy
Expand Down
10 changes: 8 additions & 2 deletions lib/smithy/liquid/tags/html.rb
Expand Up @@ -22,6 +22,10 @@ def tag_with_ext(ext)
tag.match(/\.#{ext}$/) ? tag : "#{tag}.#{ext}"
end

def tag_without_ext(ext)
tag.sub(/\.#{ext}$/, '')
end

def render(context)
raise Error.new("please override Smithy::Liquid::Tag::Html::Base#render")
end
Expand All @@ -42,13 +46,15 @@ def render(context)
class SmithyJavascriptIncludeTag < Base
def render(context)
controller = context.registers[:controller]
controller.view_context.send(:javascript_include_tag, "/templates/javascripts/#{tag_with_ext('js')}")
javascript = Smithy::Template.javascripts.find_by(name: tag_without_ext('js'))
controller.view_context.send(:javascript_include_tag, "/templates/javascripts/#{tag_with_ext('js')}?#{javascript.updated_at.to_s(:number) if javascript.present?}")
end
end
class SmithyStylesheetLinkTag < Base
def render(context)
controller = context.registers[:controller]
controller.view_context.send(:stylesheet_link_tag, "/templates/stylesheets/#{tag_with_ext('css')}")
stylesheet = Smithy::Template.stylesheets.find_by(name: tag_without_ext('css'))
controller.view_context.send(:stylesheet_link_tag, "/templates/stylesheets/#{tag_with_ext('css')}?#{stylesheet.updated_at.to_s(:number) if stylesheet.present?}")
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion smithycms.gemspec
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |s|
s.rdoc_options = ["--main"]
s.files = Dir["{app,config,db,lib,vendor}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"]

s.add_dependency 'rails', '~> 4.1.6'
s.add_dependency 'rails', '>= 4.0.0', '< 5'
s.add_dependency 'jquery-rails'

s.add_dependency 'autoprefixer-rails' # for bootstrap-sass
Expand All @@ -28,6 +28,7 @@ Gem::Specification.new do |s|
s.add_dependency 'bootstrap-sass', '~> 3.2.0'
s.add_dependency 'coffee-rails'
s.add_dependency 'font-awesome-sass', '~> 4.2'
s.add_dependency 'fog', '~> 1.36'
s.add_dependency 'formtastic', '~> 2.3.1' # as of writing, formtastic-bootstrap is only compatible with 2.3.x
s.add_dependency 'formtastic-bootstrap', '~> 3.0.0'
s.add_dependency 'friendly_id', '~> 5.0.4'
Expand Down
Binary file added vendor/assets/images/ZeroClipboard.swf
Binary file not shown.

0 comments on commit 910fb4b

Please sign in to comment.