runeblog 0.2.72 → 0.2.73

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
  SHA256:
3
- metadata.gz: a248b5068862971d08b4a7bf8ee2a9d28e243134e1447821de1c6f34144a614a
4
- data.tar.gz: 289722c7383bd6940581277fe6b729c63c5de819702deaa59388811f7969d5f1
3
+ metadata.gz: 0afccf0c622078eba670e387c4fec271552c9b2d289c25b1f325a266d94da6c7
4
+ data.tar.gz: 3cea7d0e10b8e393d2845b10c4d466f54bbfc92f1ea326eec4ee42ad8fba3927
5
5
  SHA512:
6
- metadata.gz: 3ebed576737715de06b58a472974f31f078de11dc98126fb55207b7fe7931095031216185676e116815d4d102cd83e3a8fd06e78622cd5894cbd29419133436d
7
- data.tar.gz: 3dabb68f2519418c09a64e916bb3fee96afac35e1d8e89aab56386e3a204460621f9d60fd96fe8eaa2bf2497f7417615b099cf1147557224e6560f475341174e
6
+ metadata.gz: e69baf6404c61da8028502b554008a663ec405c359707d9a33f103dd47f17b0e9a00482f09a32cb2e52c5457fe9904177db067b2592b7021ef1ddf0a5c15b698
7
+ data.tar.gz: d6942079ebdcb48d948b938bf06377caa55eabe7ea3b4de6566ed0586b83920e6c51fee272d7e35e38cb7f00e812a20cc3b0a2c66252ca03e66bcf6cc5df9337
@@ -1,7 +1,6 @@
1
1
  require 'runeblog_version'
2
2
  require 'fileutils'
3
3
 
4
- #require 'pathmagic'
5
4
  require 'xlate'
6
5
 
7
6
  module RuneBlog::Helpers
@@ -20,38 +19,85 @@ module RuneBlog::Helpers
20
19
  puts " Failed: #{cmd} - from #{caller[0]}" unless rc
21
20
  end
22
21
 
22
+ def get_repo_config
23
+ log!(enter: __method__, level: 3)
24
+ @editor = File.read(".blogs/data/EDITOR").chomp
25
+ @current_view = File.read(".blogs/data/VIEW").chomp
26
+ @root = File.read(".blogs/data/ROOT").chomp
27
+ rescue => err
28
+ puts "Can't read config: #{err}"
29
+ puts err.backtrace.join("\n")
30
+ puts "dir = #{Dir.pwd}"
31
+ end
32
+
23
33
  def copy_data(tag, dest)
24
- data = RuneBlog::Path/"../data" # files kept inside gem
34
+ data = RuneBlog::Path + "/../data" # files kept inside gem
25
35
  case tag
26
36
  when :config; files = %w[ROOT VIEW EDITOR]
27
37
  end
28
- files.each {|file| copy(data/file, dest) }
38
+ files.each {|file| copy(data + "/" + file, dest) }
29
39
  end
30
40
 
31
- def read_config
32
- log!(enter: __method__, level: 3)
33
- @editor = File.read("data/EDITOR").chomp
34
- @current_view = File.read("data/VIEW").chomp
35
- @root = File.read(".blogs/data/ROOT").chomp
41
+ def read_config(file, *syms)
42
+ log!(enter: __method__, args: [file, *syms], level: 3)
43
+ lines = File.readlines(file).map(&:chomp)
44
+ obj = ::OpenStruct.new
45
+ lines.each do |line|
46
+ next if line == "\n" || line[0] == "#"
47
+ key, val = line.split(/: +/, 2)
48
+ obj.send(key+"=", val)
49
+ end
50
+ return obj if syms.empty?
51
+
52
+ vals = []
53
+ if syms.empty?
54
+ vals = obj.to_hash.values
55
+ else
56
+ syms.each {|sym| vals << obj.send(sym) }
57
+ end
58
+ return vals
36
59
  rescue => err
37
- puts "Can't read config: #{err}"
60
+ puts "Can't read config file '#{file}': #{err}"
38
61
  puts err.backtrace.join("\n")
