haml_tumblr 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,38 +1,11 @@
1
- def render( partial )
2
- haml_concat Haml::Engine.new(File.read "partials/_#{partial.to_s}.haml" ).render(self)
3
- end
4
-
5
- def tab
6
- tab_up
7
- yield
8
- tab_down
9
- end
1
+ $LOAD_PATH << File.dirname(__FILE__)
10
2
 
11
- def coffee_tag( coffee_file )
12
- require 'coffee-script'
13
- haml_tag :script, :type => 'text/javascript' do
14
- haml_concat CoffeeScript.compile File.read "#{coffee_file.to_s}.coffee"
15
- end
16
- end
3
+ require 'haml_tumblr/defaults'
4
+ require 'haml_tumblr/helpers'
5
+ require 'haml_tumblr/importers'
17
6
 
18
- def jquery_tag( version = "1.7.2" )
19
- haml_tag :script,
20
- :type => 'text/javascript',
21
- :src => 'http://ajax.googleapis.com/ajax/libs/jquery/#{version}/jquery.min.js'
22
- end
23
-
24
- def sass_tag( sass_file )
25
- require 'sass'
26
- haml_tag :style, :type => 'text/css' do
27
- haml_concat Sass::Engine.new(File.read "#{sass_file.to_s}.sass").render
28
- end
29
- end
30
-
31
- def scss_tag( scss_file )
32
- require 'sass'
33
- haml_tag :style, :type => 'text/css' do
34
- haml_concat Sass::Engine.new(File.read "#{scss_file.to_s}.scss").render
35
- end
7
+ def render( partial )
8
+ Haml::Engine.new(File.read "partials/_#{partial.to_s}.haml" ).render(self)
36
9
  end
37
10
 
38
11
  def tumblr_tag( tag )
@@ -47,18 +20,24 @@ def tumblr_tag( tag )
47
20
  end
48
21
  end
49
22
 
50
- def tumblr_link_tag( tag )
51
- "{#{process tag}}"
52
- end
53
-
54
- def link_to( text, address )
55
- haml_tag :a, :href => address do
56
- haml_concat text
23
+ def tumblr( tag )
24
+ if block_given?
25
+ haml_concat "{block:#{process tag}}"
26
+ tab do
27
+ yield
28
+ end
29
+ haml_concat "{/block:#{process tag}}"
30
+ nil
31
+ else
32
+ "{#{process tag}}"
57
33
  end
58
34
  end
59
35
 
60
- private
61
-
62
- def process( tag )
63
- tag.to_s.split("_").map(&:capitalize).join
36
+ module Tumblr
37
+ @@sass_variables = {:color => {}, :font => {} }
38
+
39
+ def self.variables
40
+ @@sass_variables
41
+ end
42
+
64
43
  end
@@ -0,0 +1,24 @@
1
+ def render_defaults( format = :sass )
2
+ Tumblr.variables ||= {:color => {}, :font => {}}
3
+ [:font, :color].map { |type|
4
+ Tumblr.variables[type].each_pair.map { |key, value|
5
+ "$#{key}: unquote( \"{#{type}:#{process key}}\" )"
6
+ }
7
+ }.flatten.map { |string|
8
+ format == :scss ? string + ";" : string
9
+ }.join("\n") + "\n"
10
+ end
11
+
12
+ def default_colors( hash )
13
+ hash.each_pair.map { |key, val|
14
+ Tumblr.variables[:color][key.to_s] = val
15
+ capture_haml { haml_tag :meta, :name => "color:#{process key}", :content => val }
16
+ }.join
17
+ end
18
+
19
+ def default_fonts( hash )
20
+ hash.each_pair.map { |key, val|
21
+ Tumblr.variables[:font][key.to_s] = val
22
+ capture_haml { haml_tag :meta, :name => "font:#{process key}", :content => val }
23
+ }.join
24
+ end
@@ -0,0 +1,22 @@
1
+ def process( tag )
2
+ tag.to_s.split("_").map(&:capitalize).join
3
+ end
4
+
5
+ def link_to( *args )
6
+ if block_given?
7
+ haml_tag :a, :href => args.first do
8
+ yield
9
+ end
10
+ else
11
+ haml_tag :a, :href => args.last do
12
+ haml_concat args.first
13
+ end
14
+ end
15
+ nil
16
+ end
17
+
18
+ def tab
19
+ tab_up
20
+ yield
21
+ tab_down
22
+ end
@@ -0,0 +1,34 @@
1
+ def coffee_tag( coffee_file )
2
+ require 'coffee-script'
3
+ capture_haml do
4
+ haml_tag :script, :type => 'text/javascript' do
5
+ haml_concat CoffeeScript.compile File.read "#{coffee_file.to_s}.coffee"
6
+ end
7
+ end
8
+ end
9
+
10
+ def jquery_tag( version = "1.7.2" )
11
+ capture_haml { haml_tag :script,
12
+ :type => 'text/javascript',
13
+ :src => 'http://ajax.googleapis.com/ajax/libs/jquery/#{version}/jquery.min.js' }
14
+ end
15
+
16
+ def sass_tag( sass_file )
17
+ require 'sass'
18
+ full_sass = render_defaults(:sass) + (File.read "#{sass_file.to_s}.sass")
19
+ capture_haml {
20
+ haml_tag :style, :type => 'text/css' do
21
+ haml_concat Sass::Engine.new(full_sass).render
22
+ end
23
+ }
24
+ end
25
+
26
+ def scss_tag( scss_file )
27
+ require 'sass'
28
+ full_sass = render_defaults(:scss) + (File.read "#{scss_file.to_s}.sass")
29
+ capture_haml {
30
+ haml_tag :style, :type => 'text/css' do
31
+ haml_concat Sass::Engine.new(full_sass).render
32
+ end
33
+ }
34
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml_tumblr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-14 00:00:00.000000000 Z
12
+ date: 2012-06-14 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: fraser.m.murray@gmail.com
@@ -17,6 +17,9 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - lib/haml_tumblr/helpers.rb
21
+ - lib/haml_tumblr/defaults.rb
22
+ - lib/haml_tumblr/importers.rb
20
23
  - lib/haml_tumblr.rb
21
24
  homepage: http://github.com/intolerable/haml_tumblr
22
25
  licenses: []
@@ -38,7 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
38
41
  version: '0'
39
42
  requirements: []
40
43
  rubyforge_project:
41
- rubygems_version: 1.8.15
44
+ rubygems_version: 1.8.22
42
45
  signing_key:
43
46
  specification_version: 3
44
47
  summary: library for making Tumblr themes nicer to write in Haml