ragerender 0.1.5 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aedbeb388659f01299aa3694a3f30bd1368e09e9f729caa31334fff4300c6b7c
4
- data.tar.gz: 11e966fefecb160bf9992f6697ae8fc23dbe299095c1bc458af6395fb29903c8
3
+ metadata.gz: 313e3cd9c0ccd4c11ea547a565e2a1cfa77af1fda5e2fc2219c0da8046c6f27a
4
+ data.tar.gz: 3911407ca12e719f71396099f73d70c6b19aeee29ccc38f796ef4c45b684d80d
5
5
  SHA512:
6
- metadata.gz: cbdffe416a3edb68d95c256456341c19199d09d71cbc0ef8d3a2f3b41b362048ec81d67848982beca07d2560d4a164758861c152d9b24d71f76010ee45bfc793
7
- data.tar.gz: 266d915e6744dd58bf1f5db3fe795105190f9a09081ed03b596d7c58420e258d0f3ff7e1546c209c051bfb936654583d528c5555835ce5340b2863f0158baf67
6
+ metadata.gz: 4ca0ef393683e910b68e9ffe41a5909511ec66da604b50bcb99fbd758cad371bdeafdd594e1a27394e461beb3e0e8f41c4c3033a28f4c7692a492b470251f8b2
7
+ data.tar.gz: 5509097f24aa3df45416be46acb9d2f31710318b4227b190f9413dcec287d6c473793bff0fd08b3ecf7b1cc49617b9437739fc991d1c9bd2a309fcbd61eef199
data/README.rdoc CHANGED
@@ -105,18 +105,17 @@ Your webcomic now has its basic information set up.
105
105
 
106
106
  === Adding your layouts
107
107
 
108
- RageRender will use a ComicFury default layout if you don't supply your own
109
- files.
108
+ If you want to use your own layout code, then create a <tt>_layouts</tt>
109
+ directory and put the contents of each of your ComicFury layout tabs in there,
110
+ and then put your CSS in the main folder.
110
111
 
111
- If you want to keep using the "simple" layout, you can add the details into your
112
- <tt>_config.yml</tt> too:
112
+ The easiest way is to go to your Webcomic Management, click "Edit Layout", then
113
+ in the box labelled "Useful", click "Download Layout Backup". Pass this file to
114
+ RageRender, which will <tt>unpack</tt> it for you:
113
115
 
114
- layout:
116
+ bundle exec jekyll unpack mycomic-2025-09-13.cflxml
115
117
 
116
- If you want to use your own layout code, then create a <tt>_layouts</tt>
117
- directory and put the contents of each of your ComicFury layout tabs in there,
118
- and then put your CSS in the main folder. You should end up with a full set of
119
- files like:
118
+ You should end up with a full set of files like:
120
119
 
121
120
  _layouts
122
121
  archive.html
@@ -134,7 +133,7 @@ instead.
134
133
 
135
134
  === Adding blogs
136
135
 
137
- Add your blogs into a folder called `_posts`:
136
+ Add your blogs into a folder called <tt>_posts</tt>:
138
137
 
139
138
  cat _posts/2025-05-29-my-new-comic.md
140
139
  Hey guys, welcome to my new comic! It's gonna be so sick!
@@ -201,6 +200,16 @@ You control this by setting a <tt>frontpage</tt> key in your site config.
201
200
  - anything else will display the extra page that has the matching
202
201
  <tt>slug</tt> in its Front Matter
203
202
 
203
+ === Putting changes on ComicFury
204
+
205
+ Once you're done making changes, you can <tt>pack</tt> your layout:
206
+
207
+ bundle exec jekyll pack
208
+
209
+ The resulting file can be uploaded to ComicFury by going to your Webcomic
210
+ Management, clicking "Edit Layout", then in the box labelled "Useful", click
211
+ "Restore Layout Backup".
212
+
204
213
  === Stuff that doesn't work
205
214
 
206
215
  Here is a probably incomplete list of things you can expect to be different