39
62
  puts "dir = #{Dir.pwd}"
40
63
  exit
41
64
  end
42
65
 
66
+ def try_read_config(file, hash)
67
+ log!(enter: __method__, args: [file, hash], level: 3)
68
+ return hash.values unless File.exist?(file)
69
+ vals = read_config(file, *hash.keys)
70
+ vals
71
+ end
72
+
73
+ def write_config(obj, file)
74
+ log!(enter: __method__, args: [obj, file], level: 2)
75
+ hash = obj.to_h
76
+ File.open(file, "w") do |out|
77
+ hash.each_pair {|key, val| out.puts "#{key}: #{val}" }
78
+ end
79
+ end
80
+
43
81
  def get_views # read from filesystem
44
82
  log!(enter: __method__, level: 3)
45
- dirs = subdirs("#@root/views/").sort
83
+ dirs = subdirs("#@root + "/" + views/").sort
46
84
  dirs.map {|name| RuneBlog::View.new(name) }
47
85
  end
48
86
 
87
+ def write_repo_config(root: "#{Dir.pwd}/.blogs", view: "#{root}/data/VIEW", editor: "#{root}/data/EDITOR")
88
+ p root
89
+ File.write(root + "/data/ROOT", root + "\n")
90
+ File.write(root + "/data/VIEW", view.to_s + "\n")
91
+ File.write(root + "/data/EDITOR", editor + "\n")
92
+ end
93
+
49
94
  def new_dotfile(root: ".blogs", current_view: "test_view", editor: "vi")
50
95
  log!(enter: __method__, args: [root, current_view, editor], level: 3)
51
- root = Dir.pwd/root
96
+ root = Dir.pwd + "/" + root
52
97
  x = OpenStruct.new
53
98
  x.root, x.current_view, x.editor = root, current_view, editor
54
- write_config(x, root/RuneBlog::ConfigFile)
99
+ write_config(x, root + "/" + RuneBlog::ConfigFile)
100
+ write_repo_config
55
101
  end
56
102
 
57
103
  def new_sequence
@@ -4,14 +4,14 @@ require 'date'
4
4
  require 'find'
5
5
 
6
6
  require 'runeblog'
7
- # require 'pathmagic'
7
+ require 'pathmagic'
8
8
  require 'xlate'
9
9
 
10
10
 
11
11
  def init_liveblog # FIXME - a lot of this logic sucks
12
12
  here = Dir.pwd
13
13
  dir = here
14
- # loop { dir = Dir.pwd; break if File.exist?("data/ROOT"); Dir.chdir("..") }
14
+ # loop { dir = Dir.pwd; break if File.exist?("config"); Dir.chdir("..") }
15
15
  Dir.chdir(here) # here??? or dir??
16
16
  @blog = RuneBlog.new(dir)
17
17
  @root = @blog.root
@@ -443,14 +443,10 @@ rescue => err
443
443
  end
444
444
 
445
445
  def write_post
446
- STDERR.puts :wp1
447
446
  raise "'post' was not called" unless @meta
448
- STDERR.puts :wp2
449
447
  @meta.views = @meta.views.join(" ") if @meta.views.is_a? Array
450
448
  @meta.tags = @meta.tags.join(" ") if @meta.tags.is_a? Array
451
- STDERR.puts :wp3
452
449
  _write_metadata
453
- STDERR.puts :wp4
454
450
  rescue => err
455
451
  puts "err = #{err}"
456
452
  puts err.backtrace.join("\n")
@@ -471,19 +467,13 @@ def teaser
471
467
  end
472
468
 
473
469
  def finalize
474
- STDERR.puts :final1
475
470
  return unless @meta
476
- STDERR.puts :final2
477
471
  return @meta if @blog.nil?
478
- STDERR.puts :final3
479
472
 
480
473
  @slug = @blog.make_slug(@meta)
481
- STDERR.puts :final4
482
474
  slug_dir = @slug
483
475
  @postdir = @blog.view.dir/:posts/slug_dir
484
- STDERR.puts :final5
485
476
  write_post
486
- STDERR.puts :final6
487
477
  @meta
488
478
  end
489
479
 
@@ -1,6 +1,6 @@
1
1
  require 'runeblog'
2
2
  require 'global'
3
- # require 'pathmagic'
3
+ require 'pathmagic'
4
4
 
5
5
  class RuneBlog::Post
6
6
 
@@ -42,9 +42,7 @@ puts "-- load: opening #{pdir}"
42
42
  fname2 = "metadata.txt"
43
43
  hash = meta.to_h
44
44
 
45
- p :wmd1
46
45
  File.write("teaser.txt", hash[:teaser])
47
- p :wmd2
48
46
  hash.delete(:teaser)
49
47
  hash.delete(:body)
50
48
 
@@ -108,14 +106,9 @@ p :wmd2
108
106
  def build
109
107
  log!(enter: __method__)
110
108
  post = self
111
- p :bld1
112
109
  views = post.meta.views
113
- p :bld2
114
110
  text = File.read(@draft)
115
- p :bld3
116
- p @draft
117
111
  @blog.generate_post(@draft)
118
- p :bld4
119
112
  end
120
113
  end
121
114
 
@@ -12,13 +12,14 @@ require 'view'
12
12
  require 'publish'
13
13
  require 'post'
14
14
 
15
- # require 'pathmagic'
15
+ require 'pathmagic'
16
16
 
17
17
  ###
18
18
 
19
19
  class RuneBlog
20
20
 
21
21
  DotDir = ".blogs"
22
+ ConfigFile = "config"
22
23
  Themes = RuneBlog::Path/"../themes"
23
24
 
24
25
  make_exception(:FileNotFound, "File $1 was not found")
@@ -56,17 +57,18 @@ class RuneBlog
56
57
  log!(enter: __method__, args: [root])
57
58
  raise ArgumentError unless root.is_a?(String) && ! root.empty?
58
59
  root_dir = Dir.pwd/root
59
- # Crude - FIXME later - # What views are there? Publishing, etc.
60
60
  self.blog = self # Weird. Like a singleton - dumbass circular dependency?
61
61
  root = Dir.pwd/root
62
62
  raise BlogRepoAlreadyExists if Dir.exist?(root)
63
63
  create_dirs(root)
64
64
  Dir.chdir(root) do
65
- create_dirs(:data, :drafts, :views, :posts)
66
- copy_data(:config, "./data/")
67
- File.write("data/ROOT", Dir.pwd + "\n")
65
+ create_dirs(:drafts, :views, :posts)
68
66
  new_sequence
69
67
  end
68
+ x = OpenStruct.new
69
+ x.root, x.current_view, x.editor = root, "test_view", "/usr/bin/vim " # dumb - FIXME later
70
+ write_config(x, root/ConfigFile)
71
+ write_repo_config
70
72
  @blog = self.new(root)
71
73
  @blog
72
74
  rescue => err
@@ -90,13 +92,16 @@ class RuneBlog
90
92
  self.class.blog = self # Weird. Like a singleton - dumbass circular dependency?
91
93
 
92
94
  @root = root_dir
93
- read_config
94
- @views = get_views
95
+ file = @root/ConfigFile
96
+ errmsg = "No config file! file = #{file.inspect} dir = #{Dir.pwd}"
97
+ raise errmsg unless File.exist?(file)
98
+
99
+ get_repo_config
100
+ @root, @view_name, @editor = read_config(file, :root, :current_view, :editor)
95
101
  md = Dir.pwd.match(%r[.*/views/(.*?)/])
96
- if md
97
- @view_name = md[1]
98
- @view = str2view(@view_name)
99
- end
102
+ @view_name = md[1] if md
103
+ @views = get_views
104
+ @view = str2view(@view_name)
100
105
  @sequence = get_sequence
101
106
  @post_views = []
102
107
  @post_tags = []
@@ -193,7 +198,6 @@ class RuneBlog
193
198
 
194
199
  def view=(arg)
195
200
  log!(enter: __method__, args: [arg], level: 2)
196
- # FIXME should write VIEW file?
197
201
  case arg
198
202
  when RuneBlog::View
199
203
  @view = arg
@@ -376,7 +380,7 @@ class RuneBlog
376
380
  text << entry
377
381
  end
378
382
  text << "</body></html>"
379
- File.write(@vdir/:remote/file, text + "\n")
383
+ File.write(@vdir/:remote/file, text)
380
384
  return posts.size
381
385
  rescue => err
382
386
  _tmp_error(err)
@@ -388,15 +392,10 @@ class RuneBlog
388
392
  meta = nil
389
393
  views = views + [self.view.to_s]
390
394
  views.uniq!
391
- p :cnp1
392
395
  Dir.chdir(@root/"posts") do
393
- p :cnp2
394
396
  post = Post.create(title: title, teaser: teaser, body: body, pubdate: pubdate, views: views)
395
- p :cnp3
396
397
  post.edit unless testing
397
- p :cnp4
398
398
  post.build
399
- p :cnp5
400
399
  meta = post.meta
401
400
  end
402
401
  return meta.num
@@ -424,7 +423,9 @@ p :cnp5
424
423
  log!(enter: __method__, args: [view], level: 3)
425
424
  raise ArgumentError unless view.is_a?(String) || view.is_a?(RuneBlog::View)
426
425
  x = OpenStruct.new
427
- File.write(@root/"data/VIEW", view.to_s + "\n")
426
+ x.root, x.current_view, x.editor = @root, view.to_s, @editor # dumb - FIXME later
427
+ copy_data(:config, @root/:data)
428
+ write_config(x, @root/ConfigFile)
428
429
  self.view = view # error checking?
429
430
  end
430
431
 
@@ -487,24 +488,16 @@ p :cnp5
487
488
  def _post_metadata(draft, pdraft)
488
489
  log!(enter: __method__, args: [draft, pdraft], level: 2)
489
490
  # FIXME store this somewhere
490
- p :pm1
491
491
  fname = File.basename(draft) # 0001-this-is-a-post.lt3
492
492
  nslug = fname.sub(/.lt3$/, "") # 0001-this-is-a-post
493
493
  aslug = nslug.sub(/\d\d\d\d-/, "") # this-is-a-post
494
494
  pnum = nslug[0..3] # 0001
495
- p :pm2
496
495
  Dir.chdir(pdraft) do
497
- p :pm3
498
496
  excerpt = File.read("teaser.txt")
499
- p :pm4
500
497
  date = _retrieve_metadata(:date)
501
- p :pm5
502
498
  longdate = ::Date.parse(date).strftime("%B %e, %Y")
503
- p :pm6
504
499
  title = _retrieve_metadata(:title)
505
- p :pm7
506
500
  tags = _retrieve_metadata(:tags)
507
- p :pm8
508
501
  # FIXME simplify
509
502
  vars = <<~LIVE
510
503
  .set post.num = #{pnum}
@@ -524,9 +517,7 @@ p :pm8
524
517
  #{longdate}
525
518
  .end
526
519
  LIVE
527
- p :pm9
528
520
  File.open(pdraft/"vars.lt3", "w") {|f| f.puts vars }
529
- p :pma
530
521
  end
531
522
  rescue => err
532
523
  _tmp_error(err)
@@ -562,54 +553,39 @@ p :pma
562
553
  pdraft = @root/:posts/nslug
563
554
  remote = @root/:views/view_name/:remote
564
555
  @theme = @root/:views/view_name/:themes/:standard
565
- p :hp1
566
556
  # Step 1...
567
557
  create_dirs(pdraft)
568
- p :hp2
569
558
  # FIXME dependencies?
570
559
  xlate cwd: pdraft, src: draft, dst: "guts.html" # , debug: true
571
- p :hp3
572
560
  _post_metadata(draft, pdraft)
573
- p :hp4
574
561
  # Step 2...
575
562
  vposts = @root/:views/view_name/:posts
576
563
  copy!(pdraft, vposts) # ??
577
- p :hp5
578
564
  # Step 3..
579
565
  copy(pdraft/"guts.html", @theme/:post)
580
566
  copy(pdraft/"vars.lt3", @theme/:post)
581
- p :hp5
582
567
  # Step 4...
583
568
  # FIXME dependencies?
584
569
  xlate cwd: @theme/:post, src: "generate.lt3", force: true,
585
570
  dst: remote/ahtml, copy: @theme/:post # , debug: true
586
- p :hp7
587
571
  # FIXME dependencies?
588
572
  xlate cwd: @theme/:post, src: "permalink.lt3",
589
573
  dst: remote/:permalink/ahtml # , debug: true
590
- p :hp8
591
574
  copy_widget_html(view_name)
592
- p :hp9
593
575
  rescue => err
594
576
  _tmp_error(err)
595
577
  end
596
578
 
597
579
  def generate_post(draft)
598
580
  log!(enter: __method__, args: [draft], level: 1)
599
- p :gp1
600
581
  views = _get_views(draft)
601
- p :gp2
602
582
  views.each do |view|
603
- p :gp3
604
583
  unless self.view?(view)
605
584
  puts "Warning: '#{view}' is not a view"
606
585
  next
607
586
  end
608
- p :gp4
609
587
  _handle_post(draft, view)
610
- p :gp5
611
588
  end
612
- p :gp6
613
589
  rescue => err
614
590
  _tmp_error(err)
615
591
  end
@@ -1,10 +1,8 @@
1
1
 
2
- require 'pathmagic'
3
-
4
2
  if ! (Object.constants.include?(:RuneBlog) && RuneBlog.constants.include?(:Path))
5
3
 
6
4
  class RuneBlog
7
- VERSION = "0.2.72"
5
+ VERSION = "0.2.73"
8
6
 
9
7
  path = Gem.find_files("runeblog").grep(/runeblog-/).first
10
8
  Path = File.dirname(path)
@@ -85,66 +85,66 @@ EXCERPT
85
85
  That's a good thing. But their music isn't always the greatest.
86
86
  BODY
87
87
 
88
- # make_post(x, "The new amphitheatre is overrated", <<-EXCERPT, <<-BODY)
89
- # It used to be that all major concerts played the Erwin Center.
90
- # EXCERPT
91
- # .pin around_austin
92
- # Now, depending on what you consider "major," blah blah blah...
93
- # BODY
94
- #
95
- # make_post(x, "The graffiti wall", <<-EXCERPT, <<-BODY)
96
- # RIP, Hope Gallery
97
- # EXCERPT
98
- #
99
- # .dropcap It's been a while since I was there. They say it was torn down
100
- # while I wasn't looking. Never tagged anything there, of course, nor
101
- # anywhere else. Spraypainting public places isn't my thing, but in this
102
- # case I condoned it because it was sort of there for that purpose.
103
- #
104
- # This fake entry is a long one so as to demonstrate both drop-caps
105
- # (above) and an inset quote. Blah blah blah. Lorem ipsum dolor and
106
- # a partridge in a pear tree.
107
- #
108
- # .inset left 20
109
- # Wherever you go, there you are. Last night I saw upon the stair
110
- # a little man who was not there. He wasn't there again today; I
111
- # wish, I wish he'd go away. As far as we know, our computer has
112
- # never had an undetected error.
113
- # |On a clean disk, you can seek forever.
114
- # And never let it be denied that
115
- # pobbles are happier without their toes. And may your snark never
116
- # be a boojum. How do you know you aren't dreaming right now? When
117
- # you see a butterfly, think of Chuang Tzu.
118
- # .end
119
- #
120
- # Contact light. Houston, this is Tranquility Base. The Eagle has
121
- # landed. That's one small step for (a) man, one giant leap for
122
- # mankind.
123
- #
124
- # Here's the PDF of $$link["Ruby for the Old-Time C Programmer"|http://rubyhacker.com/blog2/rubydino.pdf]
125
- #
126
- # Pity this busy monster, manunkind, not. Pity rather... Listen:
127
- # There's a hell of a universe next door; let's go.
128
- # BODY
129
- #
130
- # make_post(x, "The Waller Creek project", <<-EXCERPT, <<-BODY)
131
- # Will it ever be finished?
132
- # EXCERPT
133
- # Blah blah Waller Creek blah blah...
134
- # BODY
135
- #
136
- # make_post(x, "Life on Sabine Street", <<-EXCERPT, <<-BODY)
137
- # It's like Pooh Corner, except not.
138
- # EXCERPT
139
- # This is about Sabine St, blah blah lorem ipsum dolor...
140
- # BODY
141
- #
142
- # make_post(x, "Remember Modest Mouse?", <<-EXCERPT, <<-BODY)
143
- # They date to the 90s or before.
144
- # EXCERPT
145
- # But I first heard of them
146
- # in 2005.
147
- # BODY
88
+ make_post(x, "The new amphitheatre is overrated", <<-EXCERPT, <<-BODY)
89
+ It used to be that all major concerts played the Erwin Center.
90
+ EXCERPT
91
+ .pin around_austin
92
+ Now, depending on what you consider "major," blah blah blah...
93
+ BODY
94
+
95
+ make_post(x, "The graffiti wall", <<-EXCERPT, <<-BODY)
96
+ RIP, Hope Gallery
97
+ EXCERPT
98
+
99
+ .dropcap It's been a while since I was there. They say it was torn down
100
+ while I wasn't looking. Never tagged anything there, of course, nor
101
+ anywhere else. Spraypainting public places isn't my thing, but in this
102
+ case I condoned it because it was sort of there for that purpose.
103
+
104
+ This fake entry is a long one so as to demonstrate both drop-caps
105
+ (above) and an inset quote. Blah blah blah. Lorem ipsum dolor and
106
+ a partridge in a pear tree.
107
+
108
+ .inset left 20
109
+ Wherever you go, there you are. Last night I saw upon the stair
110
+ a little man who was not there. He wasn't there again today; I
111
+ wish, I wish he'd go away. As far as we know, our computer has
112
+ never had an undetected error.
113
+ |On a clean disk, you can seek forever.
114
+ And never let it be denied that
115
+ pobbles are happier without their toes. And may your snark never
116
+ be a boojum. How do you know you aren't dreaming right now? When
117
+ you see a butterfly, think of Chuang Tzu.
118
+ .end
119
+
120
+ Contact light. Houston, this is Tranquility Base. The Eagle has
121
+ landed. That's one small step for (a) man, one giant leap for
122
+ mankind.
123
+
124
+ Here's the PDF of $$link["Ruby for the Old-Time C Programmer"|http://rubyhacker.com/blog2/rubydino.pdf]
125
+
126
+ Pity this busy monster, manunkind, not. Pity rather... Listen:
127
+ There's a hell of a universe next door; let's go.
128
+ BODY
129
+
130
+ make_post(x, "The Waller Creek project", <<-EXCERPT, <<-BODY)
131
+ Will it ever be finished?
132
+ EXCERPT
133
+ Blah blah Waller Creek blah blah...
134
+ BODY
135
+
136
+ make_post(x, "Life on Sabine Street", <<-EXCERPT, <<-BODY)
137
+ It's like Pooh Corner, except not.
138
+ EXCERPT
139
+ This is about Sabine St, blah blah lorem ipsum dolor...
140
+ BODY
141
+
142
+ make_post(x, "Remember Modest Mouse?", <<-EXCERPT, <<-BODY)
143
+ They date to the 90s or before.
144
+ EXCERPT
145
+ But I first heard of them
146
+ in 2005.
147
+ BODY
148
148
 
149
149
  debug
150
150
  debug "** generate_index #{bold("around_austin")}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runeblog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.72
4
+ version: 0.2.73
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton