octopress-ink 1.0.0.alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +38 -0
- data/Rakefile +1 -0
- data/lib/octopress-ink.rb +37 -0
- data/lib/octopress-ink/assets.rb +10 -0
- data/lib/octopress-ink/assets/asset.rb +71 -0
- data/lib/octopress-ink/assets/javascript.rb +9 -0
- data/lib/octopress-ink/assets/layout.rb +25 -0
- data/lib/octopress-ink/assets/sass.rb +64 -0
- data/lib/octopress-ink/assets/static_file.rb +26 -0
- data/lib/octopress-ink/assets/static_file_content.rb +13 -0
- data/lib/octopress-ink/assets/stylesheet.rb +24 -0
- data/lib/octopress-ink/assets/template.rb +20 -0
- data/lib/octopress-ink/generators/plugin_assets.rb +9 -0
- data/lib/octopress-ink/helpers/content_for.rb +29 -0
- data/lib/octopress-ink/jekyll/hooks.rb +12 -0
- data/lib/octopress-ink/plugin.rb +142 -0
- data/lib/octopress-ink/plugins.rb +232 -0
- data/lib/octopress-ink/plugins/sass.rb +18 -0
- data/lib/octopress-ink/tags.rb +14 -0
- data/lib/octopress-ink/tags/content_for.rb +17 -0
- data/lib/octopress-ink/tags/embed.rb +28 -0
- data/lib/octopress-ink/tags/footer.rb +10 -0
- data/lib/octopress-ink/tags/head.rb +10 -0
- data/lib/octopress-ink/tags/javascript.rb +18 -0
- data/lib/octopress-ink/tags/scripts.rb +10 -0
- data/lib/octopress-ink/tags/stylesheet.rb +18 -0
- data/lib/octopress-ink/tags/wrap_yield.rb +25 -0
- data/lib/octopress-ink/tags/yield.rb +16 -0
- data/lib/octopress-ink/version.rb +5 -0
- data/octopress-ink.gemspec +27 -0
- data/test/.gitignore +1 -0
- data/test/Gemfile +8 -0
- data/test/_config.yml +14 -0
- data/test/_custom/theme/layouts/default.html +17 -0
- data/test/_custom/theme/stylesheets/_bazz.scss +1 -0
- data/test/_custom/theme/stylesheets/bar.scss +4 -0
- data/test/_custom/theme/stylesheets/site.css +1 -0
- data/test/_plugins/bundler.rb +23 -0
- data/test/_plugins/theme/embeds/foo.html +1 -0
- data/test/_plugins/theme/files/test.html +1 -0
- data/test/_plugins/theme/javascripts/bar.js +1 -0
- data/test/_plugins/theme/javascripts/foo.js +1 -0
- data/test/_plugins/theme/layouts/default.html +18 -0
- data/test/_plugins/theme/layouts/test.html +4 -0
- data/test/_plugins/theme/stylesheets/_baz.scss +1 -0
- data/test/_plugins/theme/stylesheets/bar.scss +4 -0
- data/test/_plugins/theme/stylesheets/foo.css +1 -0
- data/test/_plugins/theme/stylesheets/print.css +1 -0
- data/test/_plugins/theme/stylesheets/site.css +3 -0
- data/test/index.md +13 -0
- data/test/stylesheets/_foo.scss +1 -0
- data/test/stylesheets/site.sass +7 -0
- metadata +177 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2733bea14e5d82069fb9d58a63ccd5fed20efb04
|
4
|
+
data.tar.gz: deb7324821b5d0ac653e401d3c2897502968b415
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2240d4345400bac8244d3aeb23387fc94ace79f70fbfe706f047c2592f7961696f2df21b41fd8c7ba649ba210d6634c14dc37f1b7b97febef6f789e0a290fd8a
|
7
|
+
data.tar.gz: 2bc307c23fa3d23c472c524ec94326354da8b0a4b6239a3b7bff53117394a38bf0ae496ab45133d4ba4120345774696f0b9fe065d81cff7d753096ae5ffc97c3
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Brandon Mathis
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Octopress Ink
|
2
|
+
|
3
|
+
Use Ink to help you build themes and plugins for Jekyll.
|
4
|
+
|
5
|
+
### Features
|
6
|
+
- Installing Ink plugins is easy.
|
7
|
+
- Users won't need to install or managae plugin assets.
|
8
|
+
- Jekyll will read your plugin's layouts, javascripts, stylesheets and more directly from your gem.
|
9
|
+
- Ink allows users to modify a theme or plugin by adding their modified version to _themes directory.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
gem 'octopress-ink'
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install octopress-ink
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
This is still evolving quite a bit. If you want to use it, you
|
28
|
+
should probably talk to me directly.
|
29
|
+
|
30
|
+
## Roadmap
|
31
|
+
- Write an example theme
|
32
|
+
- Write an example plugin
|
33
|
+
- Add support for compiling and stitching javascript/coffeescript.
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
For right now. Talk to me directly. I'd love help thinking
|
38
|
+
through some of this stuff. Pretty soon, build a theme or a plugin and tell me what's broken.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'jekyll'
|
2
|
+
require 'pry-debugger'
|
3
|
+
require 'digest/md5'
|
4
|
+
|
5
|
+
require 'octopress-ink/generators/plugin_assets'
|
6
|
+
require 'octopress-ink/jekyll/hooks'
|
7
|
+
require 'octopress-ink/version'
|
8
|
+
require 'octopress-ink/helpers/content_for'
|
9
|
+
|
10
|
+
module Octopress
|
11
|
+
CUSTOM_DIR = "_custom"
|
12
|
+
|
13
|
+
autoload :Assets, 'octopress-ink/assets'
|
14
|
+
autoload :StaticFile, 'octopress-ink/assets/static_file'
|
15
|
+
autoload :StaticFileContent, 'octopress-ink/assets/static_file_content'
|
16
|
+
autoload :Plugins, 'octopress-ink/plugins'
|
17
|
+
autoload :Plugin, 'octopress-ink/plugin'
|
18
|
+
autoload :Tags, 'octopress-ink/tags'
|
19
|
+
autoload :SassPlugin, 'octopress-ink/plugins/sass'
|
20
|
+
|
21
|
+
def self.register_plugin(plugin, name, type)
|
22
|
+
Plugins.register_plugin(plugin, name, type)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Liquid::Template.register_tag('embed', Octopress::Tags::EmbedTag)
|
27
|
+
Liquid::Template.register_tag('theme_js', Octopress::Tags::JavascriptTag)
|
28
|
+
Liquid::Template.register_tag('theme_css', Octopress::Tags::StylesheetTag)
|
29
|
+
Liquid::Template.register_tag('content_for', Octopress::Tags::ContentForBlock)
|
30
|
+
Liquid::Template.register_tag('head', Octopress::Tags::HeadBlock)
|
31
|
+
Liquid::Template.register_tag('footer', Octopress::Tags::FooterBlock)
|
32
|
+
Liquid::Template.register_tag('scripts', Octopress::Tags::ScriptsBlock)
|
33
|
+
Liquid::Template.register_tag('yield', Octopress::Tags::YieldTag)
|
34
|
+
Liquid::Template.register_tag('wrap_yield', Octopress::Tags::WrapYieldBlock)
|
35
|
+
|
36
|
+
Octopress.register_plugin(Octopress::SassPlugin, 'sass', 'local_plugin')
|
37
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Octopress
|
2
|
+
module Assets
|
3
|
+
autoload :Asset, 'octopress-ink/assets/asset'
|
4
|
+
autoload :Javascript, 'octopress-ink/assets/javascript'
|
5
|
+
autoload :Stylesheet, 'octopress-ink/assets/stylesheet'
|
6
|
+
autoload :Sass, 'octopress-ink/assets/sass'
|
7
|
+
autoload :Template, 'octopress-ink/assets/template'
|
8
|
+
autoload :Layout, 'octopress-ink/assets/layout'
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Octopress
|
2
|
+
module Assets
|
3
|
+
class Asset
|
4
|
+
|
5
|
+
def initialize(plugin, type, file)
|
6
|
+
@file = file
|
7
|
+
@type = type
|
8
|
+
@plugin = plugin
|
9
|
+
@plugin_type = plugin.type
|
10
|
+
@root = plugin.assets_path
|
11
|
+
@dir = File.join(plugin.namespace, type)
|
12
|
+
@exists = {}
|
13
|
+
end
|
14
|
+
|
15
|
+
def file
|
16
|
+
@file
|
17
|
+
end
|
18
|
+
|
19
|
+
def path(site)
|
20
|
+
file = user_path(site)
|
21
|
+
|
22
|
+
if !exists?(file) && @plugin_type != 'local_plugin'
|
23
|
+
file = plugin_path
|
24
|
+
end
|
25
|
+
|
26
|
+
unless exists? file
|
27
|
+
raise IOError.new "Could not find #{File.basename(file)} at #{file}"
|
28
|
+
end
|
29
|
+
Pathname.new file
|
30
|
+
end
|
31
|
+
|
32
|
+
def file(file, site)
|
33
|
+
@file = file
|
34
|
+
path(site)
|
35
|
+
end
|
36
|
+
|
37
|
+
def destination
|
38
|
+
File.join(@dir, @file)
|
39
|
+
end
|
40
|
+
|
41
|
+
def copy(site)
|
42
|
+
site.static_files << StaticFile.new(path(site), destination)
|
43
|
+
end
|
44
|
+
|
45
|
+
def plugin_dir
|
46
|
+
File.join @root, @type
|
47
|
+
end
|
48
|
+
|
49
|
+
def plugin_path
|
50
|
+
File.join plugin_dir, @file
|
51
|
+
end
|
52
|
+
|
53
|
+
def user_dir(site)
|
54
|
+
File.join site.source, Plugins.custom_dir(site), @dir
|
55
|
+
end
|
56
|
+
|
57
|
+
def user_path(site)
|
58
|
+
if @plugin_type == 'local_plugin'
|
59
|
+
File.join site.source, @dir, @file
|
60
|
+
else
|
61
|
+
File.join user_dir(site), @file
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def exists?(file)
|
66
|
+
@exists[file] ||= File.exists?(file)
|
67
|
+
@exists[file]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Octopress
|
2
|
+
module Assets
|
3
|
+
class Layout < Asset
|
4
|
+
|
5
|
+
def file(file, site)
|
6
|
+
@file = file
|
7
|
+
end
|
8
|
+
|
9
|
+
def register(site)
|
10
|
+
name = "#{@plugin.namespace}:#{@file}"
|
11
|
+
name = name.split(".")[0..-2].join(".")
|
12
|
+
|
13
|
+
file = user_path(site)
|
14
|
+
dir = user_dir(site)
|
15
|
+
if !exists?(file)
|
16
|
+
file = plugin_path
|
17
|
+
dir = plugin_dir
|
18
|
+
end
|
19
|
+
|
20
|
+
site.layouts[name] = Jekyll::Layout.new(site, dir, @file)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Octopress
|
2
|
+
module Assets
|
3
|
+
class Sass < Asset
|
4
|
+
def initialize(plugin, type, file, media)
|
5
|
+
@file = file
|
6
|
+
@type = type
|
7
|
+
@plugin_type = plugin.type
|
8
|
+
@root = plugin.assets_path
|
9
|
+
@dir = File.join(plugin.namespace, type)
|
10
|
+
@exists = {}
|
11
|
+
@media = media || 'all'
|
12
|
+
end
|
13
|
+
|
14
|
+
def media
|
15
|
+
@media
|
16
|
+
end
|
17
|
+
|
18
|
+
def tag
|
19
|
+
"<link href='/#{File.join(@dir, @file)}' media='#{@media}' rel='stylesheet' type='text/css'>"
|
20
|
+
end
|
21
|
+
|
22
|
+
def user_load_path(site)
|
23
|
+
File.join site.source, Plugins.custom_dir(site), @dir, File.dirname(@file)
|
24
|
+
end
|
25
|
+
|
26
|
+
def theme_load_path
|
27
|
+
File.expand_path(File.join(@root, @type))
|
28
|
+
end
|
29
|
+
|
30
|
+
# Remove sass files from Jekyll's static_files array so it doesn't end up in the
|
31
|
+
# compiled site directory.
|
32
|
+
#
|
33
|
+
def remove_static_file(site)
|
34
|
+
site.static_files.clone.each do |sf|
|
35
|
+
if sf.kind_of?(Jekyll::StaticFile) && sf.path == path(site).to_s
|
36
|
+
site.static_files.delete(sf)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def compile(site)
|
42
|
+
unless @compiled
|
43
|
+
options = Plugins.sass_options(site)
|
44
|
+
if @plugin_type == 'local_plugin'
|
45
|
+
remove_static_file(site)
|
46
|
+
@compiled = Plugins.compile_sass_file(path(site).to_s, options)
|
47
|
+
else
|
48
|
+
# If the plugin isn't a local plugin, add source paths to allow overrieds on @imports.
|
49
|
+
#
|
50
|
+
options[:load_paths] = [user_load_path(site), theme_load_path]
|
51
|
+
@compiled = Plugins.compile_sass_file(path(site).to_s, options)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
@compiled
|
56
|
+
end
|
57
|
+
|
58
|
+
def copy(site)
|
59
|
+
site.static_files << StaticFileContent.new(compile(site), destination)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Octopress
|
2
|
+
class StaticFile
|
3
|
+
def initialize(source, dest)
|
4
|
+
@source = source
|
5
|
+
@dest = dest
|
6
|
+
end
|
7
|
+
|
8
|
+
def destination(dest)
|
9
|
+
File.join(dest, @dest)
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
@source
|
14
|
+
end
|
15
|
+
|
16
|
+
def write(dest)
|
17
|
+
dest_path = destination(dest)
|
18
|
+
|
19
|
+
FileUtils.mkdir_p(File.dirname(dest_path))
|
20
|
+
FileUtils.cp(@source, dest_path)
|
21
|
+
|
22
|
+
true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Octopress
|
2
|
+
module Assets
|
3
|
+
class Stylesheet < Asset
|
4
|
+
def initialize(plugin, type, file, media)
|
5
|
+
@file = file
|
6
|
+
@type = type
|
7
|
+
@root = plugin.assets_path
|
8
|
+
@dir = File.join(plugin.namespace, type)
|
9
|
+
@plugin_type = plugin.type
|
10
|
+
@media = media || 'all'
|
11
|
+
@exists = {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def media
|
15
|
+
@media
|
16
|
+
end
|
17
|
+
|
18
|
+
def tag
|
19
|
+
"<link href='/#{File.join(@dir, @file)}' media='#{@media}' rel='stylesheet' type='text/css'>"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Octopress
|
2
|
+
module Assets
|
3
|
+
class Template < Asset
|
4
|
+
|
5
|
+
def initialize(plugin, type)
|
6
|
+
@plugin_type = plugin.type
|
7
|
+
@root = plugin.assets_path
|
8
|
+
@type = type
|
9
|
+
@dir = File.join(plugin.namespace, type)
|
10
|
+
@exists = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def file(file, site)
|
14
|
+
@file = file
|
15
|
+
path(site)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Octopress
|
2
|
+
module Helpers
|
3
|
+
module ContentFor
|
4
|
+
def self.get_block_name(tag_name, markup)
|
5
|
+
if markup.strip == ''
|
6
|
+
raise IOError.new "Syntax Error: #{tag_name} requires a name, eg. {% #{tag_name} sidebar %}"
|
7
|
+
else
|
8
|
+
markup.strip
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Gets the storage space for the content block
|
13
|
+
def self.get_block(context, block)
|
14
|
+
context.environments.first['content_for'] ||= {}
|
15
|
+
context.environments.first['content_for'][block] ||= []
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.render(context, block)
|
19
|
+
content = get_block(context, block).map { |b| b.strip }.join
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.append_to_block(context, block, content)
|
23
|
+
converter = context.environments.first['converter']
|
24
|
+
content = converter.convert(content.strip).strip
|
25
|
+
get_block(context, block) << content
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|