@@ -0,0 +1,105 @@
1
+ require 'pathname'
2
+ require 'rexml'
3
+ require 'base64'
4
+
5
+ module RageRender
6
+ HTML_FILES = {
7
+ overall: 'overall',
8
+ overview: 'overview',
9
+ viewblog: 'blog-display',
10
+ comic: 'comic-page',
11
+ archive: 'archive',
12
+ blogarchive: 'blog-archive',
13
+ error: 'error-page',
14
+ search: 'search',
15
+ }
16
+
17
+ CSS_FILES = {
18
+ layoutcss: 'layout'
19
+ }
20
+
21
+ def self.unpack src, html_dest, css_dest
22
+ doc = REXML::Document.new(src).elements
23
+ html_dir = Pathname.new(html_dest)
24
+ css_dir = Pathname.new(css_dest)
25
+
26
+ HTML_FILES.each do |(tag, filename)|
27
+ File.write html_dir.join(filename + '.html'), Base64.decode64(doc["/layout/ldata/#{tag.to_s}/text()"].value)
28
+ end
29
+
30
+ CSS_FILES.each do |(tag, filename)|
31
+ File.write css_dir.join(filename + '.css'), Base64.decode64(doc["/layout/ldata/#{tag.to_s}/text()"].value)
32
+ end
33
+ end
34
+
35
+ def self.pack html_srcdir, css_srcdir, dest
36
+ layout = REXML::Element.new('layout')
37
+
38
+ name = REXML::Element.new('name')
39
+ name.text = "Downloaded ComicFury layout"
40
+ layout.add name
41
+
42
+ version = REXML::Element.new('cfxml')
43
+ version.text = '1.2'
44
+ layout.add version
45
+
46
+ spage = REXML::Element.new('spage')
47
+ spage.text = '1'
48
+ layout.add spage
49
+
50
+ ldata = REXML::Element.new('ldata')
51
+ html_dir = Pathname.new(html_srcdir)
52
+ css_dir = Pathname.new(css_srcdir)
53
+
54
+ HTML_FILES.each do |(tag, filename)|
55
+ elem = REXML::Element.new tag.to_s
56
+ elem.text = Base64.strict_encode64 File.read html_dir.join(filename + '.html')
57
+ ldata.add elem
58
+ end
59
+
60
+ CSS_FILES.each do |(tag, filename)|
61
+ elem = REXML::Element.new tag.to_s
62
+ elem.text = Base64.strict_encode64 File.read css_dir.join(filename + '.css')
63
+ ldata.add elem
64
+ end
65
+ layout.add ldata
66
+
67
+ # ComicFury will only accept backup files that have:
68
+ # - A valid XML declaration using double quotes
69
+ # – A comment as per below
70
+ # – Tab indentation
71
+ doc = REXML::Document.new(nil, prologue_quote: :quote)
72
+ doc.add REXML::XMLDecl.new REXML::XMLDecl::DEFAULT_VERSION, REXML::XMLDecl::DEFAULT_ENCODING
73
+ doc.add REXML::Comment.new 'This is a ComicFury layout backup, use the import layout function to restore this to a webcomic site. You can access this as follows: Go to your Webcomic Management, click "Edit Layout", then in the Box labelled "Useful", click "Restore Layout Backup"'
74
+ doc.add layout
75
+
76
+ # Pretty print, but *always* make text nodes take up a single line, no
77
+ # matter how long they are
78
+ formatter = REXML::Formatters::Pretty.new(1)
79
+ formatter.compact = true
80
+ formatter.width = Float::INFINITY
81
+
82
+ # Replace the space indentation with tab indentation
83
+ buf = StringIO.new
84
+ formatter.write(doc, buf)
85
+ buf.string.each_line do |line|
86
+ dest << line.gsub(/^ +/) {|sp| "\t" * sp.size }
87
+ end
88
+ end
89
+ end
90
+
91
+ if __FILE__ == $0
92
+ case ARGV.shift
93
+ when 'pack'
94
+ html_srcdir, css_srcdir, *dest = ARGV
95
+ RageRender.pack(html_srcdir, css_srcdir, dest.any? ? File.open(dest.first, 'w') : $stdout)
96
+ when 'unpack'
97
+ src, html_dest, css_dest = ARGV
98
+ RageRender.unpack(src == '-' ? $stdin : File.open(src, 'r'), html_dest, css_dest)
99
+ else
100
+ raise <<~USAGE
101
+ Usage: pack html_srcdir css_srcdir dest
102
+ Usage: unpack src html_dest css_dest
103
+ USAGE
104
+ end
105
+ end
@@ -8,6 +8,7 @@ require_relative 'pipettes'
8
8
  # chapter pages because they are not "pages"
