octopress-ink 1.0.0.rc.13 → 1.0.0.rc.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48037693d08748489adee87f801cb143f5a320fd
4
- data.tar.gz: 7ffb7e286fd7664305502dbbb98dd6e32c55c6fc
3
+ metadata.gz: b2897bcee91248ea1e129e5cf04a4f0c1ede2844
4
+ data.tar.gz: ffbebcfa8a92445270a5241ca67e7b2a2feac89c
5
5
  SHA512:
6
- metadata.gz: c1021fc8290f4d780810aa696046f60d9fe63c49d370817d4eb0514445f05cee27ce32bffcbaf39464166599b0418d5a609c5d5f062b829b7ae21d0b0bb5931e
7
- data.tar.gz: 4b20db2aec8fc8bdcdaba7b17708e9c6d0543dee05a5c54e645e27f07a3631e669ab14add044f72a6ee779c60bf9dd9e819b76da591c5047af7db3844df28ed1
6
+ metadata.gz: 29f661c90f771c2aae273523978bb1ec1f6dad7fc75efe1080e206c33afa9e93b7fea49cbc8879d895f815454f7274caeef6cf74ffd7ed6c3ecc9bd13078a6d7
7
+ data.tar.gz: 9316a8d4c8e18b6536d80b5f0c7e82c16ff7c302e111a0f15cd30e76cd93b2f5aca1d7a66bb14573dd468b5ff62a94e75593e99e2353b1354951a72b345093e2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ### 1.0.0 RC14 - 2014-08-11
4
+
5
+ - Reworked asset methods
6
+
3
7
  ### 1.0.0 RC13 - 2014-08-11
4
8
 
5
9
  - Fixed an issue with asset tags
@@ -5,6 +5,8 @@ module Octopress
5
5
  attr_reader :plugin, :dir, :base, :root, :file
6
6
  attr_accessor :exists
7
7
 
8
+ FRONT_MATTER = /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
9
+
8
10
  def initialize(plugin, base, file)
9
11
  @file = file
10
12
  @base = base
@@ -57,6 +59,10 @@ module Octopress
57
59
  end
58
60
  end
59
61
 
62
+ def ext
63
+ File.extname(filename)
64
+ end
65
+
60
66
  def read
61
67
  path.read
62
68
  end
@@ -96,28 +102,55 @@ module Octopress
96
102
  File.join(dir, file)
97
103
  end
98
104
 
99
- private
100
-
101
- def source_dir
102
- if exists? user_override_path
103
- user_dir
104
- else
105
- plugin_dir
105
+ def content
106
+ unless @content
107
+ if read =~ FRONT_MATTER
108
+ @content = $POSTMATCH
109
+ else
110
+ @content = read
111
+ end
106
112
  end
113
+ @content
107
114
  end
108
115
 
109
116
  # Render file through Liquid if it contains YAML front-matter
110
117
  #
111
118
  def render
112
- content = path.read
119
+ unless @rendered_content
120
+ if asset_payload = payload
121
+ @rendered_content = Liquid::Template.parse(content).render!(payload)
122
+ else
123
+ @rendered_content = content
124
+ end
125
+ end
126
+
127
+ @rendered_content
128
+ end
113
129
 
114
- if content =~ /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
115
- payload = Octopress.site.site_payload
116
- content = $POSTMATCH
117
- payload['page'] = SafeYAML.load($1)
118
- Liquid::Template.parse(content).render!(payload)
130
+ def payload
131
+ unless @payload
132
+ @payload = Octopress.site.site_payload
133
+ @payload['page'] = data
134
+ end
135
+
136
+ @payload
137
+ end
138
+
139
+ def data
140
+ if read =~ FRONT_MATTER
141
+ SafeYAML.load($1)
142
+ else
143
+ {}
144
+ end
145
+ end
146
+
147
+ private
148
+
149
+ def source_dir
150
+ if exists? user_override_path
151
+ user_dir
119
152
  else
120
- content
153
+ plugin_dir
121
154
  end
122
155
  end
123
156
 
@@ -2,19 +2,13 @@ module Octopress
2
2
  module Ink
3
3
  module Assets
4
4
  class Coffeescript < Javascript
5
- def read
6
- @compiled ||= compile
7
- end
8
-
9
5
  def add
