runeblog 0.2.56 → 0.2.61

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,12 +9,12 @@ class RuneBlog::Post
9
9
 
10
10
  include RuneBlog::Helpers
11
11
 
12
- def self.files(num, root)
13
- log!(enter: __method__, args: [num, root], level: 3)
14
- files = ::Find.find(root).to_a
15
- result = files.grep(/#{prefix(num)}-/)
16
- result
17
- end
12
+ # def self.files(num, root)
13
+ # log!(enter: __method__, args: [num, root], level: 3)
14
+ # files = ::Find.find(root).to_a
15
+ # result = files.grep(/#{prefix(num)}-/)
16
+ # result
17
+ # end
18
18
 
19
19
  def self.load(post)
20
20
  log!(enter: __method__, args: [post], level: 3)
@@ -15,7 +15,6 @@ module RuneBlog::REPL
15
15
  end
16
16
 
17
17
  def cmd_quit(arg, testing = false)
18
- check_empty(arg)
19
18
  RubyText.stop
20
19
  sleep 0.1
21
20
  cmd_clear(nil)
@@ -24,14 +23,12 @@ module RuneBlog::REPL
24
23
  end
25
24
 
26
25
  def cmd_clear(arg, testing = false)
27
- check_empty(arg)
28
26
  STDSCR.cwin.clear
29
27
  STDSCR.cwin.refresh
30
28
  end
31
29
 
32
30
  def cmd_version(arg, testing = false)
33
31
  reset_output
34
- check_empty(arg)
35
32
  output RuneBlog::VERSION
36
33
  puts fx("\n RuneBlog", :bold), fx(" v #{RuneBlog::VERSION}\n", Red) unless testing
37
34
  @out
@@ -64,14 +61,12 @@ module RuneBlog::REPL
64
61
  end
65
62
 
66
63
  def _manage_pinned(arg, testing = false) # cloned from manage_links
67
- check_empty(arg)
68
64
  dir = @blog.view.dir/"themes/standard/widgets/pinned"
69
65
  data = dir/"list.data"
70
66
  edit_file(data)
71
67
  end
72
68
 
73
69
  def _manage_navbar(arg, testing = false) # cloned from manage_pages
74
- check_empty(arg)
75
70
  dir = @blog.view.dir/"themes/standard/navbar"
76
71
  files = Dir.entries(dir) - %w[. .. navbar.lt3]
77
72
  new_item = " [New item] "
@@ -107,7 +102,6 @@ module RuneBlog::REPL
107
102
  end
108
103
 
109
104
  def _manage_pages(arg, testing = false)
110
- check_empty(arg)
111
105
  dir = @blog.view.dir/"themes/standard/widgets/pages"
112
106
  # Assume child files already generated (and list.data??)
113
107
  data = dir/"list.data"
@@ -143,14 +137,12 @@ module RuneBlog::REPL
143
137
  end
144
138
 
145
139
  def cmd_import(arg, testing = false)
146
- check_empty(arg)
147
140
  files = ask("\n File(s) = ")
148
141
  system!("cp #{files} #{@blog.root}/views/#{@blog.view.name}/assets/")
149
142
  end
150
143
 
151
144
  def cmd_browse(arg, testing = false)
152
145
  reset_output
153
- check_empty(arg)
154
146
  url = @blog.view.publisher.url
155
147
  if url.nil?
156
148
  output! "Publish first."
@@ -164,8 +156,11 @@ module RuneBlog::REPL
164
156
 
165
157
  def cmd_preview(arg, testing = false)
166
158
  reset_output
167
- check_empty(arg)
168
159
  local = @blog.view.local_index
160
+ unless File.exist?(local)
161
+ puts "\n No index. Rebuilding..."
162
+ cmd_rebuild(nil)
163
+ end
169
164
  result = system!("open #{local}")
170
165
  raise CantOpen(local) unless result
171
166
  @out
@@ -182,7 +177,6 @@ module RuneBlog::REPL
182
177
  # Future Hal says please refactor this
183
178
  puts unless testing
184
179
  reset_output
185
- check_empty(arg)
186
180
  unless @blog.view.can_publish?
187
181
  msg = "Can't publish... see globals.lt3"
188
182
  puts msg unless testing
@@ -225,7 +219,6 @@ module RuneBlog::REPL
225
219
  def cmd_rebuild(arg, testing = false)
226
220
  debug "Starting cmd_rebuild..."
227
221
  reset_output
228
- check_empty(arg)
229
222
  puts unless testing
230
223
  @blog.generate_view(@blog.view)
231
224
  @blog.generate_index(@blog.view)
@@ -285,7 +278,6 @@ module RuneBlog::REPL
285
278
 
286
279
  def cmd_new_post(arg, testing = false)
287
280
  reset_output
288
- check_empty(arg)
289
281
  if @blog.views.empty?
290
282
  puts "\n Create a view before creating the first post!\n "
291
283
  return
@@ -358,7 +350,6 @@ module RuneBlog::REPL
358
350
 
359
351
  def cmd_list_views(arg, testing = false)
360
352
  reset_output("\n")
361
- check_empty(arg)
362
353
  puts unless testing
363
354
  @blog.views.each do |v|
364
355
  v = v.to_s
@@ -372,7 +363,6 @@ module RuneBlog::REPL
372
363
 
373
364
  def cmd_list_posts(arg, testing = false)
374
365
  reset_output
375
- check_empty(arg)
376
366
  posts = @blog.posts # current view
377
367
  str = @blog.view.name + ":\n"
378
368
  output str
@@ -395,7 +385,6 @@ module RuneBlog::REPL
395
385
 
396
386
  def cmd_list_drafts(arg, testing = false)
397
387
  reset_output
398
- check_empty(arg)
399
388
  drafts = @blog.drafts # current view
400
389
  if drafts.empty?
401
390
  output! "No drafts"
@@ -416,7 +405,6 @@ module RuneBlog::REPL
416
405
 
417
406
  def cmd_list_assets(arg, testing = false)
418
407
  reset_output
419
- check_empty(arg)
420
408
  dir = @blog.view.dir + "/assets"
421
409
  assets = Dir[dir + "/*"]
422
410
  if assets.empty?
@@ -512,7 +500,6 @@ module RuneBlog::REPL
512
500
 
513
501
  def cmd_help(arg, testing = false)
514
502
  reset_output
515
- check_empty(arg)
516
503
  msg = Help
517
504
  output msg
518
505
  msg.each_line do |line|
@@ -331,8 +331,11 @@ class RuneBlog
331
331
  text = nil
332
332
  @theme = @view.dir/"themes/standard"
333
333
  post_entry_name = @theme/"blog/post_entry.lt3"
334
+ # STDERR.puts "-- @pename = #{post_entry_name}"
335
+ # STDERR.puts "-- @pe = #{@_post_entry.inspect}"
334
336
  depend = [post_entry_name]
335
- xlate src: post_entry_name, dst: "/tmp/post_entry.html", deps: depend # , debug: true
337
+ xlate src: post_entry_name, dst: "/tmp/post_entry.html" # , deps: depend # , debug: true
338
+ # STDERR.puts "-- xlate result: #{`ls -l /tmp/post_entry.html`}"
336
339
  @_post_entry ||= File.read("/tmp/post_entry.html")
337
340
  vp = post_lookup(id)
338
341
  nslug, aslug, title, date, teaser_text =
@@ -347,8 +350,7 @@ class RuneBlog
347
350
  _tmp_error(err)
348
351
  end
349
352
 
350
- def collect_recent_posts(file)
351
- log!(enter: __method__, args: [file], level: 3)
353
+ def _sorted_posts
352
354
  posts = nil
353
355
  dir_posts = @vdir/:posts
354
356
  entries = Dir.entries(dir_posts)
@@ -362,18 +364,31 @@ class RuneBlog
362
364
  nb = b[bi..(bi+3)].to_i
363
365
  nb <=> na
364
366
  end # sort descending
365
- posts = posts[0..19] # return 20 at most
367
+ return posts[0..19] # return 20 at most
368
+ end
369
+
370
+ def collect_recent_posts(file)
371
+ log!(enter: __method__, args: [file], level: 3)
366
372
  text = <<-HTML
367
373
  <html>
368
374
  <head><link rel="stylesheet" href="etc/blog.css"></head>
369
375
  <body>
370
376
  HTML
377
+ posts = _sorted_posts
378
+ STDERR.puts "Posts = "
379
+ posts.each {|x| STDERR.puts " " + x }
371
380
  wanted = [8, posts.size].min # estimate how many we want?
372
381
  enum = posts.each
382
+ entries = []
373
383
  wanted.times do
374
384
  postid = File.basename(enum.next)
375
385
  postid = postid.to_i
376
- text << index_entry(postid) # side effect! calls _out
386
+ # STDERR.puts "-- postid = #{postid}"
387
+ # posts.each {|x| STDERR.puts " #{x}" }
388
+ entry = index_entry(postid)
389
+ # STDERR.puts "-- entry = #{entry.size} chars"
390
+ entries << entry
391
+ text << entry
377
392
  end
378
393
  text << "</body></html>"
379
394
  File.write(@vdir/:remote/file, text)
@@ -432,18 +447,29 @@ class RuneBlog
432
447
  _tmp_error(err)
433
448
  end
434
449
 
450
+ def _hack_pinned_rebuild(view)
451
+ tmp = "/tmp/pinned.lt3"
452
+ File.open(tmp, "w") do |f|
453
+ f.puts ".mixin liveblog\n.pinned_rebuild #{view}"
454
+ end
455
+ xlate src: tmp, dst: "/tmp/junk.html"
456
+ system("rm -f #{tmp} /tmp/junk.html")
457
+ end
458
+
435
459
  def generate_view(view) # huh?
436
460
  log!(enter: __method__, args: [view])
437
461
  vdir = @root/:views/view
438
462
  @theme = @root/:views/view/:themes/:standard
439
463
  depend = [vdir/"remote/etc/blog.css", @theme/"global.lt3",
440
- @theme/"blog/head.lt3", @theme/"navbar/navbar.lt3",
464
+ @theme/"blog/head.lt3",
465
+ # @theme/"navbar/navbar.lt3",
441
466
  @theme/"blog/index.lt3"] # FIXME what about assets?
442
467
  xlate cwd: vdir/"themes/standard/etc", deps: depend,
443
468
  src: "blog.css.lt3", copy: vdir/"remote/etc/blog.css" # , debug: true
444
469
  xlate cwd: vdir/"themes/standard", deps: depend, force: true,
445
470
  src: "blog/generate.lt3", dst: vdir/:remote/"index.html"
446
471
  copy("#{vdir}/assets/*", "#{vdir}/remote/assets/")
472
+ # _hack_pinned_rebuild(view) # FIXME experimental
447
473
  copy_widget_html(view)
448
474
  rescue => err
449
475
  _tmp_error(err)
@@ -2,7 +2,7 @@
2
2
  if ! (Object.constants.include?(:RuneBlog) && RuneBlog.constants.include?(:Path))
3
3
 
4
4
  class RuneBlog
5
- VERSION = "0.2.56"
5
+ VERSION = "0.2.61"
6
6
 
7
7
  path = Gem.find_files("runeblog").grep(/runeblog-/).first
8
8
  Path = File.dirname(path)
@@ -20,7 +20,7 @@ spec = Gem::Specification.new do |s|
20
20
  s.authors = ["Hal Fulton"]
21
21
  s.email = 'rubyhacker@gmail.com'
22
22
  s.executables << "blog"
23
- s.add_runtime_dependency 'livetext', '~> 0.8', '>= 0.8.94'
23
+ s.add_runtime_dependency 'livetext', '~> 0.8', '>= 0.8.95'
24
24
  s.add_runtime_dependency 'rubytext', '~> 0.1', '>= 0.1.16'
25
25
 
26
26
  # Files...
@@ -78,7 +78,7 @@ x.generate_view("around_austin")
78
78
  debug("-- change_view: #{bold('around_austin')}")
79
79
  x.change_view("around_austin") # 1 2 7 8 9
80
80
 
81
- make_post(x, "What's at Stubbs...", <<-EXCERPT, <<-BODY, [])
81
+ make_post(x, "What's at Stubbs...", <<-EXCERPT, <<-BODY)
82
82
  Stubbs has been around for longer than civilization.
83
83
  EXCERPT
84
84
  That's a good thing. But their music isn't always the greatest.
@@ -87,6 +87,7 @@ BODY
87
87
  make_post(x, "The new amphitheatre is overrated", <<-EXCERPT, <<-BODY)
88
88
  It used to be that all major concerts played the Erwin Center.
89
89
  EXCERPT
90
+ .pin around_austin
90
91
  Now, depending on what you consider "major," blah blah blah...
91
92
  BODY
92
93
 
@@ -137,7 +138,7 @@ EXCERPT
137
138
  This is about Sabine St, blah blah lorem ipsum dolor...
138
139
  BODY
139
140
 
140
- make_post(x, "Remember Modest Mouse?", <<-EXCERPT, <<-BODY, [])
141
+ make_post(x, "Remember Modest Mouse?", <<-EXCERPT, <<-BODY)
141
142
  They date to the 90s or before.
142
143
  EXCERPT
143
144
  But I first heard of them
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.2.56
4
+ version: 0.2.61
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-10-29 00:00:00.000000000 Z
11
+ date: 2019-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: livetext
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '0.8'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.8.94
22
+ version: 0.8.95
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '0.8'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.8.94
32
+ version: 0.8.95
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rubytext
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -68,7 +68,6 @@ files:
68
68
  - empty_view/remote/banner/austin-pano.jpg
69
69
  - empty_view/remote/banner/top.html
70
70
  - empty_view/remote/etc/GIT_IS_DUMB
71
- - empty_view/remote/navbar/GIT_IS_DUMB
72
71
  - empty_view/remote/permalink/GIT_IS_DUMB
73
72
  - empty_view/themes/standard/README
74
73
  - empty_view/themes/standard/banner/about.lt3
@@ -76,7 +75,7 @@ files:
76
75
  - empty_view/themes/standard/banner/blog-banner.jpg
77
76
  - empty_view/themes/standard/banner/contact.lt3
78
77
  - empty_view/themes/standard/banner/faq.lt3
79
- - empty_view/themes/standard/banner/navbar.lt3
78
+ - empty_view/themes/standard/banner/list.data
80
79
  - empty_view/themes/standard/banner/top.html
81
80
  - empty_view/themes/standard/blog/generate.lt3
82
81
  - empty_view/themes/standard/blog/head.lt3
@@ -87,10 +86,6 @@ files:
87
86
  - empty_view/themes/standard/etc/favicon.ico
88
87
  - empty_view/themes/standard/etc/misc.js
89
88
  - empty_view/themes/standard/global.lt3
90
- - empty_view/themes/standard/navbar/about.lt3
91
- - empty_view/themes/standard/navbar/contact.lt3
92
- - empty_view/themes/standard/navbar/faq.lt3
93
- - empty_view/themes/standard/navbar/navbar.lt3
94
89
  - empty_view/themes/standard/post/generate.lt3
95
90
  - empty_view/themes/standard/post/head.lt3
96
91
  - empty_view/themes/standard/post/index.lt3
@@ -1,17 +0,0 @@
1
- . --------------------------------------------------
2
- . This defines the content of the navigation bar.
3
- . The first one is a special case.
4
- . The others are understood to refer to .lt3 files
5
- . such as navbar/about.lt3 (which is processed into
6
- . HTML).
7
- . The title may be more than one word. Quotes are
8
- . not needed.
9
- . --------------------------------------------------
10
-
11
- .navbar2
12
- index Home
13
- about About
14
- contact Contact
15
- faq FAQ
16
- .end
17
-
@@ -1,18 +0,0 @@
1
- . --------------------------------------------------
2
- . This is a sample file typical of page referenced
3
- . directly from the navigation bar.
4
- . It is like a special case of a page in the "pages"
5
- . widget.
6
- . --------------------------------------------------
7
-
8
- .set this.title="About me"
9
- . make this better later
10
- <html><body>
11
- <div class="content container-fluid mt-4">
12
- <div class="row">
13
- <h1>$this.title</h1>
14
- . content starts here...
15
- Blah blah blah...
16
- </div>
17
- </div>
18
- </body></html>
@@ -1,18 +0,0 @@
1
- . --------------------------------------------------
2
- . This is a sample file typical of page referenced
3
- . directly from the navigation bar.
4
- . It is like a special case of a page in the "pages"
5
- . widget.
6
- . --------------------------------------------------
7
-
8
- .set this.title="Contact"
9
- . make this better later
10
- <html><body>
11
- <div class="content container-fluid mt-4">
12
- <div class="row">
13
- <h1>$this.title</h1>
14
- . content starts here...
15
- How to contact me by email, smoke signals, ICBM, seance, ...
16
- </div>
17
- </div>
18
- </body></html>
@@ -1 +0,0 @@
1
- .include ../widgets/pages/faq.lt3
@@ -1,16 +0,0 @@
1
- . --------------------------------------------------
2
- . This defines the content of the navigation bar.
3
- . The first one is a special case.
4
- . The others are understood to refer to .lt3 files
5
- . such as navbar/about.lt3 (which is processed into
6
- . HTML).
7
- . The title may be more than one word. Quotes are
8
- . not needed.
9
- . --------------------------------------------------
10
-
11
- .navbar
12
- about About
13
- contact Contact
14
- faq FAQ
15
- .end
16
-