9
9
  Jekyll::Hooks.register :pages, :pre_render do |page, payload|
10
10
  if page.data['layout'] == 'archive'
11
+ RageRender::Pipettes.clean_payload payload
11
12
  payload.merge! RageRender::ArchiveDrop.new(page).to_liquid
12
13
  end
13
14
  end
@@ -4,6 +4,7 @@ require_relative '../date_formats'
4
4
  require_relative 'pipettes'
5
5
 
6
6
  Jekyll::Hooks.register :posts, :pre_render do |post, payload|
7
+ RageRender::Pipettes.clean_payload payload
7
8
  payload.merge! RageRender::BlogDrop.new(post).to_liquid
8
9
  end
9
10
 
@@ -8,6 +8,7 @@ require_relative 'pipettes'
8
8
  # Pass the right variables to blog archive pages.
9
9
  Jekyll::Hooks.register :pages, :pre_render do |page, payload|
10
10
  if page.data['layout'] == 'blog-archive'
11
+ RageRender::Pipettes.clean_payload payload
11
12
  payload.merge! RageRender::BlogArchiveDrop.new(page).to_liquid
12
13
  end
13
14
  end
@@ -21,6 +21,7 @@ Jekyll::Hooks.register :site, :after_init do |site|
21
21
  end
22
22
 
23
23
  Jekyll::Hooks.register :chapters, :pre_render do |chapter, payload|
24
+ RageRender::Pipettes.clean_payload payload
24
25
  payload.merge! RageRender::ChapterDrop.new(chapter).to_liquid
25
26
  payload.merge! RageRender::ArchiveDrop.new(chapter).to_liquid
26
27
  end
@@ -80,16 +81,13 @@ module RageRender
80
81
  extend Forwardable
81
82
 
82
83
  def_data_delegator :description, :chapterdescription
84
+ def_data_delegator :image, :image
83
85
  def_delegator :@obj, :url, :chapterarchiveurl
84
86
 
85
87
  def chaptername
86
88
  escape @obj.data['title']
87
89
  end
88
90
 
89
- def cover
90
- cover_obj.url
91
- end
92
-
93
91
  def cover_width_small
94
92
  if (cover_height.to_f / COVER_MAX_HEIGHT) > (cover_width.to_f / COVER_MAX_WIDTH)
95
93
  (cover_height_small * cover_width) / cover_height
@@ -117,24 +115,15 @@ module RageRender
117
115
  end
118
116
 
119
117
  private
120
- def cover_width
121
- cover_obj.data['width'] ||= Dimensions.width cover_obj.path
122
- end
123
-
124
- def cover_height
125
- cover_obj.data['height'] ||= Dimensions.height cover_obj.path
126
- end
127
-
128
- def cover_obj
129
- @cover_obj ||= @obj.site.static_files.detect {|f| f.relative_path == cover_relative_path }
130
- end
131
-
132
- def cover_relative_path
133
- Pathname.new('/').join(@obj.data['image']).to_s
134
- end
118
+ def_image_metadata :image
135
119
 
136
120
  def first_comic
137
121
  @obj.site.collections['comics'].docs.select {|c| c.data['chapter'] == @obj.data['slug'] }.first
138
122
  end
123
+
124
+ public
125
+ alias cover image_url
126
+ alias cover_height image_height
127
+ alias cover_width image_width
139
128
  end
140
129
  end
@@ -5,6 +5,7 @@ require_relative '../date_formats'
5
5
  require_relative 'pipettes'
