wst 0.11.0 → 0.12.0

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: 723c892f789eacb670ebb1a44dfda254c9bfc918
4
- data.tar.gz: c46c1e6e3739c985f9a4113ed334e1a8c6a3bd33
3
+ metadata.gz: 5780fc012bd4a1464f33820f2b1e87e78e20cbc8
4
+ data.tar.gz: 78ca2b68b04a8d910a3d7b3f5e6fb6e1ed56c309
5
5
  SHA512:
6
- metadata.gz: abbcc6b49120ba2cd7c15ae3516876a27b6a0f0fdfd9994e060f568734a03abada64c490aaaf6f099b33c9e8339f9c9feae8cfb6c006494b948ab1d595307018
7
- data.tar.gz: 3ca844e17483d1f3eeb4c1d602283dea52563339d7f4c508bd68258d97df87cc74e11a00b0164c13d41fabef25420656a686839f662a966a2136a76fa141f4c6
6
+ metadata.gz: 86746cf2fe7cae704138f752013773fcc6d8bffea36c1d4e585810ef4abef2ac22d721ff29faf75146f97912b366b240f62a823aceaa8bd5f979ee6cb5fea171
7
+ data.tar.gz: 77b8ca27579bd135db248ab2cdbdb3a43105898ae84aa7c982bab40e392280999936d2866f5c77547082a26c08437e3f37eea4d32a61109f53f3a8010e17e829
data/lib/wst/logging.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- require 'wst/logger'
2
+ require 'logger'
3
3
 
4
4
  module Wst
5
5
  module Logging
data/lib/wst/main.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- require 'haml_helpers_wlt_extensions'
2
+ require 'wst/haml_helpers_wlt_extensions'
3
3
  require 'wst/post'
4
4
  require 'wst/page'
5
5
  require 'wst/renderer_factory'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wst
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yves Brissaud
@@ -10,6 +10,20 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2015-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: wst-parser
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.1'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: haml
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -135,20 +149,14 @@ files:
135
149
  - lib/.editorconfig
136
150
  - lib/wst.rb
137
151
  - lib/wst/colored.rb
138
- - lib/wst/configuration.rb
139
- - lib/wst/content.rb
140
152
  - lib/wst/css_renderer.rb
141
- - lib/wst/haml_content.rb
142
153
  - lib/wst/haml_helpers_wlt_extensions.rb
143
154
  - lib/wst/haml_renderer.rb
144
155
  - lib/wst/html_with_pygments.rb
145
156
  - lib/wst/js_renderer.rb
146
157
  - lib/wst/logging.rb
147
158
  - lib/wst/main.rb
148
- - lib/wst/md_content.rb
149
159
  - lib/wst/md_renderer.rb
150
- - lib/wst/page.rb
151
- - lib/wst/post.rb
152
160
  - lib/wst/reader.rb
153
161
  - lib/wst/renderer.rb
154
162
  - lib/wst/renderer_factory.rb
