zine 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +171 -0
- data/README.md +27 -8
- data/lib/zine.rb +37 -77
- data/lib/zine/cli.rb +16 -0
- data/lib/zine/page.rb +8 -3
- data/lib/zine/post.rb +17 -6
- data/lib/zine/posts_and_headlines.rb +202 -0
- data/lib/zine/server.rb +36 -4
- data/lib/zine/skeleton/source/assets/webicon-rss-m.png +0 -0
- data/lib/zine/skeleton/source/assets/webicon-rss.svg +18 -0
- data/lib/zine/skeleton/source/assets/webicon-twitter-m.png +0 -0
- data/lib/zine/skeleton/source/assets/webicon-twitter.svg +24 -0
- data/lib/zine/skeleton/source/screen.css +1 -1
- data/lib/zine/skeleton/source/styles/screen.scss +291 -0
- data/lib/zine/skeleton/source/templates/footer_partial.erb +16 -4
- data/lib/zine/skeleton/source/templates/home.erb +3 -1
- data/lib/zine/skeleton/zine.yaml +38 -25
- data/lib/zine/style.rb +19 -0
- data/lib/zine/tag.rb +1 -0
- data/lib/zine/upload.rb +161 -0
- data/lib/zine/version.rb +1 -1
- data/lib/zine/watcher.rb +88 -0
- metadata +115 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b554bb3eeda3a4ddc886a4b0c3c15ac6e7626215
|
4
|
+
data.tar.gz: 68f1a7d4d8684ac52ff79f3f617ccf68df346ea3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 276a5fc7b22ea376ec58c8ee05934ea8b31bbc015c319d8ec71dea4d4ba58758fe41044d7b3d7154198db84c0b72f4c518e0f871e3beefbb0d37ad10f8c5b26a
|
7
|
+
data.tar.gz: 9113788bb9fc2f0d4596782b271fb8a9c8a2f1c9bac8b9d3c230e9b974bc105d0d522cb5ce6eb5873de4164a83788e0af54c0b0d9a4f53f187946ee26bac15f2
|
data/CHANGELOG.md
CHANGED
@@ -298,3 +298,174 @@ Was listening in on RubyConf_au going on in the background on Twitter all day --
|
|
298
298
|
|
299
299
|
1. [Repo](https://github.com/mikekreuzer/zine)
|
300
300
|
2. [Gem](https://rubygems.org/gems/zine)
|
301
|
+
3. [Tweet](https://twitter.com/mikekreuzer/status/829677797241090050)
|
302
|
+
|
303
|
+
### Day 18: February 10, 2017
|
304
|
+
|
305
|
+
**Today's Progress**:
|
306
|
+
|
307
|
+
- PostsAndHeadlines class extracted from Site
|
308
|
+
- CSS preprocessing with Sass added (LibSass and SassC)
|
309
|
+
- messing about with styles
|
310
|
+
- some minor refactoring & doc work
|
311
|
+
|
312
|
+
**Thoughts:**
|
313
|
+
|
314
|
+
Now well behind with testing, will need to concentrate on that soon.
|
315
|
+
|
316
|
+
**Links to work**
|
317
|
+
|
318
|
+
1. [Repo](https://github.com/mikekreuzer/zine)
|
319
|
+
2. [Tweet](https://twitter.com/mikekreuzer/status/830034964393529345)
|
320
|
+
|
321
|
+
### Day 19: February 11, 2017
|
322
|
+
|
323
|
+
**Today's Progress**:
|
324
|
+
|
325
|
+
- watching the Markdown files for changes with Listener
|
326
|
+
- started on incremental builds
|
327
|
+
|
328
|
+
**Thoughts:**
|
329
|
+
|
330
|
+
A productive evening, despite spending a lot of time breaking my brain trying to work around the Guard gem. Incremental builds are on the way (deleted files I'm still to do), then on to live reloads and SFTP uploads (I think).
|
331
|
+
|
332
|
+
**Links to work**
|
333
|
+
|
334
|
+
1. [Repo](https://github.com/mikekreuzer/zine)
|
335
|
+
2. [Tweet](https://twitter.com/mikekreuzer/status/830414957745369088)
|
336
|
+
|
337
|
+
### Day 20: February 12, 2017
|
338
|
+
|
339
|
+
**Today's Progress**:
|
340
|
+
|
341
|
+
- added SFTP uploads of the files that changed, which includes (and it warrants a line)...
|
342
|
+
- my own homegrown (& no doubt pretty rough) SFTP version of mkdir_p
|
343
|
+
- incremental builds handle Markdown file deletions now
|
344
|
+
- rearranged the zine.yaml preferences file to accommodate file transfers
|
345
|
+
- added footer links via zine.yaml, tweaking the style & templates a little
|
346
|
+
|
347
|
+
**Thoughts:**
|
348
|
+
|
349
|
+
Writing the remote version of mkdir_p feels good, even if the number of edge cases I'd be missing must be huge. I'm going to drop live reloads for now, too much JavaScript jiggery pokery. It's been almost been 3 weeks... Need to optimise the tag rebuilds & uploads, probably. And tests...
|
350
|
+
|
351
|
+
**Links to work**
|
352
|
+
|
353
|
+
1. [Repo](https://github.com/mikekreuzer/zine)
|
354
|
+
2. [Tweet](https://twitter.com/mikekreuzer/status/830762418485633024)
|
355
|
+
|
356
|
+
### Day 21: February 13, 2017
|
357
|
+
|
358
|
+
**Today's Progress**:
|
359
|
+
|
360
|
+
- fixed some hard wiring from yesterday
|
361
|
+
|
362
|
+
**Thoughts:**
|
363
|
+
|
364
|
+
Three weeks! And it looks like my router is dying. Sigh. Not much time for programming tonight.
|
365
|
+
|
366
|
+
Need to adjust the ordering of the build & file watching, to catch the initial build. Want to consolidate the mkdir requests before I send duplicates over the wire, as well as the tag rebuilds.
|
367
|
+
|
368
|
+
**Links to work**
|
369
|
+
|
370
|
+
1. [Repo](https://github.com/mikekreuzer/zine)
|
371
|
+
2. [Tweet](https://twitter.com/mikekreuzer/status/831116561515638785)
|
372
|
+
|
373
|
+
### Day 22: February 14, 2017
|
374
|
+
|
375
|
+
**Today's Progress**:
|
376
|
+
|
377
|
+
- slogging it out (so far unsuccessfully) consolidating upload paths
|
378
|
+
|
379
|
+
**Thoughts:**
|
380
|
+
|
381
|
+
Valentine's Day special. Router seems to have righted itself for the moment. Slow going.
|
382
|
+
|
383
|
+
**Links to work**
|
384
|
+
|
385
|
+
1. [Tweet](https://twitter.com/mikekreuzer/status/831478367174037506)
|
386
|
+
|
387
|
+
### Day 23: February 15, 2017
|
388
|
+
|
389
|
+
**Today's Progress**:
|
390
|
+
|
391
|
+
- consolidate upload paths instead of sending duplicate mkdir requests via SFTP
|
392
|
+
|
393
|
+
**Thoughts:**
|
394
|
+
|
395
|
+
Was looking the wrong way - was looking at a folder's children, when it's its parents that matter when removing duplicate mkdir calls.
|
396
|
+
|
397
|
+
**Links to work**
|
398
|
+
|
399
|
+
1. [Repo](https://github.com/mikekreuzer/zine)
|
400
|
+
2. [Tweet](https://twitter.com/mikekreuzer/status/831859701411307520)
|
401
|
+
|
402
|
+
### Day 24: February 16, 2017
|
403
|
+
|
404
|
+
**Today's Progress**:
|
405
|
+
|
406
|
+
- file watcher extended to cover non Markdown files
|
407
|
+
|
408
|
+
**Thoughts:**
|
409
|
+
|
410
|
+
A brief session after a few slugfest-y nights
|
411
|
+
|
412
|
+
**Links to work**
|
413
|
+
|
414
|
+
1. [Repo](https://github.com/mikekreuzer/zine)
|
415
|
+
2. [Tweet](https://twitter.com/mikekreuzer/status/832174649492463616)
|
416
|
+
|
417
|
+
### Day 25: February 17, 2017
|
418
|
+
|
419
|
+
**Today's Progress**:
|
420
|
+
|
421
|
+
- testing real world data with my blog
|
422
|
+
|
423
|
+
**Thoughts:**
|
424
|
+
|
425
|
+
Exciting, looking at things I need to clean up to make this workable...
|
426
|
+
|
427
|
+
**Links to work**
|
428
|
+
|
429
|
+
1. [Repo](https://github.com/mikekreuzer/zine)
|
430
|
+
2. [Tweet](https://twitter.com/mikekreuzer/status/832575013769187330)
|
431
|
+
|
432
|
+
### Day 26: February 18, 2017
|
433
|
+
|
434
|
+
**Today's Progress**:
|
435
|
+
|
436
|
+
- start the file watcher earlier to catch the initial build in a full build,
|
437
|
+
meant everything was a change so everything's uploaded...
|
438
|
+
- added an incremental build that skipped the initial writes to fix that
|
439
|
+
- linked homepage post titles to posts
|
440
|
+
|
441
|
+
**Thoughts:**
|
442
|
+
|
443
|
+
Have to move some local directory writes, then I think that's probably v0.3.0. Tomorrow. Would mean uploads took a week by themselves.
|
444
|
+
|
445
|
+
**Links to work**
|
446
|
+
|
447
|
+
1. [Repo](https://github.com/mikekreuzer/zine)
|
448
|
+
2. [Tweet](https://twitter.com/mikekreuzer/status/832941448307748864)
|
449
|
+
|
450
|
+
## v0.3.0
|
451
|
+
|
452
|
+
### Day 27: February 19, 2017
|
453
|
+
|
454
|
+
**Today's Progress**:
|
455
|
+
|
456
|
+
- moved the local post directory creation to the write method
|
457
|
+
- added a minimalist version of building additional posts while build is running
|
458
|
+
- v0.3.0
|
459
|
+
- and tonight Zine's in use in the wild
|
460
|
+
|
461
|
+
**Thoughts:**
|
462
|
+
|
463
|
+
Happy to call this a new pre release version, and also happy enough to push Zine into production use. My first 'Built with Zine' blog post's going up tonight.
|
464
|
+
|
465
|
+
TODO: A 'known issue' I'll deal with later: adding a post file while build is running will generate a post, but the posts & tags won't be re-ordered by date. Adding new posts during a build's not how my blogging workflow works, but it's a bug so I'll fix it.
|
466
|
+
|
467
|
+
**Links to work**
|
468
|
+
|
469
|
+
1. [Repo](https://github.com/mikekreuzer/zine)
|
470
|
+
2. [Gem](https://rubygems.org/gems/zine)
|
471
|
+
3. [Blog](https://mikekreuzer.com)
|
data/README.md
CHANGED
@@ -9,6 +9,13 @@ These are the very early days of zine, expect breaking changes.
|
|
9
9
|
|
10
10
|
Written in a #100DaysOfCode challenge -- my [progress log's here](CHANGELOG.md). Despite the [proliferation in these things][engine_list] (450!) I still find it more comfortable to use my own tools.
|
11
11
|
|
12
|
+
Distinguishing features include:
|
13
|
+
|
14
|
+
- ERB templates
|
15
|
+
- Sass stylesheets
|
16
|
+
- fast incremental builds
|
17
|
+
- SFTP file uploads
|
18
|
+
|
12
19
|
Presented here in the hope it's of use to someone else too.
|
13
20
|
|
14
21
|
## Installation
|
@@ -19,13 +26,13 @@ Install the gem.
|
|
19
26
|
$ gem install zine
|
20
27
|
```
|
21
28
|
|
22
|
-
|
29
|
+
To generate a new site scaffold, cd to a new folder and:
|
23
30
|
|
24
31
|
```shell
|
25
32
|
$ zine site
|
26
33
|
```
|
27
34
|
|
28
|
-
Then update your site's name, your name & so on in zine.yaml.
|
35
|
+
Then update your site's name, your name & so on in zine.yaml. Pay particular care to the Upload section, if you want to use Zine as an SFTP uploader to deploy files that've changed, you'll need to edit this section to include your remote server's details, as well as the path to a YAML file with your username & password (nil for that if you're using SSH without a password).
|
29
36
|
|
30
37
|
## Day to day usage
|
31
38
|
|
@@ -35,31 +42,43 @@ To set up a new blog post:
|
|
35
42
|
$ zine post 'Your chosen title'
|
36
43
|
```
|
37
44
|
|
38
|
-
Your new post will have some fields set up in the YAML front matter, feel free to edit them too.
|
45
|
+
Your new post will have some fields set up in the YAML front matter, feel free to edit them too. Markdown files you create outside of the posts folder will be rendered into HTML in the same relative position in the build folder.
|
39
46
|
|
40
47
|
Once you're done writing, build your new site:
|
41
48
|
|
42
49
|
```shell
|
43
|
-
$ zine build
|
50
|
+
$ zine build # or zine force
|
44
51
|
```
|
45
52
|
|
53
|
+
Build only writes files for things that have changed while it's running, so the first time you build your site you should use force -- force writes all of the files (& so also uploads them all too if you've set up uploads).
|
54
|
+
|
55
|
+
## Design & development
|
56
|
+
|
57
|
+
Typing <code>zine style</code> will render the Sass file into CSS. The templates are all editable, as are the files' names, which you can change in the options file.
|
58
|
+
|
46
59
|
### Halp!
|
47
60
|
|
48
|
-
To see the options available:
|
61
|
+
To see the options available type zine & hit enter:
|
49
62
|
|
50
63
|
```shell
|
51
64
|
$ zine
|
65
|
+
Commands:
|
66
|
+
zine build # Build the site
|
67
|
+
zine force # Build the site, forcing writes & uploads
|
68
|
+
zine help [COMMAND] # Describe available commands or one specific command
|
69
|
+
zine nuke # Delete the build folder
|
70
|
+
zine post TITLE # Create the file for a new blog post, titled TITLE
|
71
|
+
zine site # Create the skeleton of a new site (overwriting files)
|
72
|
+
zine style # Build the site's stylesheet
|
73
|
+
zine version # Show the version number
|
52
74
|
```
|
53
75
|
|
54
76
|
### Up next
|
55
77
|
|
56
78
|
This is only a first cut at this gem, the stuff I considered a (barely) minimum viable product. Up next are:
|
57
79
|
|
58
|
-
- CSS preprocessing
|
59
|
-
- file watching
|
60
80
|
- migration scripts from eg Jekyll? Maybe.
|
61
81
|
- Apple News
|
62
|
-
- SSH uploads, as well as
|
63
82
|
- much refactoring
|
64
83
|
- docs
|
65
84
|
- tests, lots of tests
|
data/lib/zine.rb
CHANGED
@@ -1,12 +1,9 @@
|
|
1
1
|
require 'erb'
|
2
2
|
require 'rainbow'
|
3
|
-
require 'zine/data_page'
|
4
3
|
require 'zine/page'
|
5
|
-
require 'zine/
|
4
|
+
require 'zine/posts_and_headlines'
|
6
5
|
require 'zine/server'
|
7
|
-
require 'zine/tag'
|
8
6
|
require 'zine/templates'
|
9
|
-
require 'zine/version'
|
10
7
|
|
11
8
|
module Zine
|
12
9
|
# the site
|
@@ -14,11 +11,9 @@ module Zine
|
|
14
11
|
attr_reader :options
|
15
12
|
|
16
13
|
def initialize
|
17
|
-
@post_array = []
|
18
14
|
@templates_by_name = {}
|
19
15
|
init_options
|
20
16
|
clean_option_paths
|
21
|
-
init_templates
|
22
17
|
end
|
23
18
|
|
24
19
|
def init_options
|
@@ -38,12 +33,21 @@ module Zine
|
|
38
33
|
end
|
39
34
|
|
40
35
|
def build_site
|
41
|
-
|
42
|
-
|
43
|
-
|
36
|
+
init_templates
|
37
|
+
FileUtils.mkdir_p @options['directories']['build']
|
38
|
+
# posts_and_guard is { posts: @post_array, guard: @guard }
|
39
|
+
posts_and_guard = posts_and_headlines_without_writing
|
40
|
+
preview posts_and_guard
|
41
|
+
end
|
42
|
+
|
43
|
+
def build_site_forcing_writes
|
44
|
+
init_templates
|
45
|
+
FileUtils.mkdir_p @options['directories']['build']
|
46
|
+
# posts_and_guard is { posts: @post_array, guard: @guard }
|
47
|
+
posts_and_guard = write_posts_and_headlines
|
44
48
|
housekeeping_copy
|
45
49
|
write_other_markdown_pages
|
46
|
-
preview
|
50
|
+
preview posts_and_guard
|
47
51
|
end
|
48
52
|
|
49
53
|
def clean_option_paths
|
@@ -61,7 +65,7 @@ module Zine
|
|
61
65
|
possible = Dir.glob(search, File::FNM_DOTMATCH).reject do |found|
|
62
66
|
found =~ /^.+\.md$|^.+\.erb$|^\.DS_Store$|^\.$|^\.\.$'/ ||
|
63
67
|
File.directory?(found) || found[directories['posts']] ||
|
64
|
-
found[directories['templates']]
|
68
|
+
found[directories['templates']] || found[directories['styles']]
|
65
69
|
end
|
66
70
|
possible.each do |file|
|
67
71
|
dir = Pathname(File.dirname(file)).relative_path_from(Pathname(src_dir))
|
@@ -84,88 +88,44 @@ module Zine
|
|
84
88
|
)
|
85
89
|
end
|
86
90
|
|
87
|
-
|
88
|
-
|
91
|
+
# Generate data without writing files (for incremnetal builds & uploads)
|
92
|
+
# returns posts & guard to use during edits under preview
|
93
|
+
def posts_and_headlines_without_writing
|
94
|
+
posts = Zine::PostsAndHeadlines.new self, @options
|
95
|
+
posts.writeless
|
89
96
|
end
|
90
97
|
|
91
|
-
def
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
@post_array << Zine::Post.new(file,
|
96
|
-
make_template_bundle(post_name),
|
97
|
-
@options)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def sort_posts_by_date
|
102
|
-
@post_array.sort_by! do |post|
|
103
|
-
post.formatted_data.page[:date_rfc3339]
|
104
|
-
end.reverse!
|
105
|
-
@post_array.freeze
|
98
|
+
def preview(posts_and_guard)
|
99
|
+
guard = posts_and_guard[:guard]
|
100
|
+
Server.new @options['directories']['build'], @options['upload'],
|
101
|
+
guard.delete_array, guard.upload_array
|
106
102
|
end
|
107
103
|
|
108
|
-
def
|
109
|
-
dir =
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
number: options['num_items_on_home'], suffix: '.html',
|
117
|
-
template_name: templates['home'], title: 'Home' },
|
118
|
-
{ build_dir: dir, name: 'rss',
|
119
|
-
number: options['number_items_in_RSS'], suffix: '.xml',
|
120
|
-
template_name: templates['rss'], title: '' }]
|
121
|
-
end
|
122
|
-
|
123
|
-
def wrangle_headlines
|
124
|
-
headline_pages.each do |page|
|
125
|
-
write_headline page
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def write_headline(page)
|
130
|
-
data = page
|
131
|
-
data[:post_array] = []
|
132
|
-
@post_array.first(page[:number]).each do |post|
|
133
|
-
post_data = post.formatted_data
|
134
|
-
data[:post_array] << { page: post_data.page, html: post_data.html,
|
135
|
-
uri: post_data.uri }
|
136
|
-
end
|
137
|
-
data_page = DataPage.new(data, make_template_bundle(data[:template_name]),
|
138
|
-
@options, data[:suffix])
|
139
|
-
data_page.write
|
104
|
+
def write_markdown(default_name, src_dir, file)
|
105
|
+
dir = Pathname(File.dirname(file)).relative_path_from(Pathname(src_dir))
|
106
|
+
file_name = "#{File.basename(file, '.*')}.html"
|
107
|
+
dest = File.join @options['directories']['build'], dir
|
108
|
+
FileUtils.mkdir_p dest
|
109
|
+
page = Zine::Page.new(file, File.join(dest, file_name),
|
110
|
+
make_template_bundle(default_name), @options)
|
111
|
+
page.process
|
140
112
|
end
|
141
113
|
|
114
|
+
# TODO: structure in common with housekeeping_copy
|
142
115
|
def write_other_markdown_pages
|
143
116
|
dir_options = @options['directories']
|
144
117
|
src_dir = dir_options['source']
|
145
118
|
search = File.join src_dir, '**', '*.md'
|
146
119
|
default_name = @options['templates']['default']
|
147
120
|
Dir[search].reject { |found| found[dir_options['posts']] }.each do |file|
|
148
|
-
|
149
|
-
file_name = "#{File.basename(file, '.*')}.html"
|
150
|
-
dest = File.join dir_options['build'], dir
|
151
|
-
FileUtils.mkdir_p dest
|
152
|
-
page = Zine::Page.new(file, File.join(dest, file_name),
|
153
|
-
make_template_bundle(default_name), @options)
|
154
|
-
page.process
|
121
|
+
write_markdown(default_name, src_dir, file)
|
155
122
|
end
|
156
123
|
end
|
157
124
|
|
125
|
+
# returns posts & guard to use during edits under preview
|
158
126
|
def write_posts_and_headlines
|
159
|
-
|
160
|
-
|
161
|
-
tags_by_post << post.process
|
162
|
-
end
|
163
|
-
tag_name = @options['templates']['tag']
|
164
|
-
tag_index_name = @options['templates']['tag_index']
|
165
|
-
tags = Zine::Tag.new tags_by_post, make_template_bundle(tag_name),
|
166
|
-
make_template_bundle(tag_index_name), @options
|
167
|
-
tags.write_tags
|
168
|
-
wrangle_headlines
|
127
|
+
posts = Zine::PostsAndHeadlines.new self, @options
|
128
|
+
posts.write
|
169
129
|
end
|
170
130
|
end
|
171
131
|
end
|
data/lib/zine/cli.rb
CHANGED
@@ -3,6 +3,7 @@ require 'rainbow'
|
|
3
3
|
require 'time'
|
4
4
|
require 'yaml'
|
5
5
|
require 'zine'
|
6
|
+
require 'zine/style'
|
6
7
|
require 'zine/version'
|
7
8
|
|
8
9
|
module Zine
|
@@ -23,6 +24,13 @@ module Zine
|
|
23
24
|
puts Rainbow('Site built').green
|
24
25
|
end
|
25
26
|
|
27
|
+
desc 'force', 'Build the site, forcing writes & uploads'
|
28
|
+
def force
|
29
|
+
init_site
|
30
|
+
@site.build_site_forcing_writes
|
31
|
+
puts Rainbow('Site built').green
|
32
|
+
end
|
33
|
+
|
26
34
|
desc 'nuke', 'Delete the build folder'
|
27
35
|
def nuke
|
28
36
|
init_site
|
@@ -50,6 +58,14 @@ module Zine
|
|
50
58
|
puts Rainbow('New skeleton site created').green
|
51
59
|
end
|
52
60
|
|
61
|
+
desc 'style', 'Build the site\'s stylesheet'
|
62
|
+
def style
|
63
|
+
init_site
|
64
|
+
style = Zine::Style.new(@site.options['directories'])
|
65
|
+
style.process
|
66
|
+
puts Rainbow('Stylesheet rendered').green
|
67
|
+
end
|
68
|
+
|
53
69
|
desc 'version', 'Show the version number'
|
54
70
|
def version
|
55
71
|
puts VERSION
|