6
6
 
7
7
  Jekyll::Hooks.register :comics, :pre_render do |page, payload|
8
+ RageRender::Pipettes.clean_payload payload
8
9
  payload.merge! RageRender::ComicDrop.new(page).to_liquid
9
10
  end
10
11
 
@@ -82,6 +83,7 @@ module RageRender
82
83
 
83
84
  delegate_method_as :id, :comicid
84
85
  def_delegator :@obj, :url, :comicurl
86
+ def_delegator :@obj, :url, :permalink
85
87
  data_delegator 'rating'
86
88
  data_delegator 'votecount'
87
89
 
@@ -2,6 +2,7 @@ require_relative 'pipettes'
2
2
 
3
3
  Jekyll::Hooks.register :pages, :pre_render do |page, payload|
4
4
  if page.data['layout'] == 'error-page'
5
+ RageRender::Pipettes.clean_payload payload
5
6
  payload.merge! RageRender::ErrorDrop.new(page).to_liquid
6
7
  end
7
8
  end
@@ -6,6 +6,7 @@ require_relative 'blog_archive'
6
6
  # Pass the right variables to overview pages.
7
7
  Jekyll::Hooks.register :pages, :pre_render do |page, payload|
8
8
  if page.data['layout'] == 'overview'
9
+ RageRender::Pipettes.clean_payload payload
9
10
  payload.merge! RageRender::ComicDrop.new(page.site.collections['comics'].docs.last).to_liquid
10
11
  payload.merge! RageRender::OverviewDrop.new(page).to_liquid
11
12
  end
@@ -1,8 +1,16 @@
1
1
  # Pipettes help you make drops.
2
2
  require 'cgi'
3
+ require 'dimensions'
3
4
 
4
5
  module RageRender
5
6
  module Pipettes
7
+ def self.clean_payload payload
8
+ Jekyll.logger.debug("Cleaning payload")
9
+ sets = Jekyll::Drops::DocumentDrop.subclasses.map(&:invokable_methods)
10
+ methods = sets.reduce(Set.new) {|s,acc| acc.merge(s)} - Set.new(Jekyll::Drops::DocumentDrop.invokable_methods)
11
+ payload.send(:fallback_data).delete_if {|k| methods.include? k}
12
+ end
13
+
6
14
  def def_data_delegator key, aliaz
7
15
  define_method(aliaz.to_sym) do
8
16
  @obj.data[key.to_s]
@@ -1,5 +1,6 @@
1
1
  Jekyll::Hooks.register :pages, :pre_render do |page, payload|
2
2
  if page.data['layout'] == 'search'
3
+ RageRender::Pipettes.clean_payload payload
3
4
  payload.merge! RageRender::SearchDrop.new(page).to_liquid
4
5
  end
5
6
  end
@@ -1,11 +1,11 @@
1
1
  require 'etc'
2
2
  require 'stringio'
3
3
  require 'jekyll'
4
- require 'dimensions'
5
4
  require_relative 'language'
6
5
  require_relative 'functions'
7
6
  require_relative 'to_liquid'
8
7
  require_relative 'date_formats'
8
+ require_relative 'cflxml'
9
9
  require_relative 'jekyll/archive'
10
10
  require_relative 'jekyll/blog'
11
11
  require_relative 'jekyll/blog_archive'
@@ -17,6 +17,39 @@ require_relative 'jekyll/search'
17
17
  require_relative 'jekyll/pipettes'
18
18
  require_relative 'jekyll/setup_collection'
19
19
 
20
+ module RageRender
21
+ class CFLXMLCommands < Jekyll::Command
22
+ class << self
23
+ def init_with_program(jekyll)
24
+ jekyll.command :pack do |pack|
25
+ pack.syntax 'pack'
26
+ pack.description 'Create a ComicFury layout backup from this site'
27
+ pack.action do |args, options|
28
+ config = configuration_from_options(options)
29
+ filename = "#{(config['title'] || File.basename(config['source']))} #{Time.now.to_s}.cflxml"
30
+ puts "Outputting backup file #{filename}"
31
+ File.open(filename, 'w') do |file|
32
+ RageRender.pack config['layouts_dir'], config['source'], file
33
+ end
34
+ end
35
+ end
36
+
37
+ jekyll.command :unpack do |unpack|
38
+ unpack.syntax 'unpack <file>'
39
+ unpack.description 'Overwrite HTML and CSS from a ComicFury layout backup'
40
+ unpack.action do |args, options|
41
+ raise ArgumentError, 'unpack requires one cflxml file' unless args.one?
42
+ config = configuration_from_options(options)
43
+ File.open(args.first, 'r') do |file|
44
+ RageRender.unpack file, config['layouts_dir'], config['source']
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+
20
53
  Jekyll::Hooks.register :site, :after_init do |site|
21
54
  # This is obviously quite naughty for many reasons,
22
55
  # but it's the only way to get the theme selected
@@ -84,6 +117,7 @@ Jekyll::Hooks.register :documents, :pre_render do |doc, payload|
84
117
  end
85
118
 
86
119
  Jekyll::Hooks.register :pages, :pre_render do |page, payload|
120
+ RageRender::Pipettes.clean_payload payload
87
121
  payload.merge! RageRender::WebcomicDrop.new(page).to_liquid
88
122
  end
89
123
 
@@ -169,8 +203,6 @@ class RageRender::WebcomicDrop < Jekyll::Drops::Drop
169
203
  HTML
170
204
  end
171
205
 
172
- delegate_method_as :url, :permalink
173
-
174
206
  def pagetitle
175
207
  escape @obj.data['title']
176
208
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ragerender
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Worthington
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-09-06 00:00:00.000000000 Z
11
+ date: 2025-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rsec
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rexml
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -185,8 +199,15 @@ description: |-
185
199
 
186
200
  If you want to use your own layout code, then create a <tt>_layouts</tt>
187
201
  directory and put the contents of each of your ComicFury layout tabs in there,
188
- and then put your CSS in the main folder. You should end up with a full set of
189
- files like:
202
+ and then put your CSS in the main folder.
203
+
204
+ The easiest way is to go to your Webcomic Management, click "Edit Layout", then
205
+ in the box labelled "Useful", click "Download Layout Backup". Pass this file to
206
+ RageRender, which will <tt>unpack</tt> it for you:
207
+
208
+ bundle exec jekyll unpack mycomic-2025-09-13.cflxml
209
+
210
+ You should end up with a full set of files like:
190
211
 
191
212
  _layouts
192
213
  archive.html
@@ -204,7 +225,7 @@ description: |-
204
225
 
205
226
  === Adding blogs
206
227
 
207
- Add your blogs into a folder called `_posts`:
228
+ Add your blogs into a folder called <tt>_posts</tt>:
208
229
 
209
230
  cat _posts/2025-05-29-my-new-comic.md
210
231
  Hey guys, welcome to my new comic! It's gonna be so sick!
@@ -271,6 +292,16 @@ description: |-
271
292
  - anything else will display the extra page that has the matching
272
293
  <tt>slug</tt> in its Front Matter
273
294
 
295
+ === Putting changes on ComicFury
296
+
297
+ Once you're done making changes, you can <tt>pack</tt> your layout:
298
+
299
+ bundle exec jekyll pack
300
+
301
+ The resulting file can be uploaded to ComicFury by going to your Webcomic
302
+ Management, clicking "Edit Layout", then in the box labelled "Useful", click
303
+ "Restore Layout Backup".
304
+
274
305
  === Stuff that doesn't work
275
306
 
276
307
  Here is a probably incomplete list of things you can expect to be different
@@ -322,6 +353,7 @@ files:
322
353
  - assets/overview.html
323
354
  - assets/search.html
324
355
  - lib/ragerender.rb
356
+ - lib/ragerender/cflxml.rb
325
357
  - lib/ragerender/date_formats.rb
326
358
  - lib/ragerender/functions.rb
327
359
  - lib/ragerender/jekyll.rb