archival 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/archival.gemspec +2 -1
- data/bin/redcarpet +29 -0
- data/lib/archival/builder.rb +44 -18
- data/lib/archival/helper_server.rb +1 -1
- data/lib/archival/version.rb +1 -1
- data/package.json +1 -1
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c29406fcec39c52b6876b805dba5509d6f43da5805944a344b2c771214cd8ed
|
4
|
+
data.tar.gz: 7319f9d6dace6b20c57e318d4df1c4dc80c1bd67673cee1b37d9a17ba35f823b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e05e6573f3e580d3a364826b7fd604559f2513e609a5436ba4170d606112d913e91d3cc0ec5498f4e0c418212b85068d7d859829030ee8b113a8909b04020e64
|
7
|
+
data.tar.gz: 8c227320c6d961595b5ce545559df4cdddf42e1d27819c1e5013b1e8189932bb50b4047e47bc5f85c8af1b0109a9b582063e487fb926132248d766b19fc98498
|
data/archival.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'archival'
|
5
|
-
s.version = '0.0.
|
5
|
+
s.version = '0.0.5'
|
6
6
|
s.summary = 'An incredibly simple CMS for durable websites'
|
7
7
|
s.description = 'https://jesseditson.com/the-simplest-cms-part-1'
|
8
8
|
s.authors = ['Jesse Ditson']
|
@@ -24,5 +24,6 @@ Gem::Specification.new do |s|
|
|
24
24
|
|
25
25
|
s.add_dependency 'liquid', '~> 5.1.0'
|
26
26
|
s.add_dependency 'listen', '~> 3.7.0'
|
27
|
+
s.add_dependency 'redcarpet', '~> 3.5.1'
|
27
28
|
s.add_dependency 'tomlrb', '~> 2.0.1'
|
28
29
|
end
|
data/bin/redcarpet
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'redcarpet' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("redcarpet", "redcarpet")
|
data/lib/archival/builder.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'liquid'
|
4
4
|
require 'tomlrb'
|
5
5
|
require 'tags/layout'
|
6
|
+
require 'redcarpet'
|
6
7
|
|
7
8
|
Liquid::Template.error_mode = :strict
|
8
9
|
Liquid::Template.register_tag('layout', Layout)
|
@@ -13,23 +14,33 @@ module Archival
|
|
13
14
|
|
14
15
|
def initialize(config, *_args)
|
15
16
|
@config = config
|
17
|
+
@markdown = Redcarpet::Markdown.new(
|
18
|
+
Redcarpet::Render::HTML.new(prettify: true,
|
19
|
+
hard_wrap: true), no_intra_emphasis: true,
|
20
|
+
fenced_code_blocks: true,
|
21
|
+
autolink: true,
|
22
|
+
strikethrough: true,
|
23
|
+
underline: true
|
24
|
+
)
|
16
25
|
refresh_config
|
17
26
|
end
|
18
27
|
|
19
28
|
def refresh_config
|
20
29
|
@file_system = Liquid::LocalFileSystem.new(
|
21
|
-
@config.root, '%s.liquid'
|
30
|
+
File.join(@config.root, @config.pages_dir), '%s.liquid'
|
22
31
|
)
|
23
32
|
@variables = {}
|
24
33
|
@object_types = {}
|
25
34
|
@page_templates = {}
|
26
35
|
|
27
|
-
Liquid::Template.file_system =
|
36
|
+
Liquid::Template.file_system = Liquid::LocalFileSystem.new(
|
37
|
+
File.join(@config.root, @config.pages_dir), '_%s.liquid'
|
38
|
+
)
|
28
39
|
|
29
40
|
objects_definition_file = File.join(@config.root,
|
30
41
|
'objects.toml')
|
31
42
|
if File.file? objects_definition_file
|
32
|
-
@object_types =
|
43
|
+
@object_types = Tomlrb.load_file(objects_definition_file)
|
33
44
|
end
|
34
45
|
|
35
46
|
update_pages
|
@@ -61,10 +72,7 @@ module Archival
|
|
61
72
|
if entry.end_with?('.liquid') && !(entry.start_with? '_')
|
62
73
|
page_name = File.basename(entry,
|
63
74
|
'.liquid')
|
64
|
-
template_file =
|
65
|
-
@config.pages_dir,
|
66
|
-
add_prefix.call(page_name)
|
67
|
-
)
|
75
|
+
template_file = add_prefix.call(page_name)
|
68
76
|
content = @file_system.read_template_file(template_file)
|
69
77
|
content += dev_mode_content if @config.dev_mode
|
70
78
|
@page_templates[add_prefix.call(page_name)] =
|
@@ -81,30 +89,48 @@ module Archival
|
|
81
89
|
|
82
90
|
def do_update_objects(dir)
|
83
91
|
objects = {}
|
84
|
-
@object_types.each do |name,
|
85
|
-
objects[name] =
|
92
|
+
@object_types.each do |name, definition|
|
93
|
+
objects[name] = {}
|
86
94
|
obj_dir = File.join(dir, name)
|
87
95
|
if File.directory? obj_dir
|
88
96
|
Dir.foreach(obj_dir) do |file|
|
89
97
|
if file.end_with? '.toml'
|
90
|
-
object =
|
91
|
-
|
92
|
-
|
98
|
+
object = Tomlrb.load_file(File.join(
|
99
|
+
obj_dir, file
|
100
|
+
))
|
93
101
|
object[:name] =
|
94
102
|
File.basename(file, '.toml')
|
95
|
-
objects[name]
|
103
|
+
objects[name][object[:name]] = parse_object(object, definition)
|
96
104
|
end
|
97
105
|
end
|
98
106
|
end
|
99
|
-
objects[name] = objects[name]
|
100
|
-
(a['order'] || a[:name]).to_s <=> (b['order'] || b[:name]).to_s
|
101
|
-
end
|
107
|
+
objects[name] = sort_objects(objects[name])
|
102
108
|
end
|
103
109
|
@variables['objects'] = objects
|
104
110
|
end
|
105
111
|
|
106
|
-
def
|
107
|
-
|
112
|
+
def sort_objects(objects)
|
113
|
+
# Since objects are hashes but we'd like them to be iterable based on
|
114
|
+
# arbitrary "order" keys, and in ruby hashes enumerate in insert order,
|
115
|
+
# we just need to re-insert in the correct order.
|
116
|
+
sorted_keys = objects.sort_by do |name, obj|
|
117
|
+
obj['order'].to_s || name
|
118
|
+
end
|
119
|
+
sorted_objects = {}
|
120
|
+
sorted_keys.each do |d|
|
121
|
+
sorted_objects[d[0]] = d[1]
|
122
|
+
end
|
123
|
+
sorted_objects
|
124
|
+
end
|
125
|
+
|
126
|
+
def parse_object(object, definition)
|
127
|
+
definition.each do |name, type|
|
128
|
+
case type
|
129
|
+
when 'markdown'
|
130
|
+
object[name] = @markdown.render(object[name]) if object[name]
|
131
|
+
end
|
132
|
+
end
|
133
|
+
object
|
108
134
|
end
|
109
135
|
|
110
136
|
def set_var(name, value)
|
data/lib/archival/version.rb
CHANGED
data/package.json
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: archival
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesse Ditson
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 3.7.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: redcarpet
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.5.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.5.1
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: tomlrb
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,6 +90,7 @@ files:
|
|
76
90
|
- bin/ldiff
|
77
91
|
- bin/listen
|
78
92
|
- bin/rake
|
93
|
+
- bin/redcarpet
|
79
94
|
- bin/rspec
|
80
95
|
- bin/rubocop
|
81
96
|
- bin/ruby-parse
|