middleman-org 0.1.0 → 0.2.0
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 +4 -4
- data/lib/middleman-org/extension.rb +16 -3
- data/lib/middleman-org/helpers.rb +25 -11
- data/lib/middleman-org/org_article.rb +22 -8
- data/lib/middleman-org/org_data.rb +6 -4
- data/lib/middleman-org/version.rb +1 -1
- data/middleman-org.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a311d5390b08913e4ac82bcd7bb59531c3d4271f
|
4
|
+
data.tar.gz: 7eb15646043b8c664ddbd971ed0c6a0c55b5c66d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d30c48667d5da0083fd65ea2692ba13e101fc467266679c5147d1a025bc2d5e04521f89bd52f02b559b13b797b92b4db784cf5a67e47d4db10b22ee71789695
|
7
|
+
data.tar.gz: 6d0e6436ea4300f2298a2f53484daa8c3b54c5a5c35bcd16c0aab0edfd27c8a34e26e372ab659e4ecf9344420b3d4875391faadac42971d47d9f55b084b92a52
|
@@ -4,12 +4,18 @@ require 'middleman-org/helpers'
|
|
4
4
|
|
5
5
|
module Middleman
|
6
6
|
class OrgExtension < ::Middleman::Extension
|
7
|
+
self.supports_multiple_instances = true
|
8
|
+
|
9
|
+
option :name, nil, 'Unique ID for telling multiple orgs apart'
|
7
10
|
option :layout, 'layout', 'article specific layout'
|
8
11
|
option :root, 'org', 'source folder for org files'
|
9
12
|
option :prefix, nil, 'prefix on destination and root path'
|
10
|
-
|
13
|
+
|
14
|
+
option :emacs, 'emacs', 'emacs executable'
|
15
|
+
option :load, nil, 'load elisp file'
|
11
16
|
|
12
17
|
attr_reader :data
|
18
|
+
attr_reader :name
|
13
19
|
|
14
20
|
self.defined_helpers = [Middleman::Org::Helpers]
|
15
21
|
def initialize(app, options_hash = {}, &block)
|
@@ -17,13 +23,19 @@ module Middleman
|
|
17
23
|
super
|
18
24
|
|
19
25
|
# Require libraries only when activated
|
26
|
+
require 'emacs-ruby'
|
20
27
|
require 'org-ruby'
|
21
28
|
require 'middleman-org/org_data'
|
29
|
+
::Tilt.prefer(Tilt::OrgTemplate, 'org')
|
22
30
|
|
23
|
-
|
31
|
+
@name = options.name.to_sym if options.name
|
32
|
+
# options.root = File.join(options.prefix, options.root) if options.prefix
|
24
33
|
|
25
34
|
app.after_configuration do
|
26
35
|
template_extensions org: :html
|
36
|
+
if config[:org_engine] == :emacs_ruby
|
37
|
+
::Tilt.prefer(Tilt::EmacsRuby::OrgTemplate, 'org')
|
38
|
+
end
|
27
39
|
end
|
28
40
|
|
29
41
|
# set up your extension
|
@@ -31,7 +43,8 @@ module Middleman
|
|
31
43
|
end
|
32
44
|
|
33
45
|
def after_configuration
|
34
|
-
::Middleman::Org.
|
46
|
+
@name ||= :"org#{::Middleman::Org.instances.keys.length}"
|
47
|
+
::Middleman::Org.instances[@name] = self
|
35
48
|
|
36
49
|
# Make sure ActiveSupport's TimeZone stuff has something to work with,
|
37
50
|
# allowing people to set their desired time zone via Time.zone or
|
@@ -1,24 +1,38 @@
|
|
1
1
|
module Middleman
|
2
2
|
module Org
|
3
|
-
|
4
|
-
|
5
|
-
@controller ||= nil
|
3
|
+
def self.instances
|
4
|
+
@org_instances ||= {}
|
6
5
|
end
|
7
6
|
|
8
|
-
def self.
|
9
|
-
@
|
7
|
+
def self.instances=(v)
|
8
|
+
@org_instances = v
|
10
9
|
end
|
11
10
|
|
12
11
|
module Helpers
|
13
12
|
def self.included(base)
|
13
|
+
::Middleman::Org.instances = {}
|
14
|
+
end
|
15
|
+
|
16
|
+
def org_instances
|
17
|
+
::Middleman::Org.instances
|
18
|
+
end
|
19
|
+
|
20
|
+
def org_controller(org_name = nil)
|
21
|
+
# Warn if a non-existent org name provided
|
22
|
+
if org_name && !org_instances.keys.include?(org_name.to_sym)
|
23
|
+
fail "Non-existent org name provided: #{org_name}."
|
24
|
+
end
|
25
|
+
|
26
|
+
org_name ||= org_instances.keys.first
|
27
|
+
org_instances[org_name.to_sym]
|
14
28
|
end
|
15
29
|
|
16
|
-
def
|
17
|
-
|
30
|
+
def org_data(org_name = nil)
|
31
|
+
org_controller(org_name).data
|
18
32
|
end
|
19
33
|
|
20
|
-
def
|
21
|
-
|
34
|
+
def org_article?
|
35
|
+
!current_article.nil?
|
22
36
|
end
|
23
37
|
|
24
38
|
def current_article
|
@@ -30,8 +44,8 @@ module Middleman
|
|
30
44
|
end
|
31
45
|
end
|
32
46
|
|
33
|
-
def articles
|
34
|
-
org_data.articles
|
47
|
+
def articles(org_name = nil)
|
48
|
+
org_data(org_name).articles
|
35
49
|
end
|
36
50
|
end
|
37
51
|
end
|
@@ -42,7 +42,12 @@ module Middleman
|
|
42
42
|
opts[:layout] = opts[:layout].to_s if opts[:layout].is_a? Symbol
|
43
43
|
end
|
44
44
|
|
45
|
+
opts[:emacs] = org_options.emacs
|
46
|
+
opts[:load] = org_options.load
|
47
|
+
|
45
48
|
content = super(opts, locs, &block)
|
49
|
+
# testing
|
50
|
+
# content = export source_file
|
46
51
|
fix_links(content)
|
47
52
|
end
|
48
53
|
|
@@ -58,19 +63,27 @@ module Middleman
|
|
58
63
|
in_buffer_setting['TITLE'] || File.basename(source_file, '.*')
|
59
64
|
end
|
60
65
|
|
61
|
-
def
|
62
|
-
|
63
|
-
return [] unless
|
66
|
+
def keywords
|
67
|
+
article_keywords = in_buffer_setting['KEYWORDS']
|
68
|
+
return [] unless article_keywords
|
64
69
|
|
65
|
-
if
|
66
|
-
|
70
|
+
if article_keywords.is_a? String
|
71
|
+
article_keywords.split(' ').map(&:strip)
|
67
72
|
else
|
68
|
-
Array(
|
73
|
+
Array(article_keywords).map(&:to_s)
|
69
74
|
end
|
70
75
|
end
|
71
76
|
|
77
|
+
def description
|
78
|
+
in_buffer_setting['DESCRIPTION'] || 'no description'
|
79
|
+
end
|
80
|
+
|
81
|
+
def category
|
82
|
+
in_buffer_setting['CATEGORY'] || ''
|
83
|
+
end
|
84
|
+
|
72
85
|
def published?
|
73
|
-
|
86
|
+
in_buffer_setting['DATE'] || false
|
74
87
|
end
|
75
88
|
|
76
89
|
def body
|
@@ -80,7 +93,8 @@ module Middleman
|
|
80
93
|
def date
|
81
94
|
return @_date if @_date
|
82
95
|
|
83
|
-
|
96
|
+
return nil unless in_buffer_setting['DATE']
|
97
|
+
@_date = Date.parse in_buffer_setting['DATE']
|
84
98
|
|
85
99
|
# frontmatter_date = data['date']
|
86
100
|
|
@@ -28,15 +28,17 @@ module Middleman
|
|
28
28
|
resources.each do |resource|
|
29
29
|
next unless resource.path =~ /^#{options.root}/
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
if options.prefix
|
32
|
+
resource.destination_path = resource
|
33
|
+
.path
|
34
|
+
.gsub(/^#{options.root}/,
|
35
|
+
options.prefix)
|
36
|
+
end
|
33
37
|
if File.extname(resource.source_file) == '.org'
|
34
38
|
article = convert_to_article resource
|
35
|
-
puts article.source_file
|
36
39
|
next unless publishable?(article)
|
37
40
|
@_articles << article
|
38
41
|
end
|
39
|
-
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
data/middleman-org.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-org
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xiaoxing Hu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman-core
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: emacs-ruby
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.1'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.1'
|
69
83
|
description: Middleman extension for publishing org-mode project
|
70
84
|
email:
|
71
85
|
- dawnstar.hu@gmail.com
|