Permalink
Browse files

adjusts assets / adds task to copy assets, etc.

  • Loading branch information...
1 parent ed6a745 commit d52688dc81c2dbb40f8404df4937a3d768cb2b4a @jejacks0n committed Mar 24, 2013
View
@@ -13,6 +13,7 @@ namespace :mercury do
env = Rails.application.assets
output_path = Rails.root.join('distro')
stylesheets = ['mercury.css']
+ asset_paths = ['fonts/mercury']
javascripts = {
dependencies: 'mercury/dependencies.js',
locales: 'mercury/locales.js',
@@ -88,10 +89,16 @@ namespace :mercury do
asset = env.find_asset(path)
asset.write_to(output_path.join(path))
- # add base64 encoded image urls
+ # add base64 encoded image/font urls
processed = asset.source.gsub(/url\(\/assets\/mercury\/(.*?)\)/ix) do |m|
- encoded = Base64.encode64(File.read(Rails.root.join('lib/images/mercury', $1))).gsub("\n", '')
- "url(data:image/png;base64,#{encoded})"
+ format = 'image/png'
+ file = Rails.root.join('lib/images/mercury', $1)
+ unless File.exists?(file)
+ format = 'font/ttf'
+ file = Rails.root.join('lib/fonts/mercury', $1)
+ end
+ encoded = Base64.encode64(File.read(file)).gsub("\n", '')
+ "url(data:#{format};base64,#{encoded})"
end
# minimized css with a few line breaks added in
@@ -104,6 +111,15 @@ namespace :mercury do
end
end
end
+
+ desc "Copy asset files into distro"
+ task :assets => :environment do
+ puts 'Copying assets...'
+ FileUtils.mkdir_p(output_path.join('assets'))
+ for path in asset_paths
+ FileUtils.cp_r Rails.root.join('lib', path), output_path.join('assets')
+ end
+ end
end
end
View
@@ -18,6 +18,7 @@ module Mercury
config.assets.debug = true
config.assets.paths = []
+ #config.assets.paths << 'distro'
config.assets.paths << 'lib/dependencies'
config.assets.paths << 'lib/javascripts'
config.assets.paths << 'lib/stylesheets'
View
@@ -0,0 +1,102 @@
+!!!
+%html
+ %head
+ = csrf_meta_tag
+ = javascript_include_tag "dependencies/jquery-1.9.1",
+ "dependencies/rangy-core",
+ "dependencies/rangy-cssclassapplier",
+ "dependencies/rangy-serializer",
+ "dependencies/showdown-1.0"
+ = javascript_include_tag "mercury.min"
+ = javascript_include_tag "regions/html.min",
+ "regions/gallery.min",
+ "regions/image.min",
+ "regions/markdown.min",
+ "regions/plain.min",
+ "regions/text.min"
+ = stylesheet_link_tag "mercury.bundle"
+ %script jQuery(function() { window.mercury = Mercury.init() })
+ %body
+ %h1 Mercury2 <a href="/teabag">Specs</a>
+
+ %p
+ Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
+ <br/>
+ %img(src="http://goo.gl/ZoJd4")
+ <br/>
+ = link_to('Google Link', 'http://google.com')
+
+ %hr
+ -# -----------------------------------------------------------------------------------------------------------------
+ %h2 HTML Regions
+
+ #html1(data-mercury="html")
+ Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
+
+ %section#html2(data-mercury="html") section
+ %p#html3(data-mercury="html") paragraph
+ %span#html4(data-mercury="html") span
+
+ %ul
+ %li#html5(data-mercury="html") list item
+
+ %table
+ %tr
+ %td#html6(data-mercury="html") table cell
+ %td another table cell
+
+ %h2#plain(data-mercury="plain")
+ Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
+
+ %hr
+ -# -----------------------------------------------------------------------------------------------------------------
+ %h2 Markdown Regions
+
+ #markdown1(data-mercury="markdown" data-region-options='{"name": "markdown_region_1", "allowDirection": true}')
+ :preserve
+ 1
+ **something here**
+ 2
+
+ paragraph1
+ Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
+
+ paragraph2
+
+ paragraph3
+
+ #markdown2(data-mercury="markdown") Lorem Ipsum is simply dummy text of the printing and typesetting industry.
+
+ %hr
+ -# -----------------------------------------------------------------------------------------------------------------
+ %h2 Text Regions
+
+ %h1#text1(data-mercury="text") Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy
+ #text2(data-mercury="text" data-region-options='{"height": 100, "autoSize": false}') Lorem<br/><br/>Testing
+
+ %hr
+ -# -----------------------------------------------------------------------------------------------------------------
+ %h2 Image Regions
+
+ %img#image1(data-mercury="image" src="http://goo.gl/CgyJj" width="200")
+ %img#image2(data-mercury="image" src="http://goo.gl/CgyJj" width="200")
+
+ %hr
+ -# -----------------------------------------------------------------------------------------------------------------
+ %h2 Gallery Region
+
+ #gallery1(data-mercury="gallery")
+ .slides
+ .paginator
+
+:scss
+ .red {
+ color: red;
+ }
+ .blue {
+ color: blue;
+ }
+ .highlight {
+ background: yellow;
+ }
+
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.

0 comments on commit d52688d

Please sign in to comment.