runeblog 0.2.51 → 0.2.52

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: 600dac0389d976fd41b8c3a5f4f63e4896a1b3f330525faa6b703dfb38e0b825
4
- data.tar.gz: 52472d46f783f209ad13e95f8e230c89173780a98867389a075833fb3cb1edd9
3
+ metadata.gz: fab29a6bc9b27d8b8390c07288d63a8d27c4131a47ddcecf5291e92a7877d1fa
4
+ data.tar.gz: 7a782cc946f7d541491755d6c592defaf58df51772b2815801fbc2a27af303d9
5
5
  SHA512:
6
- metadata.gz: 9a650511f857069328ec4295e4ab1c70add5730118b68c16d45113844215f8db540bad78580225228b24ae4b26022abda6ab1e5af487edc231360d1a1c50fbda
7
- data.tar.gz: 641d6ae9269a77d36929f36810ff779736cee66e81e0bb27660f8e7832f2f6ecce57977362a2128585789365d503a4f79b03580674293bf7a8575facadc296ac
6
+ metadata.gz: 56a454e863d21a642101e99de411f22cb2471b60d7f1575d1e6905d50273f3bbdf4ec1ac3a08bae55c5c41137588e0d4f12d388532cc61a369be232d5a2f226f
7
+ data.tar.gz: 8a4598adc7ac76950e588890db7fbb62d7f024934df04f0c9aed44098296a7b6de5b1fe6f4de82289516eaba010d64554c46df4a711b272c87c9ed6d7ac55d78
data/lib/helpers-repl.rb CHANGED
@@ -32,6 +32,8 @@ module RuneBlog::REPL
32
32
  "config" => :cmd_config,
33
33
  "manage $widget" => :cmd_manage,
34
34
 
35
+ "legacy" => :cmd_legacy,
36
+
35
37
  "list posts" => :cmd_list_posts,
36
38
  "lsp" => :cmd_list_posts,
37
39
 
@@ -187,25 +189,6 @@ module RuneBlog::REPL
187
189
  slug[0..3] + slug[4..-1]
188
190
  end
189
191
 
190
- def import(arg = nil)
191
- raise "Not implemented at present..."
192
- arg = nil if arg == ""
193
- arg ||= ask("Filename: ") # check validity later
194
- name = arg
195
- grep = `grep ^.title #{name}`
196
- @title = grep.sub(/^.title /, "")
197
- @slug = @blog.make_slug(@title) # import (not impl)
198
- @fname = @slug + ".lt3"
199
- result = system!("cp #{name} #@root/drafts/#@fname")
200
- raise CantCopy(name, "#@root/drafts/#@fname") unless result
201
-
202
- edit_initial_post(@fname)
203
- process_post(@fname)
204
- link_post_all_views(@meta)
205
- rescue => err
206
- error(err)
207
- end
208
-
209
192
  def tags_for_view(vname = @blog.view)
210
193
  Dir.chdir(vname) do
211
194
  fname = "tagpool"
data/lib/repl.rb CHANGED
@@ -287,6 +287,10 @@ puts "Got to #{__method__}"
287
287
  def cmd_new_post(arg, testing = false)
288
288
  reset_output
289
289
  check_empty(arg)
290
+ if @blog.views.empty?
291
+ puts "\n Create a view before creating the first post!\n "
292
+ return
293
+ end
290
294
  title = ask("\nTitle: ")
291
295
  puts
292
296
  @blog.create_new_post(title)
@@ -448,54 +452,92 @@ puts "Got to #{__method__}"
448
452
  @out
449
453
  end
450
454
 
455
+ def cmd_legacy(arg = nil)
456
+ # dir = ask("Dir = ")
457
+ dir = "sources/computing"
458
+ puts "Importing from: #{dir}"
459
+ files = Dir[dir/"**"]
460
+ files.each do |fname|
461
+ name = fname
462
+ cmd = "grep ^.title #{name}"
463
+ grep = `#{cmd}` # find .title
464
+ @title = grep.sub(/^.title /, "")
465
+ num = `grep ^.post #{name}`.sub(/^.post /, "").to_i
466
+ seq = @blog.get_sequence
467
+ tnum = File.basename(fname).to_i
468
+
469
+ raise "num != seq + 1" if num != seq + 1
470
+ raise "num != tnum" if num != tnum
471
+ seq = @blog.next_sequence
472
+ raise "num != seq" if num != seq
473
+
474
+ label = '%04d' % num
475
+ slug0 = @title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
476
+ @slug = "#{label}-#{slug0}"
477
+ @fname = @slug + ".lt3"
478
+ cmd = "cp #{name} #{@blog.root}/drafts/#@fname"
479
+ result = system!(cmd)
480
+ raise CantCopy(name, "#{@blog.root}/drafts/#@fname") unless result
481
+ puts(`ls -l #{@blog.root}/drafts`)
482
+ puts "@fname = #@fname"
483
+ puts "Pause..."
484
+ gets
485
+ @meta = @blog.process_post(@fname)
486
+ puts
487
+ sleep 2
488
+ end
489
+ rescue => err
490
+ error(err)
491
+ end
492
+
493
+ Help = <<-EOS
494
+
495
+ {Basics:} {Views:}
496
+ ------------------------------------------- -------------------------------------------
497
+ {h, help} This message {change view VIEW} Change current view
498
+ {q, quit} Exit the program {cv VIEW} Change current view
499
+ {v, version} Print version information {new view} Create a new view
500
+ {list views} List all views available
501
+ {lsv} Same as: list views
502
+
503
+ {Posts:} {Advanced:}
504
+ ------------------------------------------- -------------------------------------------
505
+ {p, post} Create a new post {config} Edit various system files
506
+ {new post} Same as p, post {customize} (BUGGY) Change set of tags, extra views
507
+ {lsp, list posts} List posts in current view {preview} Look at current (local) view in browser
508
+ {lsd, list drafts} List all drafts (all views) {browse} Look at current (published) view in browser
509
+ {delete ID [ID...]} Remove multiple posts {rebuild} Regenerate all posts and relink
510
+ {undelete ID} Undelete a post {publish} Publish (current view)
511
+ {edit ID} Edit a post {ssh} Login to remote server
512
+ {import ASSETS} Import assets (images, etc.) {manage WIDGET} Manage content/layout of a widget
513
+ EOS
514
+
451
515
  def cmd_help(arg, testing = false)
452
516
  reset_output
453
517
  check_empty(arg)
454
- msg = <<-EOS
455
-
456
- Commands:
457
-
458
- h, help This message
459
- q, quit Exit the program
460
- v, version Print version information
461
-
462
- change view VIEW Change current view
463
- cv VIEW Change current view
464
-
465
- new view Create a new view
466
-
467
- list views List all views available
468
- lsv Same as: list views
469
-
470
- config Edit various system files
471
- * customize (BUGGY) Change set of tags, extra views
472
-
473
- p, post Create a new post
474
- new post Same as post (create a post)
475
-
476
- * import ASSETS Import assets (images, etc.)
477
-
478
- lsp, list posts List posts in current view
479
-
480
- lsd, list drafts List all posts regardless of view
481
-
482
- delete ID [ID...] Remove multiple posts
483
- undelete ID Undelete a post
484
- edit ID Edit a post
485
-
486
- preview Look at current (local) view in browser
487
- browse Look at current (published) view in browser
488
- rebuild Regenerate all posts and relink
489
- publish Publish (current view)
490
- ssh Login to remote server
491
- EOS
518
+ msg = Help
492
519
  output msg
493
520
  msg.each_line do |line|
494
- next if testing
495
- line.chomp!
496
- s1, s2 = line[0..22], line[23..-1]
497
- print fx(s1, :bold)
498
- puts s2
521
+ e = line.each_char
522
+ first = true
523
+ loop do
524
+ s1 = ""
525
+ c = e.next
526
+ if c == "{"
527
+ s2 = first ? "" : " "
528
+ first = false
529
+ loop do
530
+ c = e.next
531
+ break if c == "}"
532
+ s2 << c
533
+ end
534
+ print fx(s2, :bold)
535
+ s2 = ""
536
+ else
537
+ s1 << c
538
+ end
539
+ print s1
540
+ end
499
541
  end
500
542
  puts unless testing
501
543
  @out
data/lib/runeblog.rb CHANGED
@@ -117,11 +117,14 @@ class RuneBlog
117
117
  Dir.chdir(dir) do
118
118
  views = _retrieve_metadata(:views)
119
119
  views.each do |v|
120
- unless @blog.view?(v)
121
- puts "Warning: '#{v}' is not a view"
120
+ puts "VIEW = #{v} dir = #{dir}"
121
+ unless self.view?(v)
122
+ puts "#{fx("Warning:", :red)} #{fx(v, :bold)} is not a view"
122
123
  next
123
124
  end
124
- system!("cp *html #@root/views/#{v}/remote")
125
+ puts "pwd = #{Dir.pwd}"
126
+ puts "cp *html #@root/views/#{v}/remote"
127
+ system!("cp *html #@root/views/#{v}/remote", show: true)
125
128
  end
126
129
  end
127
130
  rescue => err
@@ -154,12 +157,16 @@ class RuneBlog
154
157
  end
155
158
 
156
159
  def process_post(sourcefile)
157
- log!(enter: __method__, args: [dir], level: 2)
160
+ log!(enter: __method__, args: [sourcefile], level: 2)
158
161
  nslug = sourcefile.sub(/.lt3/, "")
159
162
  dir = @root/:posts/nslug
160
- create_dir(dir)
163
+ # puts "sourcefile = #{sourcefile}"
164
+ puts "-- dir = #{dir}\n pwd = #{Dir.pwd}\n @root = #@root"
165
+ gets
166
+ create_dirs(dir)
161
167
  # FIXME dependencies?
162
- xlate cwd: dir, src: sourcefile # , debug: true
168
+ xlate cwd: dir, src: @root/:drafts/sourcefile, debug: true
169
+ # puts `ls -l #{dir}`
163
170
  _deploy_local(dir)
164
171
  rescue => err
165
172
  _tmp_error(err)
@@ -398,12 +405,15 @@ class RuneBlog
398
405
  _tmp_error(err)
399
406
  end
400
407
 
408
+ def import_legacy_post(file, oldfile, testing = false)
409
+ end
410
+
401
411
  def edit_initial_post(file, testing = false)
402
412
  log!(enter: __method__, args: [file, testing], level: 3)
403
- debug "=== edit_initial_post #{file.inspect} => #{sourcefile}"
404
- result = system!("#@editor #{sourcefile} +8") unless testing
405
- raise EditorProblem(sourcefile) unless result
406
- process_post(sourcefile)
413
+ debug "=== edit_initial_post #{file.inspect} => #{file}"
414
+ result = system!("#@editor #{file} +8") unless testing
415
+ raise EditorProblem(file) unless result
416
+ process_post(file)
407
417
  nil
408
418
  rescue => err
409
419
  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.51"
5
+ VERSION = "0.2.52"
6
6
 
7
7
  path = Gem.find_files("runeblog").grep(/runeblog-/).first
8
8
  Path = File.dirname(path)
data/lib/xlate.rb CHANGED
@@ -17,10 +17,10 @@ def stale?(src, dst, deps, force = false)
17
17
  end
18
18
 
19
19
  def xlate(cwd: Dir.pwd, src:,
20
- dst: (strip = true; src.sub(/.lt3$/,"")),
20
+ dst: (strip = true; File.basename(src).sub(/.lt3$/,"")),
21
21
  deps: [], copy: nil, debug: false, force: false)
22
22
  src += LEXT unless src.end_with?(LEXT)
23
- dst += ".html" unless dst.end_with?(".html") || strip
23
+ dst += ".html" unless (dst.end_with?(".html")) # || strip)
24
24
  indent = " "*12
25
25
  Dir.chdir(cwd) do
26
26
  if debug
@@ -30,6 +30,7 @@ def xlate(cwd: Dir.pwd, src:,
30
30
  STDERR.puts "#{indent} copy: #{copy}" if copy
31
31
  end
32
32
  stale = stale?(src, dst, deps, force)
33
+ # puts "stale? src = #{src}\n dst = #{dst}\n #{stale}"
33
34
  if stale
34
35
  rc = system("livetext #{src} >#{dst}")
35
36
  STDERR.puts "...completed (shell returned #{rc})" if debug
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.51
4
+ version: 0.2.52
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-25 00:00:00.000000000 Z
11
+ date: 2019-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: livetext