10
6
  Plugins.add_js_tag tag
11
- Plugins.static_files << StaticFileContent.new(read, destination)
7
+ Plugins.static_files << StaticFileContent.new(compile, destination)
12
8
  end
13
9
 
14
- private
15
-
16
10
  def compile
17
- ::CoffeeScript.compile(render)
11
+ ::CoffeeScript.compile(content)
18
12
  end
19
13
 
20
14
  def destination
@@ -11,8 +11,6 @@ module Octopress
11
11
  super
12
12
  end
13
13
 
14
- private
15
-
16
14
  def destination
17
15
  File.join(base, plugin.slug, file)
18
16
  end
@@ -17,21 +17,13 @@ module Octopress
17
17
  "<link href='#{Filters.expand_url(File.join(dir, file))}' media='#{@media}' rel='stylesheet' type='text/css'>"
18
18
  end
19
19
 
20
- def read
21
- @compiled ||= compile
22
- end
23
-
24
20
  def add
25
21
  unless file =~ /^_/
26
22
  Plugins.add_css_tag tag
27
- Plugins.static_files << StaticFileContent.new(read, destination)
23
+ Plugins.static_files << StaticFileContent.new(compile, destination)
28
24
  end
29
25
  end
30
26
 
31
- def content
32
- render
33
- end
34
-
35
27
  def ext
36
28
  path.extname
37
29
  end
@@ -44,12 +36,16 @@ module Octopress
44
36
  is_disabled('sass', filename) || is_disabled('stylesheets', filename)
45
37
  end
46
38
 
47
- private
48
-
49
39
  def compile
50
40
  PluginAssetPipeline.compile_sass(self)
51
41
  end
52
42
 
43
+ def destination
44
+ File.join(base, plugin.slug, file.sub(/@(.+?)\./,'.').sub(/s.ss/, 'css'))
45
+ end
46
+
47
+ private
48
+
53
49
  def user_load_path
54
50
  File.join(Octopress.site.source, Plugins.custom_dir, dir, File.dirname(file)).sub /\/\.$/, ''
55
51
  end
@@ -73,9 +69,6 @@ module Octopress
73
69
  file.sub(ext, alt_ext)
74
70
  end
75
71
 
76
- def destination
77
- File.join(base, plugin.slug, file.sub(/@(.+?)\./,'.').sub(/s.ss/, 'css'))
78
- end
79
72
  end
80
73
  end
81
74
  end
@@ -13,7 +13,7 @@ module Octopress
13
13
  end
14
14
 
15
15
  def self.compile_sass(sass)
16
- Sass.compile(sass.content, sass_configs(sass))
16
+ Sass.compile(sass.render, sass_configs(sass))
17
17
  end
18
18
 
19
19
  # Gets default Sass configuration hash from Jekyll
@@ -77,7 +77,7 @@ module Octopress
77
77
  header = "/* #{file.plugin.type.capitalize}: #{file.plugin.name} */"
78
78
  combined[media] ||= ''
79
79
  combined[media] << "#{header}\n" unless combined[media] =~ /#{file.plugin.name}/
80
- combined[media] << file.read
80
+ combined[media] << (file.ext.match(/\.s[ca]ss/) ? file.compile : file.content)
81
81
  end
82
82
  end
83
83
 
@@ -139,11 +139,11 @@ module Octopress
139
139
  @combined_javascript
140
140
  else
141
141
  js = ""
142
- javascripts.clone.each do |f|
143
- unless js =~ /#{f.plugin.name}/
144
- js += "/* #{f.plugin.type.capitalize}: #{f.plugin.name} */\n"
142
+ javascripts.clone.each do |file|
143
+ unless js =~ /#{file.plugin.name}/
144
+ js += "/* #{file.plugin.type.capitalize}: #{file.plugin.name} */\n"
145
145
  end
146
- js += f.read
146
+ js += (file.ext.match(/.coffee/) ? file.compile : file.content)
147
147
  end
148
148
  @combined_javascript = js
149
149
  end
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
2
  module Ink
3
- VERSION = "1.0.0.rc.13"
3
+ VERSION = "1.0.0.rc.14"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopress-ink
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc.13
4
+ version: 1.0.0.rc.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-11 00:00:00.000000000 Z
11
+ date: 2014-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll