runeblog 0.1.79 → 0.1.84

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: 6add0a9ef9437be9e4f41ee88ac0a067cc13a9120c73a4403a2a23d471f1034d
4
- data.tar.gz: ec7b79a7c68f46b57e367043aff7db3524d88e8fd593ccd9a699ca1071ff83c0
3
+ metadata.gz: b18c3d8c6c7a36be892a6ad4f5d1343839da39d8a151ac2a9600cb29389a855d
4
+ data.tar.gz: e18259284be9484e35e800c60ee531b4678ea9ad9c1ce85994d36362d92d7f66
5
5
  SHA512:
6
- metadata.gz: 2301c17418d3d5f1cb076e36d9b6583b8388f82f6c142ac67b4d2f88110dcd46c3d79f344bf59a0e3dd0858fbbf35d3469f6a7ab0ad11d587b5cd142c61eb124
7
- data.tar.gz: e96e4521ecb8f542a58164ac20f2cac17b51113cd3096258a45124b05ad1a79e29f6059eabe154c1ae4576ece2bda8f51f50c5c3368740f5728fd137a0a50e03
6
+ metadata.gz: 19bcba26366d495a4c879f79b5fcc0b068cbca46f1a40e1f2959864bd7ed9b9d5a5c80cf07d5aeeb0fde5d72ce146d63b6aff99df81d5e1b62b5a8689357da91
7
+ data.tar.gz: 947861e8132ac5fa801398e81fed3e0fad60d1a10f210478e8a248583e57a40b6000b7b7940cfc56fadd11d73c2328f21bca137168a81b96d1855ca4a8ecf519
@@ -23,6 +23,9 @@ def RuneBlog.post_template(num: 0, title: "No title", date: nil, view: "test_vie
23
23
  #{teaser}
24
24
  .end
25
25
  #{body}
26
+
27
+ <br>
28
+ <a href="javascript:history.go(-1)">[Back]</a>
26
29
  TEXT
27
30
 
28
31
  end
@@ -4,6 +4,20 @@ require 'runeblog_version'
4
4
 
5
5
  module RuneBlog::Helpers
6
6
 
7
+ def copy(src, dst)
8
+ system("cp #{src} #{dst}")
9
+ end
10
+
11
+ def copy!(src, dst)
12
+ system("cp -r #{src} #{dst}")
13
+ end
14
+
15
+ def livetext(src, dst)
16
+ src << ".lt3" unless src.end_with?(".lt3")
17
+ dst << ".html" unless src.end_with?(".html")
18
+ system("livetext #{src} >#{dst}")
19
+ end
20
+
7
21
  def get_root
8
22
  if $_blog
9
23
  if $_blog.root
@@ -114,9 +128,9 @@ module RuneBlog::Helpers
114
128
  raise CantCreateDir(dir) unless result
115
129
  end
116
130
 
117
- def interpolate(str)
131
+ def interpolate(str, binding)
118
132
  wrap = "<<-EOS\n#{str}\nEOS"
119
- eval wrap
133
+ eval wrap, binding
120
134
  end
121
135
 
122
136
  def error(err) # Hmm, this is duplicated
@@ -8,8 +8,6 @@ require 'runeblog'
8
8
  errfile = File.new("liveblog.out", "w")
9
9
  STDERR.reopen(errfile)
10
10
 
11
- # ::Home = Dir.pwd unless defined?(::Home)
12
-
13
11
  =begin
14
12
  123:def title # side-effect
15
13
  133:def pubdate # side-effect
@@ -21,11 +19,20 @@ STDERR.reopen(errfile)
21
19
  491:def _post_lookup(postid) # side-effect
22
20
  =end
23
21
 
22
+ def init_liveblog # FIXME - a lot of this logic sucks
23
+ @blog = $_blog = RuneBlog.new(false)
24
+ @root = @blog.root
25
+ @view = @blog.view
26
+ @view_name = @blog.view.name
27
+ @vdir = @blog.view.dir
28
+ @version = RuneBlog::VERSION
29
+ @theme = @vdir + "/themes/standard/"
30
+ end
31
+
24
32
  def post
25
33
  @meta = OpenStruct.new
26
34
  @meta.num = _args[0]
27
- # @live = ::Livetext.new
28
- # STDERR.puts ">>> #{__method__}: @meta = #{@meta.to_h.inspect}"
35
+ _out " <!-- Post number #{@meta.num} -->\n "
29
36
  end
30
37
 
31
38
  def _view_from_cwd
@@ -95,31 +102,6 @@ def inset
95
102
  _optional_blank_line
96
103
  end
97
104
 
98
- ### copy_asset
99
-
100
- # def copy_asset(asset)
101
- # vdir = @blog.view.dir
102
- # return if File.exist?(vdir + "/assets/" + asset)
103
- # top = vdir + "/../../assets/"
104
- # if File.exist?(top + asset)
105
- # system("cp #{top}/#{asset} #{vdir}/assets/#{asset}")
106
- # return
107
- # end
108
- # raise "Can't find #{asset.inspect}"
109
- # end
110
-
111
- #############
112
-
113
- def init_liveblog # FIXME - a lot of this logic sucks
114
- @blog = $_blog = RuneBlog.new(false)
115
- @root = @blog.root
116
- @view = @blog.view
117
- @view_name = @blog.view.name
118
- @vdir = @blog.view.dir
119
- @version = RuneBlog::VERSION
120
- @theme = @vdir + "/themes/standard/"
121
- end
122
-
123
105
  def _errout(*args)
124
106
  ::STDERR.puts *args
125
107
  end
@@ -142,8 +124,6 @@ def title # side-effect
142
124
  raise "'post' was not called" unless @meta
143
125
  title = @_data.chomp
144
126
  @meta.title = title
145
- # STDERR.puts ">>> #{__method__}: @meta = #{@meta.to_h.inspect}"
146
- # @live.setvar :title, title
147
127
  setvar :title, title
148
128
  _out %[<h1 class="post-title">#{title}</h1><br>]
149
129
  _optional_blank_line
@@ -158,7 +138,6 @@ def pubdate # side-effect
158
138
  y, m, d = y.to_i, m.to_i, d.to_i
159
139
  @meta.date = ::Date.new(y, m, d)
160
140
  @meta.pubdate = "%04d-%02d-%02d" % [y, m, d]
161
- # STDERR.puts ">>> #{__method__}: @meta = #{@meta.to_h.inspect}"
162
141
  _optional_blank_line
163
142
  end
164
143
 
@@ -174,7 +153,6 @@ def tags # side-effect
174
153
  raise "'post' was not called" unless @meta
175
154
  _debug "args = #{_args}"
176
155
  @meta.tags = _args.dup || []
177
- # STDERR.puts ">>> #{__method__}: @meta = #{@meta.to_h.inspect}"
178
156
  _optional_blank_line
179
157
  end
180
158
 
@@ -182,7 +160,6 @@ def views # side-effect
182
160
  raise "'post' was not called" unless @meta
183
161
  _debug "data = #{_args}"
184
162
  @meta.views = _args.dup # + ["main"]
185
- # STDERR.puts ">>> #{__method__}: @meta = #{@meta.to_h.inspect}"
186
163
  _optional_blank_line
187
164
  end
188
165
 
@@ -191,13 +168,9 @@ def pin # side-effect
191
168
  _debug "data = #{_args}"
192
169
  # verify only already-specified views?
193
170
  @meta.pinned = _args.dup
194
- # STDERR.puts ">>> #{__method__}: @meta = #{@meta.to_h.inspect}"
195
171
  _optional_blank_line
196
172
  end
197
173
 
198
- # def liveblog_version
199
- # end
200
-
201
174
  def list
202
175
  _out "<ul>"
203
176
  _body {|line| _out "<li>#{line}</li>" }
@@ -221,38 +194,14 @@ def list!
221
194
  _optional_blank_line
222
195
  end
223
196
 
224
- def asset
225
- raise "'post' was not called" unless @meta
226
- @meta.assets ||= {}
227
- # STDERR.puts ">>> #{__method__}: @meta = #{@meta.to_h.inspect}"
228
- list = _args
229
- # For now: copies, doesn't keep record
230
- # Later: Add to file and uniq; use in publishing
231
- list.each {|asset| copy_asset(asset) }
232
- _optional_blank_line
233
- end
234
-
235
- def assets
236
- raise "'post' was not called" unless @meta
237
- @meta.assets ||= []
238
- @meta.assets += _body
239
- # STDERR.puts ">>> #{__method__}: @meta = #{@meta.to_h.inspect}"
240
- _optional_blank_line
241
- end
242
-
243
197
  def write_post # side-effect
244
198
  raise "'post' was not called" unless @meta
245
- # return
246
199
  save = Dir.pwd
247
200
  @postdir.gsub!(/\/\//, "/") # FIXME unneeded?
248
201
  Dir.mkdir(@postdir) unless Dir.exist?(@postdir) # FIXME remember assets!
249
202
  Dir.chdir(@postdir)
250
- STDERR.puts "------ cd into #@postdir"
251
203
  @meta.views = @meta.views.join(" ")
252
204
  @meta.tags = @meta.tags.join(" ") rescue ""
253
- # STDERR.puts ">>>> #{__method__}: writing #{@live.body.size} bytes to #{Dir.pwd}/body.txt"
254
- # File.write("body.txt", @live.body) # Actually HTML...
255
- # p Dir.pwd
256
205
  File.write("teaser.txt", @meta.teaser)
257
206
 
258
207
  fields = [:num, :title, :date, :pubdate, :views, :tags]
@@ -261,7 +210,6 @@ STDERR.puts "------ cd into #@postdir"
261
210
  f2 = File.open(fname2, "w") do |f2|
262
211
  fields.each {|fld| f2.puts "#{fld}: #{@meta.send(fld)}" }
263
212
  end
264
- STDERR.puts ">>> #{__method__}: @meta = #{@meta.to_h.inspect}"
265
213
  Dir.chdir(save)
266
214
  rescue => err
267
215
  puts "err = #{err}"
@@ -271,11 +219,8 @@ end
271
219
  def teaser
272
220
  raise "'post' was not called" unless @meta
273
221
  @meta.teaser = _body_text
274
- STDERR.puts ">>> #{__method__}: @meta = #{@meta.to_h.inspect}"
275
222
  _out @meta.teaser + "\n"
276
223
  STDERR.puts "TEASER cwd = #{Dir.pwd}"
277
- # file = @vdir + "/teaser.txt"
278
- # File.write(file, @meta.teaser)
279
224
  # FIXME
280
225
  end
281
226
 
@@ -291,7 +236,6 @@ def finalize
291
236
  @slug = @blog.make_slug(@meta)
292
237
  slug_dir = @slug
293
238
  @postdir = @blog.view.dir + "/posts/#{slug_dir}"
294
- STDERR.puts "Got here!"
295
239
  write_post
296
240
  @meta
297
241
  end
@@ -329,23 +273,17 @@ end
329
273
  ###### experimental...
330
274
 
331
275
  class Livetext::Functions
332
-
333
276
  def _var(name)
334
277
  ::Livetext::Vars[name] || "[:#{name} is undefined]"
335
278
  end
336
279
 
337
-
338
280
  def link
339
281
  file, cdata = self.class.param.split("||", 2)
340
282
  %[<link type="application/atom+xml" rel="alternate" href="#{_var(:host)}#{file}" title="#{_var(:title)}">]
341
283
  end
342
-
343
284
  end
344
285
 
345
- ###############
346
-
347
-
348
- def _var(name) # FIXME later
286
+ def _var(name) # FIXME scope issue!
349
287
  ::Livetext::Vars[name] || "[:#{name} is undefined]"
350
288
  end
351
289
 
@@ -363,7 +301,7 @@ def head
363
301
  "linkc" => %[<link rel="canonical" href="#{_var(:host)}">],
364
302
  "og:url" => %[<meta property="og:url" content="#{_var(:host)}">],
365
303
  "og:site_name" => %[<meta property="og:site_name" content="#{_var(:title)}">],
366
- "style" => %[<link rel="stylesheet" href="blog-application.css">],
304
+ "style" => %[<link rel="stylesheet" href="assets/blog.css">],
367
305
  "feed" => %[<link type="application/atom+xml" rel="alternate" href="#{_var(:host)}/feed.xml" title="#{_var(:title)}">],
368
306
  "favicon" => %[<link rel="shortcut icon" type="image/x-icon" href="../assets/favicon.ico">\n <link rel="apple-touch-icon" href="../assets/favicon.ico">]
369
307
  }
@@ -388,7 +326,7 @@ def head
388
326
  end
389
327
  end
390
328
  hash = defaults.dup.update(result) # FIXME collisions?
391
- _out "<html lang=en_US>"
329
+ # _out "<html lang=en_US>"
392
330
  _out "<head>"
393
331
  hash.each_value {|x| _out " " + x }
394
332
  _out "</head>"
@@ -423,11 +361,8 @@ STDERR.puts "--- inside #main: which = #{which.inspect}"
423
361
  case which
424
362
  when "recent_posts"
425
363
  all_teasers
426
- when "post" # FIXME!!!
427
- # _out "<iframe src='./0001-whats-at-stubbs/whats-at-stubbs.html'><iframe>"
364
+ when "post" # No longer needed??
428
365
  _out %[<iframe style="width: 100vw;height: 100vh;position: relative;" src='whats-at-stubbs.html' width=100% frameborder="0" allowfullscreen></iframe>]
429
- # self.data = "post-index.lt3"
430
- # _include
431
366
  end
432
367
  _out %[</div>]
433
368
  end
@@ -468,6 +403,7 @@ def script
468
403
  _out %[<script src="#{url}" integrity="#{integ}" crossorigin="#{cross}"></script>]
469
404
  end
470
405
 
406
+
471
407
  ### How this next bit works:
472
408
  ###
473
409
  ### all_teasers will call _find_recent_posts
@@ -484,12 +420,10 @@ end
484
420
  ###
485
421
 
486
422
  def _find_recent_posts
487
- STDERR.puts "--- frp: $FileDir = #{_var(:FileDir)}"
488
423
  @vdir = _var(:FileDir).match(%r[(^.*/views/.*?)/])[1]
489
424
  posts = nil
490
425
  dir_posts = @vdir + "/posts"
491
426
  entries = Dir.entries(dir_posts)
492
- STDERR.puts "--- frp: dir_posts = #{dir_posts} ent = #{entries.inspect}"
493
427
  posts = entries.grep(/^\d\d\d\d/).map {|x| dir_posts + "/" + x }
494
428
  posts.select! {|x| File.directory?(x) }
495
429
  # directories that start with four digits
@@ -498,7 +432,6 @@ STDERR.puts "--- frp: dir_posts = #{dir_posts} ent = #{entries.inspect}"
498
432
  end
499
433
 
500
434
  def all_teasers
501
- STDERR.puts "-- inside #all_teasers..."
502
435
  open = <<-HTML
503
436
  <section class="posts">
504
437
  HTML
@@ -508,10 +441,9 @@ STDERR.puts "-- inside #all_teasers..."
508
441
 
509
442
  text = <<-HTML
510
443
  <html>
511
- <head><link rel="stylesheet" href="blog-application.css"></head>
444
+ <head><link rel="stylesheet" href="assets/blog.css"></head>
512
445
  <body>
513
446
  HTML
514
- # _out open
515
447
  posts = _find_recent_posts
516
448
  wanted = [5, posts.size].min # estimate how many we want?
517
449
  enum = posts.each
@@ -522,8 +454,6 @@ STDERR.puts "-- inside #all_teasers..."
522
454
  end
523
455
  text << "</body></html>"
524
456
  File.write("recent.html", text)
525
- # _out close
526
- # _out "<iframe src='./recent.html'><iframe>"
527
457
  _out %[<iframe style="width: 100vw;height: 100vh;position: relative;" src='recent.html' width=100% frameborder="0" allowfullscreen></iframe>]
528
458
  end
529
459
 
@@ -556,17 +486,14 @@ def _teaser(slug)
556
486
  nslug, aslug, title, date, teaser_text =
557
487
  vp.nslug, vp.aslug, vp.title, vp.date, vp.teaser_text
558
488
  path = vp.path
559
- STDERR.puts [">>>>> vp = ", vp].inspect
560
489
  url = "#{path}/#{aslug}.html" # Should be relative to .blogs!! FIXME
561
- STDERR.puts [slug, url].inspect
562
490
  date = Date.parse(date)
563
491
  date = date.strftime("%B %e<br>%Y")
564
492
  text = _interpolate(@_post_entry, binding)
565
- # File.write("../../../generated/#{slug}.html", text)
566
- # _out text
567
493
  text
568
494
  end
569
495
 
496
+
570
497
  def card_iframe
571
498
  title = _data
572
499
  lines = _body
@@ -153,5 +153,18 @@ class RuneBlog::ViewPost
153
153
  @title = lines.grep(/title:/).first[7..-1].chomp
154
154
  @date = lines.grep(/pubdate:/).first[9..-1].chomp
155
155
  end
156
+
157
+ def get_dirs
158
+ fname = File.basename(draft)
159
+ noext = fname.sub(/.lt3$/, "")
160
+ vdir = "#@root/views/#{view}"
161
+ dir = "#{vdir}/posts/#{noext}/"
162
+ Dir.mkdir(dir) unless Dir.exist?(dir)
163
+ system("cp #{draft} #{dir}")
164
+ viewdir, slugdir, aslug = vdir, dir, noext[5..-1]
165
+ theme = viewdir + "/themes/standard"
166
+ [noext, viewdir, slugdir, aslug, theme]
167
+ end
168
+
156
169
  end
157
170
 
@@ -1,5 +1,5 @@
1
- #equire 'find'
2
- require 'livetext'
1
+ require 'date'
2
+ # require 'livetext'
3
3
 
4
4
  require 'runeblog_version'
5
5
  require 'global'
@@ -9,17 +9,13 @@ require 'view'
9
9
  require 'publish'
10
10
  require 'post'
11
11
 
12
- # ::Home = Dir.pwd unless defined?(::Home)
13
-
14
12
  ###
15
13
 
16
14
  class RuneBlog
17
15
 
18
16
  DotDir = ".blogs"
19
17
  ConfigFile = "config"
20
- GemData = RuneBlog::Path + "/../data"
21
-
22
- # ::Home = Dir.pwd
18
+ GemData = RuneBlog::Path + "/../themes"
23
19
 
24
20
  make_exception(:FileNotFound, "File $1 was not found")
25
21
  make_exception(:BlogRepoAlreadyExists, "Blog repo $1 already exists")
@@ -29,7 +25,7 @@ class RuneBlog
29
25
  make_exception(:CantCreateDir, "Can't create directory $1")
30
26
  make_exception(:EditorProblem, "Could not edit $1")
31
27
  make_exception(:NoSuchView, "No such view: $1")
32
- make_exception(:LivetextError, "Livetext#process_file returned nil for $1")
28
+ # make_exception(:LivetextError, "Livetext#process_file returned nil for $1")
33
29
  make_exception(:NoBlogAccessor, "Runeblog.blog is not set")
34
30
 
35
31
 
@@ -51,7 +47,6 @@ class RuneBlog
51
47
  raise BlogRepoAlreadyExists if Dir.exist?(root_dir)
52
48
  new_dotfile(root: root_dir, current_view: first_view)
53
49
  create_dir(dir)
54
- # New code goes here!
55
50
  Dir.chdir(dir) do
56
51
  create_dir("drafts")
57
52
  create_dir("views")
@@ -66,8 +61,7 @@ class RuneBlog
66
61
  end
67
62
 
68
63
  def initialize(top = true) # at top? always assumes existing blog
69
- # Crude - FIXME later -
70
- # What views are there? Publishing, etc.
64
+ # Crude - FIXME later - # What views are there? Publishing, etc.
71
65
  self.class.blog = self # Weird. Like a singleton - dumbass circular dependency?
72
66
  $_blog = self # Dumber still?
73
67
  dir = ""
@@ -78,11 +72,11 @@ class RuneBlog
78
72
  file = dir.empty? ? ConfigFile : dir + "/" + ConfigFile
79
73
  errmsg = "No config file! file = #{file.inspect} dir = #{Dir.pwd}"
80
74
  raise errmsg unless File.exist?(file)
81
- # Hmm. current_view doesn't belong?
75
+ # Hmm. current_view doesn't belong?
82
76
  @root, @view_name, @editor = read_config(file, :root, :current_view, :editor)
77
+
83
78
  md = Dir.pwd.match(%r[.*/views/(.*?)/])
84
79
  @view_name = md[1] if md
85
- # STDERR.puts "---- vname = #@view_name"
86
80
  @views = get_views
87
81
  @view = str2view(@view_name)
88
82
  @sequence = get_sequence
@@ -173,17 +167,22 @@ class RuneBlog
173
167
  Dir.chdir(vdir)
174
168
  x = RuneBlog::Default
175
169
  create_dir('themes')
176
- # create_dir("generated")
177
170
  create_dir('assets')
178
171
  create_dir('posts')
179
172
 
173
+ create_dir('staging')
174
+ create_dir('staging/assets')
175
+ create_dir('remote')
176
+ create_dir('remote/assets')
177
+
180
178
  Dir.chdir("themes") { system("tar zxvf #{GemData}/standard.tgz >/dev/null 2>&1") }
181
- # system("cp themes/standard/blog/assets/* assets/")
179
+ copy!("themes/standard/*", "staging/")
180
+ copy("themes/standard/assets/*", "remote/assets/")
182
181
 
183
182
  pub = "user: xxx\nserver: xxx\ndocroot: xxx\npath: xxx\nproto: xxx\n"
184
183
  dump(pub, "publish")
185
184
 
186
- # Add to global.lt3 here? FIXME
185
+ # Add to global.lt3 here? FIXME
187
186
 
188
187
  view = RuneBlog::View.new(arg)
189
188
  self.view = view
@@ -218,22 +217,82 @@ class RuneBlog
218
217
  result
219
218
  end
220
219
 
220
+ def post_lookup(postid) # side-effect?
221
+ # .. = templates, ../.. = views/thisview
222
+ slug = title = date = teaser_text = nil
223
+
224
+ dir_posts = @vdir + "/posts"
225
+ posts = Dir.entries(dir_posts).grep(/^\d\d\d\d/).map {|x| dir_posts + "/" + x }
226
+ posts.select! {|x| File.directory?(x) }
227
+
228
+ post = posts.select {|x| File.basename(x).to_i == postid }
229
+ raise "Error: More than one post #{postid}" if post.size > 1
230
+ postdir = post.first
231
+ vp = RuneBlog::ViewPost.new(self.view, postdir)
232
+ vp
233
+ end
234
+
235
+ def teaser(slug)
236
+ id = slug.to_i
237
+ text = nil
238
+ post_entry_name = @theme + "/blog-_postentry.lt3"
239
+ @_post_entry ||= File.read(post_entry_name)
240
+ vp = post_lookup(id)
241
+ nslug, aslug, title, date, teaser_text =
242
+ vp.nslug, vp.aslug, vp.title, vp.date, vp.teaser_text
243
+ path = vp.path
244
+ # url = "#{path}/#{aslug}.html" # Should be relative to .blogs!! FIXME
245
+ url = "#{aslug}.html" # Should be relative to .blogs!! FIXME
246
+ date = ::Date.parse(date)
247
+ date = date.strftime("%B %e<br>%Y")
248
+ text = interpolate(@_post_entry, binding)
249
+ text
250
+ end
251
+
252
+ def collect_recent_posts(file)
253
+ @vdir = ".."
254
+ posts = nil
255
+ dir_posts = @vdir + "/posts"
256
+ entries = Dir.entries(dir_posts)
257
+ posts = entries.grep(/^\d\d\d\d/).map {|x| dir_posts + "/" + x }
258
+ posts.select! {|x| File.directory?(x) }
259
+ # directories that start with four digits
260
+ posts = posts.sort {|a, b| b.to_i <=> a.to_i } # sort descending
261
+ posts = posts[0..19] # return 20 at most
262
+ text = <<-HTML
263
+ <html>
264
+ <head><link rel="stylesheet" href="assets/blog.css"></head>
265
+ <body>
266
+ HTML
267
+ # posts = _find_recent_posts
268
+ wanted = [5, posts.size].min # estimate how many we want?
269
+ enum = posts.each
270
+ wanted.times do
271
+ postid = File.basename(enum.next)
272
+ postid = postid.to_i
273
+ text << teaser(postid) # side effect! calls _out
274
+ end
275
+ text << "</body></html>"
276
+ File.write(file, text) # FIXME ???
277
+ iframe_text = <<-HTML
278
+ <iframe style="width: 100vw;height: 100vh;position: relative;"
279
+ src='recent.html' width=100% frameborder="0" allowfullscreen>
280
+ </iframe>
281
+ HTML
282
+ # _out iframe_text # FIXME ??
283
+ end
284
+
221
285
  def create_new_post(title, testing = false, teaser: nil, body: nil, other_views: [])
222
286
  save = Dir.pwd
223
287
  Dir.chdir(self.view.dir)
224
288
  # change to create_draft ?
225
289
  post = Post.create(title: title, teaser: teaser, body: body, other_views: other_views)
226
- puts "cnp: num = #{post.meta.num}"
227
290
  post.edit unless testing
228
291
  post.build
229
292
  meta = post.meta
230
293
  Dir.chdir(save)
231
- puts "cnp: title = #{title.inspect}\n meta = #{meta.inspect}"
232
- meta.num ||= 999
233
- return meta.num
234
- Dir.chdir(save)
235
- meta.num = 999
236
- meta.num
294
+ meta.num ||= 999 # ??
295
+ return meta.num
237
296
  rescue => err
238
297
  puts err
239
298
  puts err.backtrace.join("\n")
@@ -268,37 +327,18 @@ return meta.num
268
327
  self.view = view # error checking?
269
328
  end
270
329
 
271
- def process_post(file)
272
- raise ArgumentError unless file.is_a?(String)
273
- path = @root + "/drafts/#{file}"
274
- raise FileNotFound(path) unless File.exist?(path)
275
- num = file.to_i # e.g. 0098-this-is-a-title
276
- live = Livetext.new # (STDOUT) # (nil)
277
- Livetext.parameters = [self, num, live]
278
- text = File.read(path)
279
- live.process_text(text)
280
- rescue => err
281
- error(err)
282
- getch
283
- end
284
-
285
- def generate_index(view)
286
- # FIXME
330
+ def generate_index(view) # FIXME delete?
287
331
  debug "=== generate_index view = #{view.to_s}"
288
332
  raise ArgumentError unless view.is_a?(String) || view.is_a?(RuneBlog::View)
289
333
 
290
334
  vdir = self.view.dir
291
335
  dir0 = "#{vdir}/themes/standard/blog"
292
- # dir1 = "#{vdir}/generated"
293
- # system("livetext #{dir0}/generate.lt3 >#{dir1}/index.html 2>#{dir1}/errors.txt")
294
336
  rescue => err
295
337
  error(err)
296
338
  exit
297
339
  end
298
340
 
299
- ######## New code
300
-
301
- def generate_view(view)
341
+ def generate_view(view) # huh?
302
342
  end
303
343
 
304
344
  def _get_views(draft)
@@ -306,7 +346,6 @@ return meta.num
306
346
  view_line = File.readlines(draft).grep(/^.views /)
307
347
  raise "More than one .views call!" if view_line.size > 1
308
348
  raise "No .views call!" if view_line.size < 1
309
- # STDERR.puts view_line.inspect
310
349
  view_line = view_line.first
311
350
  views = view_line[7..-1].split
312
351
  end
@@ -314,18 +353,18 @@ return meta.num
314
353
  # Remember: A post in multiple views will trigger multiple
315
354
  # views needing to be rebuilt (and published)
316
355
 
317
- # generate a post:
318
- # given draft 9999-title.lt3
319
- # create VIEW/posts/9999-title/index.lt3
320
- # LATER: metadata!! or is it in head?
321
- # Generate VIEW/posts/9999-title/head.lt3?
322
- # livetext draft_wrapper_plain.lt3 >generated/posts/plain-title.html # unframed
323
- # livetext draft_generate.lt3 >generated/posts/real-title.html # framed
324
- # livetext draft_wrapper_perma.lt3 >generated/posts/perma-title.html # permaframed
325
- #
326
- # Generate associated views:
327
- # livetext ??/recent.lt3 >VIEW/working/recent.html
328
- # livetext VIEW/blog/generate.lt3 ??
356
+ # generate a post:
357
+ # given draft 9999-title.lt3
358
+ # create VIEW/posts/9999-title/index.lt3
359
+ # LATER: metadata!! or is it in head?
360
+ # Generate VIEW/posts/9999-title/head.lt3?
361
+ # livetext draft_wrapper_plain.lt3 >generated/posts/plain-title.html # unframed
362
+ # livetext draft_generate.lt3 >generated/posts/real-title.html # framed
363
+ # livetext draft_wrapper_perma.lt3 >generated/posts/perma-title.html # permaframed
364
+ #
365
+ # Generate associated views:
366
+ # livetext ??/recent.lt3 >VIEW/working/recent.html
367
+ # livetext VIEW/blog/generate.lt3 ??
329
368
 
330
369
  def _copy_get_dirs(draft, view)
331
370
  fname = File.basename(draft)
@@ -342,76 +381,29 @@ return meta.num
342
381
  def generate_post(draft)
343
382
  views = _get_views(draft)
344
383
  views.each do |view|
345
- noext, viewdir, slugdir, aslug, theme = _copy_get_dirs(draft, view)
384
+ noext, viewdir, slugdir, aslug, @theme = _copy_get_dirs(draft, view)
385
+ staging = viewdir + "/staging"
346
386
  Dir.chdir(slugdir) do
347
- html = noext[5..-1] + ".html"
348
- STDERR.puts "--- NEW gp into #{slugdir}: livetext #{draft} >#{html}"
349
- system("livetext #{draft} >#{html}")
350
-
351
- Dir.mkdir("sidebar") unless Dir.exist?("sidebar")
352
- system("cp #{theme}/sidebar/*.lt3 ./sidebar/")
353
- files = ["blog-generate.lt3", "blog-index.lt3", "global.lt3", "blog-head.lt3",
354
- "meta.lt3", "navbar.lt3"]
355
- files2 = files.map {|x| theme + "/" + x }
356
- files2.each do |f|
357
- system("cp #{f} .")
387
+ copy(draft, ".")
388
+ lt3 = draft.split("/")[-1]
389
+ # Remember: Some posts may be in more than one view -- careful with links back
390
+ # system("livetext #{draft} >staging/#{name}/index.html") # permalink?
391
+ # Structure is borked?
392
+ copy!("#{@theme}/*", "#{staging}")
393
+ copy(lt3, staging)
394
+ html = noext[5..-1]
395
+ Dir.chdir(staging) do
396
+ livetext draft, html
397
+ # link to POST??
398
+ copy html, "../remote"
399
+ collect_recent_posts("recent.html")
400
+ copy("recent.html", "../remote")
401
+ livetext "blog-generate", "../remote/index"
358
402
  end
359
-
360
- # system("livetext blog-generate.lt3 >bgen.html")
361
- # files.each {|fname| system("rm ./#{fname}") }
362
- # system("rm -rf ./sidebar/")
363
403
  end
364
- # create framed pure slug (where?)
365
404
  end
366
405
  end
367
406
 
368
- def old_generate_post(draft)
369
- dir = File.dirname(draft)
370
- fname = File.basename(draft)
371
- # STDERR.puts "--- gp01 dir/fname = #{dir} #{fname}"
372
- # FIXME dumb code
373
- view_line = File.readlines(draft).grep(/^.views /)
374
- raise "More than one .views call!" if view_line.size > 1
375
- raise "No .views call!" if view_line.size < 1
376
- view_line = view_line.first
377
-
378
- views = view_line[7..-1].split
379
- slug_dir = fname.sub(/.lt3$/, "")
380
- views.each do |view|
381
- vdir = "#@root/views/#{view}"
382
- dir = "#{vdir}/posts/#{slug_dir}/"
383
- Dir.mkdir(dir) unless Dir.exist?(dir)
384
- system("cp #{draft} #{dir}")
385
- Dir.chdir(dir) do
386
- html = draft.sub(/.lt3$/, ".html")
387
- STDERR.puts "--- gp05 into #{dir}: livetext #{draft} >#{html}"
388
- system("livetext #{draft} >#{html}")
389
-
390
- # copy from theme?
391
- theme = vdir + "/themes/standard"
392
- Dir.mkdir("sidebar") unless Dir.exist?("sidebar")
393
- system("cp #{theme}/sidebar/*.lt3 ./sidebar/")
394
- files = ["blog-generate.lt3", "blog-index.lt3", "global.lt3", "blog-head.lt3",
395
- "meta.lt3", "navbar.lt3"]
396
- files2 = files.map {|x| theme + "/" + x }
397
- # STDERR.puts "---- gp06: In #{Dir.pwd}: files = #{files.inspect}"
398
- files2.each do |f|
399
- # STDERR.puts "---- gp07: cp #{f} ."
400
- system("cp #{f} .")
401
- end
402
- # STDERR.puts "---- gp08: Files copied from theme"
403
-
404
- system("livetext blog-generate.lt3 >bgen.html")
405
- # STDERR.puts "---- gp09: Files went thru livetext"
406
- # files.each {|fname| system("rm ./#{fname}") }
407
- # system("rm -rf ./sidebar/")
408
- end
409
- # create framed pure slug (where?)
410
- end
411
- end
412
-
413
- ########
414
-
415
407
  def relink
416
408
  self.views.each {|view| generate_index(view) }
417
409
  end
@@ -437,11 +429,10 @@ STDERR.puts "--- gp05 into #{dir}: livetext #{draft} >#{html}"
437
429
  end
438
430
 
439
431
  def rebuild_post(file)
432
+ raise "Doesn't currently work"
440
433
  debug "Called rebuild_post(#{file.inspect})"
441
434
  raise ArgumentError unless file.is_a?(String)
442
435
  meta = process_post(file)
443
- # p meta
444
- # sleep 4
445
436
  @views_dirty ||= []
446
437
  @views_dirty << meta.views
447
438
  @views_dirty.flatten!
@@ -494,8 +485,6 @@ STDERR.puts "--- gp05 into #{dir}: livetext #{draft} >#{html}"
494
485
  end
495
486
 
496
487
  def make_slug(meta)
497
- # check_meta(meta, "makeslug")
498
- # meta.num = 9999 # FIXME
499
488
  raise ArgumentError unless meta.title.is_a?(String)
500
489
  label = '%04d' % meta.num # FIXME can do better
501
490
  slug0 = meta.title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
@@ -2,7 +2,7 @@
2
2
  if ! (Object.constants.include?(:RuneBlog) && RuneBlog.constants.include?(:Path))
3
3
 
4
4
  class RuneBlog
5
- VERSION = "0.1.79"
5
+ VERSION = "0.1.84"
6
6
 
7
7
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
8
8
  end
@@ -25,7 +25,7 @@ class RuneBlog::View
25
25
  end
26
26
 
27
27
  def local_index
28
- dir + "/generated/index.html"
28
+ dir + "/remote/index.html"
29
29
  end
30
30
 
31
31
  def index
@@ -39,7 +39,7 @@ class RuneBlog::View
39
39
  def publishable_files
40
40
  vdir = dir()
41
41
  files = [local_index()]
42
- others = Dir.entries(vdir + "/generated").grep(/^\d\d\d\d/).map {|x| "#{vdir}/generated/#{x}" }
42
+ others = Dir.entries(vdir + "/remote").grep(/^\d\d\d\d/).map {|x| "#{vdir}/remote/#{x}" }
43
43
  abort "FIXME... publishable_files"
44
44
  deep_assets = Dir["#{vdir}/themes/standard/assets/*"]
45
45
  deep_assets.each do |file| # Do this at view creation
@@ -27,11 +27,7 @@ spec = Gem::Specification.new do |s|
27
27
  main = Find.find("bin").to_a +
28
28
  Find.find("lib").to_a
29
29
 
30
- Dir.chdir("data") do
31
- system("tar zcvf standard.tgz standard/ >/dev/null 2>&1")
32
- end
33
-
34
- std_theme = ["data/standard.tgz"]
30
+ std_theme = ["themes/standard.tgz"]
35
31
 
36
32
  misc = %w[./README.lt3 ./README.md ./runeblog.gemspec]
37
33
  test = Find.find("test").to_a
@@ -19,7 +19,8 @@ def debug(str)
19
19
  end
20
20
 
21
21
  def make_post(x, title, teaser, body, views=[])
22
- STDERR.puts "\n========= make_post '#{title}'"
22
+ # STDERR.puts "\n========= make_post '#{title}'"
23
+ print "."
23
24
  meta = OpenStruct.new
24
25
  num = x.create_new_post(title, true, teaser: teaser, body: body, other_views: views)
25
26
  num
@@ -32,6 +33,10 @@ def show_lines(text)
32
33
  str
33
34
  end
34
35
 
36
+
37
+
38
+ puts
39
+
35
40
  system("rm -rf .blogs")
36
41
  RuneBlog.create_new_blog_repo('test_view', ".blogs/data")
37
42
  x = RuneBlog.new
@@ -61,36 +66,36 @@ EXCERPT
61
66
  Now, depending on what you consider "major," blah blah blah...
62
67
  BODY
63
68
 
64
- # x.change_view("computing") # 3 5 6
65
- #
66
- # make_post(x, "Elixir Conf coming up...", <<-EXCERPT, <<-BODY)
67
- # The next Elixir Conf is always coming up.
68
- # EXCERPT
69
- # I mean, unless the previous one was the last one ever, which I don't expect to
70
- # happen for a couple of decades.
71
- # BODY
72
- #
73
- # x.change_view("music") # 4 10
74
- #
75
- # make_post(x, "Does indie still matter?", <<-EXCERPT, <<-BODY)
76
- # Indie msic blah blah blah blah....
77
- # EXCERPT
78
- # And more about indie music.
79
- # BODY
80
- #
81
- # x.change_view("computing")
82
- #
83
- # make_post(x, "The genius of Scenic", <<-EXCERPT, <<-BODY)
84
- # Boyd Multerer is a genius.
85
- # EXCERPT
86
- # And so is Scenic.
87
- # BODY
88
- #
89
- # make_post(x, "The future of coding", <<-EXCERPT, <<-BODY)
90
- # Someday you can forget your text editor entirely.
91
- # EXCERPT
92
- # But that day hasn't come yet.
93
- # BODY
69
+ x.change_view("computing") # 3 5 6
70
+
71
+ make_post(x, "Elixir Conf coming up...", <<-EXCERPT, <<-BODY)
72
+ The next Elixir Conf is always coming up.
73
+ EXCERPT
74
+ I mean, unless the previous one was the last one ever, which I don't expect to
75
+ happen for a couple of decades.
76
+ BODY
77
+
78
+ x.change_view("music") # 4 10
79
+
80
+ make_post(x, "Does indie still matter?", <<-EXCERPT, <<-BODY)
81
+ Indie msic blah blah blah blah....
82
+ EXCERPT
83
+ And more about indie music.
84
+ BODY
85
+
86
+ x.change_view("computing")
87
+
88
+ make_post(x, "The genius of Scenic", <<-EXCERPT, <<-BODY)
89
+ Boyd Multerer is a genius.
90
+ EXCERPT
91
+ And so is Scenic.
92
+ BODY
93
+
94
+ make_post(x, "The future of coding", <<-EXCERPT, <<-BODY)
95
+ Someday you can forget your text editor entirely.
96
+ EXCERPT
97
+ But that day hasn't come yet.
98
+ BODY
94
99
 
95
100
  x.change_view("around_austin")
96
101
 
@@ -124,3 +129,4 @@ BODY
124
129
 
125
130
  x.change_view("around_austin")
126
131
 
132
+ puts
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runeblog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.79
4
+ version: 0.1.84
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-21 00:00:00.000000000 Z
11
+ date: 2019-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: livetext
@@ -61,7 +61,6 @@ files:
61
61
  - "./README.md"
62
62
  - "./runeblog.gemspec"
63
63
  - bin/blog
64
- - data/standard.tgz
65
64
  - lib/Javascript.stuff
66
65
  - lib/default.rb
67
66
  - lib/global.rb
@@ -78,6 +77,7 @@ files:
78
77
  - test/general_test.rb
79
78
  - test/make_blog.rb
80
79
  - test/test
80
+ - themes/standard.tgz
81
81
  homepage: https://github.com/Hal9000/runeblog
82
82
  licenses:
83
83
  - Ruby
Binary file