runeblog 0.1.84 → 0.1.85

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: b18c3d8c6c7a36be892a6ad4f5d1343839da39d8a151ac2a9600cb29389a855d
4
- data.tar.gz: e18259284be9484e35e800c60ee531b4678ea9ad9c1ce85994d36362d92d7f66
3
+ metadata.gz: cb6100ad69994f06dcb9d75dcef71d5f485f56119725efb419607c3ca5521b89
4
+ data.tar.gz: 025a5cc03d7203cd32db22c2bb283c3db7ad6aa1eb4b110ec5f1613bb5740fe9
5
5
  SHA512:
6
- metadata.gz: 19bcba26366d495a4c879f79b5fcc0b068cbca46f1a40e1f2959864bd7ed9b9d5a5c80cf07d5aeeb0fde5d72ce146d63b6aff99df81d5e1b62b5a8689357da91
7
- data.tar.gz: 947861e8132ac5fa801398e81fed3e0fad60d1a10f210478e8a248583e57a40b6000b7b7940cfc56fadd11d73c2328f21bca137168a81b96d1855ca4a8ecf519
6
+ metadata.gz: b89cca81ab11b4a2b7ea4694cb0f9c6f875f0691629a7eb14daa4ce3dc6b77b167db71eb5be3abc4777da3940ccc62a250d513119cebe775f6af09bea50c781d
7
+ data.tar.gz: 7b495793aeb39e03d7ca07002c66fcf309d330fe877b712ceaa524cd7e09d8da25dae2d9fcfd64ba014aa291fc177981b254fc0d5063047142b38d65741ad43c
@@ -65,6 +65,17 @@ module RuneBlog::Helpers
65
65
  vals
66
66
  end
67
67
 
68
+ def put_config(root:, view:"test_view", editor: "/bin/vim")
69
+ Dir.mkdir(root) unless Dir.exist?(root)
70
+ Dir.chdir(root) do
71
+ File.open("config", "w") do |cfg|
72
+ cfg.puts "root: #{root}"
73
+ cfg.puts "current_view: #{view}"
74
+ cfg.puts "editor: #{editor}"
75
+ end
76
+ end
77
+ end
78
+
68
79
  def write_config(obj, file)
69
80
  hash = obj.to_h
70
81
  # Dir.chdir(::Home)
@@ -86,9 +97,10 @@ module RuneBlog::Helpers
86
97
  # end
87
98
  end
88
99
 
89
- def new_dotfile(root: "./.blogs/data", current_view: "no_default", editor: "vi")
90
- raise BlogAlreadyExists if Dir.exist?(".blogs")
91
- Dir.mkdir(".blogs")
100
+ def new_dotfile(root: ".blogs", current_view: "test_view", editor: "vi")
101
+ # raise BlogAlreadyExists if Dir.exist?(".blogs")
102
+ # Dir.mkdir(".blogs")
103
+ root = Dir.pwd + "/" + root
92
104
  x = OpenStruct.new
93
105
  x.root, x.current_view, x.editor = root, current_view, editor
94
106
  write_config(x, ".blogs/" + RuneBlog::ConfigFile)
@@ -101,8 +113,10 @@ module RuneBlog::Helpers
101
113
  end
102
114
 
103
115
  def subdirs(dir)
116
+ STDERR.puts "== SUB dir = #{dir}"
104
117
  verify(Dir.exist?(dir) => "Directory #{dir} not found")
105
118
  dirs = Dir.entries(dir) - %w[. ..]
119
+ STDERR.puts "== SUB dirs = #{dirs.inspect}"
106
120
  dirs.reject! {|x| ! File.directory?("#@root/views/#{x}") }
107
121
  dirs
108
122
  end
@@ -20,7 +20,11 @@ STDERR.reopen(errfile)
20
20
  =end
21
21
 
22
22
  def init_liveblog # FIXME - a lot of this logic sucks
23
- @blog = $_blog = RuneBlog.new(false)
23
+ here = Dir.pwd
24
+ dir = here
25
+ loop { dir = Dir.pwd; break if File.exist?("config"); Dir.chdir("..") }
26
+ Dir.chdir(here)
27
+ @blog = $_blog = RuneBlog.new(dir)
24
28
  @root = @blog.root
25
29
  @view = @blog.view
26
30
  @view_name = @blog.view.name
@@ -236,6 +240,7 @@ def finalize
236
240
  @slug = @blog.make_slug(@meta)
237
241
  slug_dir = @slug
238
242
  @postdir = @blog.view.dir + "/posts/#{slug_dir}"
243
+ STDERR.puts "--- finalize: pwd = #{Dir.pwd} postdir = #@postdir"
239
244
  write_post
240
245
  @meta
241
246
  end
@@ -139,6 +139,7 @@ end
139
139
  class RuneBlog::ViewPost
140
140
  attr_reader :path, :nslug, :aslug, :title, :date,
141
141
  :teaser_text
142
+
142
143
  def initialize(view, postdir)
143
144
  # Assumes already parsed/processed
144
145
  @blog = RuneBlog.blog || raise(NoBlogAccessor)
@@ -41,40 +41,54 @@ class RuneBlog
41
41
 
42
42
  include Helpers
43
43
 
44
- def self.create_new_blog_repo(first_view, dir = ".blogs/data")
44
+ def self.create_new_blog_repo(dir = ".blogs")
45
45
  raise ArgumentError unless dir.is_a?(String) && ! dir.empty?
46
46
  root_dir = Dir.pwd + "/" + dir
47
- raise BlogRepoAlreadyExists if Dir.exist?(root_dir)
48
- new_dotfile(root: root_dir, current_view: first_view)
49
- create_dir(dir)
50
- Dir.chdir(dir) do
47
+ self.create(dir)
48
+ rescue => err
49
+ puts "Can't create blog repo: '#{dir}' - #{err}"
50
+ puts err.backtrace.join("\n")
51
+ end
52
+
53
+ def self.create(root = ".blogs")
54
+ # Crude - FIXME later - # What views are there? Publishing, etc.
55
+ self.blog = self # Weird. Like a singleton - dumbass circular dependency?
56
+ $_blog = self # Dumber still?
57
+ root = Dir.pwd + "/" + root
58
+ raise BlogRepoAlreadyExists if Dir.exist?(root)
59
+ create_dir(root)
60
+ Dir.chdir(root) do
51
61
  create_dir("drafts")
52
62
  create_dir("views")
53
63
  #? create_dir("assets")
54
64
  new_sequence
55
65
  end
56
- blog = self.new
57
- blog.create_view(first_view)
58
- rescue => err
59
- puts "Can't create blog repo: '#{dir}' - #{err}"
60
- puts err.backtrace.join("\n")
66
+ put_config(root: root)
67
+ @blog = self.new(root)
68
+ @blog.create_view("test_view")
69
+ @blog
70
+ end
71
+
72
+ def self.open(root = ".blogs")
73
+ # Crude - FIXME later - # What views are there? Publishing, etc.
74
+ self.blog = self # Weird. Like a singleton - dumbass circular dependency?
75
+ $_blog = self # Dumber still?
76
+ root = Dir.pwd + "/" + root
77
+ blog = self.new(root)
61
78
  end
62
79
 
63
- def initialize(top = true) # at top? always assumes existing blog
80
+ def initialize(root_dir = ".blogs") # always assumes existing blog
64
81
  # Crude - FIXME later - # What views are there? Publishing, etc.
65
82
  self.class.blog = self # Weird. Like a singleton - dumbass circular dependency?
66
83
  $_blog = self # Dumber still?
67
- dir = ""
68
- unless top
69
- md = Dir.pwd.match(%r[.*.blogs])
70
- dir = md[0]
71
- end
72
- file = dir.empty? ? ConfigFile : dir + "/" + ConfigFile
84
+
85
+ @root = root_dir
86
+ file = @root + "/" + ConfigFile
87
+ STDERR.puts "--- init: file = #{file}"
73
88
  errmsg = "No config file! file = #{file.inspect} dir = #{Dir.pwd}"
74
89
  raise errmsg unless File.exist?(file)
75
- # Hmm. current_view doesn't belong?
76
- @root, @view_name, @editor = read_config(file, :root, :current_view, :editor)
77
90
 
91
+ @root, @view_name, @editor = read_config(file, :root, :current_view, :editor)
78
92
  md = Dir.pwd.match(%r[.*/views/(.*?)/])
79
93
  @view_name = md[1] if md
80
94
  @views = get_views
@@ -348,6 +362,8 @@ class RuneBlog
348
362
  raise "No .views call!" if view_line.size < 1
349
363
  view_line = view_line.first
350
364
  views = view_line[7..-1].split
365
+ STDERR.puts "--- gv: #{views.inspect}"
366
+ views
351
367
  end
352
368
 
353
369
  # Remember: A post in multiple views will trigger multiple
@@ -393,6 +409,7 @@ class RuneBlog
393
409
  copy(lt3, staging)
394
410
  html = noext[5..-1]
395
411
  Dir.chdir(staging) do
412
+ STDERR.puts "--- gp: pwd = #{Dir.pwd} draft = #{draft} html = #{html}"
396
413
  livetext draft, html
397
414
  # link to POST??
398
415
  copy html, "../remote"
@@ -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.84"
5
+ VERSION = "0.1.85"
6
6
 
7
7
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
8
8
  end
@@ -38,14 +38,14 @@ end
38
38
  puts
39
39
 
40
40
  system("rm -rf .blogs")
41
- RuneBlog.create_new_blog_repo('test_view', ".blogs/data")
42
- x = RuneBlog.new
41
+ RuneBlog.create_new_blog_repo(".blogs")
42
+ x = RuneBlog.new(".blogs")
43
43
 
44
44
  x.create_view("around_austin") # FIXME remember view title!
45
45
 
46
46
  # Hack:
47
47
  if File.exist?("publish")
48
- system("cp publish .blogs/data/views/around_austin/publish")
48
+ system("cp publish .blogs/views/around_austin/publish")
49
49
  end
50
50
 
51
51
  x.create_view("computing")
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.84
4
+ version: 0.1.85
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-09-07 00:00:00.000000000 Z
11
+ date: 2019-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: livetext