@@ -1,65 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Wst
4
- module Configuration
5
- def config
6
- Configuration.config
7
- end
8
-
9
- def self.config
10
- @config
11
- end
12
-
13
- def defaultLinks
14
- Configuration.defaultLinks
15
- end
16
-
17
- def self.defaultLinks
18
- @defaultLinks
19
- end
20
-
21
- def self.read_config location, local
22
- Configuration.read_configuration location, local
23
- Configuration.read_default_links
24
- Configuration.read_translations
25
- end
26
-
27
- def self.read_configuration location, local
28
- raise "Not a valid Web Log Today location" unless self.valid_location? location
29
- @config = YAML.load File.open(File.join(location, 'config.yaml'), 'r:utf-8').read
30
- @config["__site_url__"] = @config["site_url"]
31
- @config["site_url"] = "http://localhost:4000" if local
32
- @config["path"] = location
33
- @config["debug"] = ENV['WST_ENV'] != nil && ENV['WST_ENV'].casecmp('debug').zero?
34
- end
35
-
36
- def self.read_default_links
37
- @defaultLinks = if File.exists? self.links_file_path then "\n" + File.open(self.links_file_path, "r:utf-8").read else "" end
38
- end
39
-
40
- def self.read_translations
41
- @config['translations'] = {}
42
- self.translation_files.each do |file|
43
- translation = YAML.load File.open(file, 'r:utf-8').read
44
- lang = File.basename file, '.yaml'
45
- @config['translations'][lang] = translation
46
- end
47
- end
48
-
49
- def self.valid_location? location
50
- return false unless File.exists? File.join location, "config.yaml"
51
- return false unless File.directory? File.join location, "_posts"
52
- return false unless File.directory? File.join location, "_pages"
53
- return false unless File.directory? File.join location, "_layouts"
54
- return true
55
- end
56
-
57
- def self.links_file_path
58
- File.join config['path'], "links.md"
59
- end
60
-
61
- def self.translation_files
62
- Dir.glob File.join config['path'], "_translations", "**.yaml"
63
- end
64
- end
65
- end
data/lib/wst/content.rb DELETED
@@ -1,100 +0,0 @@
1
- # encoding: utf-8
2
- require 'yaml'
3
- require 'wst/configuration'
4
- require 'digest/md5'
5
-
6
- module Wst
7
- class Content
8
- include Configuration
9
-
10
- def initialize file_path, child = nil
11
- @file_path = file_path
12
- @plain_content = ""
13
- @datas = Hash.new
14
- @cats = ""
15
- @child = child
16
- @content = content
17
-
18
- read_content
19
- end
20
-
21
- def child
22
- @child
23
- end
24
-
25
- def content
26
- c = self
27
- while !c.child.nil?
28
- c = c.child
29
- end
30
- c
31
- end
32
-
33
- def dir
34
- File.dirname @file_path
35
- end
36
-
37
- def method_missing(m, *args, &block)
38
- if m =~ /^(.*)\?$/
39
- return @datas.has_key? $1
40
- elsif @datas.has_key? m.to_s
41
- return @datas[m.to_s]
42
- else
43
- return nil
44
- end
45
- end
46
-
47
- def raw_content
48
- @plain_content
49
- end
50
-
51
- def content_url= url
52
- @url = url
53
- end
54
-
55
- def content_url
56
- @url ||= ''
57
- end
58
-
59
- def datas
60
- @datas
61
- end
62
-
63
- def gravatar?
64
- email?
65
- end
66
-
67
- def gravatar
68
- hash = Digest::MD5.hexdigest(email)
69
- "http://www.gravatar.com/avatar/#{hash}"
70
- end
71
-
72
- def account? name
73
- return false unless config.has_key? "accounts"
74
- return config["accounts"].has_key? name
75
- end
76
-
77
- def account name
78
- return nil unless account? name
79
- return config["accounts"][name]
80
- end
81
-
82
- protected
83
-
84
- def default_links_path
85
- "#{config['path']}/links.md"
86
- end
87
-
88
- def read_content
89
- @plain_content = File.open(@file_path, "r:utf-8").read
90
- begin
91
- if @plain_content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
92
- @plain_content = $'
93
- @datas = YAML.load $1
94
- end
95
- rescue => e
96
- puts "YAML Exception reading #{@file_path}: #{e.message}"
97
- end
98
- end
99
- end
100
- end
@@ -1,23 +0,0 @@
1
- # encoding: utf-8
2
- require 'wst/content'
3
-
4
- module Wst
5
- class HamlContent < Content
6
- def initialize file_path, child = nil, sub_content = ''
7
- super file_path, child
8
- @sub_content = sub_content
9
- end
10
-
11
- def sub_content
12
- @sub_content
13
- end
14
-
15
- def deep_content
16
- c = self
17
- while !c.child.nil? && !c.child.child.nil?
18
- c = c.child
19
- end
20
- c
21
- end
22
- end
23
- end
@@ -1,49 +0,0 @@
1
- # encoding: utf-8
2
- require 'wst/content'
3
- require 'wst/configuration'
4
-
5
- module Wst
6
- class MdContent < Content
7
- @@matcher = /^(.+\/)*(\d+-\d+-\d+)?-?(.*)(\.[^.]+)$/
8
-
9
- def initialize file_path
10
- super file_path
11
-
12
- m, cats, date, slug, ext = *file_path.match(@@matcher)
13
- @cats = cats
14
- @date = Time.parse(date) if date
15
- @slug = slug
16
- @ext = ext
17
- end
18
-
19
- def date
20
- @date
21
- end
22
-
23
- def raw_content
24
- if useDefaultLinks?
25
- content_with_links
26
- else
27
- @plain_content
28
- end
29
- end
30
-
31
- def self.matcher
32
- @@matcher
33
- end
34
-
35
- protected
36
-
37
- def content_with_links
38
- @plain_content + defaultLinks
39
- end
40
-
41
- def useDefaultLinks?
42
- if @datas.has_key? 'nolinks'
43
- @datas['nolinks'] == 'true'
44
- else
45
- true
46
- end
47
- end
48
- end
49
- end
data/lib/wst/page.rb DELETED
@@ -1,89 +0,0 @@
1
- # encoding: utf-8
2
- require 'wst/md_content'
3
- require 'wst/haml_content'
4
- require 'cgi'
5
-
6
- module Wst
7
- module PageComparison
8
- def <=> obj
9
- return content_url <=> obj.content_url
10
- end
11
- end
12
-
13
- class HamlPage < HamlContent
14
- include PageComparison
15
-
16
- @@matcher = /^(.+\/)*(.*)(\.[^.]+)$/
17
-
18
- def initialize file_path
19
- super file_path
20
-
21
- m, cats, slug, ext = *file_path.match(@@matcher)
22
- base_path = File.join(Configuration.config['path'], '_pages') + '/'
23
- @cats = cats.gsub(base_path, '').chomp('/') if !cats.nil? && cats != base_path
24
- @slug = slug
25
- @ext = ext
26
- end
27
-
28
- def content_url
29
- "#{@cats + '/' if @cats != ''}#{CGI.escape @slug}.html"
30
- end
31
-
32
- def self.matcher
33
- @@matcher
34
- end
35
- end
36
-
37
- class MdPage < MdContent
38
- include PageComparison
39
-
40
- def initialize file_path
41
- super file_path
42
-
43
- base_path = File.join(Configuration.config['path'], '_pages') + '/'
44
- @cats = @cats.gsub(base_path, '') if !@cats.nil?
45
- @cats.chomp!('/')
46
- end
47
-
48
- def content_url
49
- "#{@cats + '/' if @cats != ''}#{CGI.escape @slug}.html"
50
- end
51
- end
52
-
53
- class Page
54
- @@glob_md = '*.{md,mkd,markdown}'
55
- @@glob_haml = '*.haml'
56
-
57
- class << self
58
- def all
59
- (haml_pages + md_pages).sort
60
- end
61
-
62
- private
63
-
64
- def haml_pages
65
- page_files(@@glob_haml, HamlPage.matcher).inject([]) { |pages, file| pages << HamlPage.new(file) }
66
- end
67
-
68
- def md_pages
69
- page_files(@@glob_md, MdContent.matcher).inject([]) { |pages, file| pages << MdPage.new(file) }
70
- end
71
-
72
- def page_files glob, matcher
73
- select_match all_files(glob), matcher
74
- end
75
-
76
- def select_match files, matcher
77
- files.select { |file| file =~ matcher }
78
- end
79
-
80
- def all_files glob
81
- Dir.glob glob_path glob
82
- end
83
-
84
- def glob_path glob
85
- File.join "#{Configuration.config['path']}/_pages", '**', glob
86
- end
87
- end
88
- end
89
- end
data/lib/wst/post.rb DELETED
@@ -1,53 +0,0 @@
1
- # encoding: utf-8
2
- require 'wst/md_content'
3
-
4
- module Wst
5
- class Post < MdContent
6
- @@glob = "*.{md,mkd,markdown}"
7
-
8
- def initialize file_path
9
- super file_path
10
-
11
- base_path = File.join(Configuration.config['path'], '_posts') + '/'
12
- @cats = @cats.gsub(base_path, '') if !@cats.nil?
13
- @cats.chomp!('/')
14
- end
15
-
16
- def content_url
17
- generate_url = {
18
- "year" => @date.strftime("%Y"),
19
- "month" => @date.strftime("%m"),
20
- "day" => @date.strftime("%d"),
21
- "title" => CGI.escape(@slug)
22
- }.inject(":year/:month/:day/:title.html") { |result, token|
23
- result.gsub(/:#{Regexp.escape token.first}/, token.last)
24
- }.gsub(/\/\//, "/")
25
- generate_url = "#{@cats}/#{generate_url}" if @cats != ''
26
- generate_url
27
- end
28
-
29
- class << self
30
- def all
31
- post_files.inject([]) { |posts, file| posts << Post.new(file) }
32
- end
33
-
34
- private
35
-
36
- def glob_path
37
- File.join "#{Configuration.config['path']}/_posts", '**', @@glob
38
- end
39
-
40
- def all_files
41
- Dir.glob glob_path
42
- end
43
-
44
- def select_match files
45
- files.select { |file| file =~ @@matcher }
46
- end
47
-
48
- def post_files
49
- select_match(all_files).sort
50
- end
51
- end
52
- end
53
- end