runeblog 0.0.82 → 0.0.83
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/helpers-blog.rb +88 -36
- data/lib/post.rb +2 -0
- data/lib/runeblog.rb +16 -50
- data/lib/skeleton.rb +3 -0
- data/lib/version.rb +1 -1
- data/lib/view.rb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91e43d12b26a11fa3a918c8770f677a5f22f744e
|
4
|
+
data.tar.gz: ed5d4b517cb59294fc4a632d686f5c8e71a0d06f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ad7d9bb119e863f66c786a3e06152c9eb2b64725670d7d2f90e27b8ce3a3a86301e0e4020903ac24fd2124241234f49044db1003b062ef4dd41cc10657bfb63
|
7
|
+
data.tar.gz: e517a33878737d6ae901423a9869f5b5cbd13089e01d2f7c313aeb16c9f2e35174376e1eb5780429b7893f3af969c0fecf1529b3e6494516f236c98b5f6974e8
|
data/lib/helpers-blog.rb
CHANGED
@@ -1,42 +1,94 @@
|
|
1
|
-
|
2
|
-
cmd = "mkdir -p #{dir} >/dev/null 2>&1"
|
3
|
-
result = system(cmd)
|
4
|
-
raise "Can't create #{dir}" unless result
|
5
|
-
end
|
6
|
-
|
7
|
-
def interpolate(str)
|
8
|
-
wrap = "<<-EOS\n#{str}\nEOS"
|
9
|
-
eval wrap
|
10
|
-
end
|
1
|
+
module RuneBlog::Helpers
|
11
2
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
3
|
+
def read_config(file, *syms)
|
4
|
+
lines = File.readlines(file).map(&:chomp)
|
5
|
+
obj = OpenStruct.new
|
6
|
+
lines.each do |line|
|
7
|
+
key, val = line.split(" ", 2)
|
8
|
+
key = key[0..-2] # remove colon
|
9
|
+
obj.send(key+"=", val)
|
10
|
+
end
|
11
|
+
return obj if syms.empty?
|
12
|
+
vals = []
|
13
|
+
syms.each {|sym| vals << obj.send(sym) }
|
14
|
+
return vals
|
15
|
+
rescue => err
|
16
|
+
puts "Something hit the fan: #{err}"
|
17
|
+
puts err.backtrace
|
18
|
+
exit
|
19
|
+
end
|
17
20
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
rescue => err
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
21
|
+
def huh_read_config(file, *syms)
|
22
|
+
lines = File.readlines(file).map(&:chomp)
|
23
|
+
obj = OpenStruct.new
|
24
|
+
lines.each do |line|
|
25
|
+
key, val = line.split(" ", 2)
|
26
|
+
key = key[0..-2] # remove colon
|
27
|
+
obj.send(key+"=", val)
|
28
|
+
end
|
29
|
+
@deployer = RuneBlog::Deployment.new(obj)
|
30
|
+
obj
|
31
|
+
rescue => err
|
32
|
+
puts "Something hit the fan: #{err}"
|
33
|
+
puts err.backtrace
|
34
|
+
exit
|
35
|
+
end
|
33
36
|
|
34
|
-
def write_config(obj, file)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
def write_config(obj, file)
|
38
|
+
hash = obj.to_h
|
39
|
+
File.open(file, "w") do |f|
|
40
|
+
hash.each_pair do |key, val|
|
41
|
+
f.puts "#{key}: #{val}"
|
42
|
+
end
|
39
43
|
end
|
40
44
|
end
|
41
|
-
end
|
42
45
|
|
46
|
+
def get_views # read from filesystem
|
47
|
+
dirs = subdirs("#@root/views/").sort
|
48
|
+
dirs.map {|name| RuneBlog::View.new(name) }
|
49
|
+
end
|
50
|
+
|
51
|
+
def new_dotfile(root: "data", current_view: "no_default", editor: "vi")
|
52
|
+
x = OpenStruct.new
|
53
|
+
x.root, x.current_view, x.editor = root, current_view, editor
|
54
|
+
write_config(x, RuneBlog::DotFile)
|
55
|
+
end
|
56
|
+
|
57
|
+
def new_sequence
|
58
|
+
File.write("sequence", 0)
|
59
|
+
File.write("VERSION", "#{RuneBlog::VERSION}\n" +
|
60
|
+
"Blog created: " + Time.now.to_s)
|
61
|
+
end
|
62
|
+
|
63
|
+
def subdirs(dir)
|
64
|
+
dirs = Dir.entries(dir) - %w[. ..]
|
65
|
+
dirs.reject! {|x| ! File.directory?("#@root/views/#{x}") }
|
66
|
+
dirs
|
67
|
+
end
|
68
|
+
|
69
|
+
def find_src_slugs
|
70
|
+
files = Dir.entries("#@root/src/").grep /\d{4}.*.lt3$/
|
71
|
+
files.map! {|f| File.basename(f) }
|
72
|
+
files = files.sort.reverse
|
73
|
+
files
|
74
|
+
end
|
75
|
+
|
76
|
+
def create_dir(dir)
|
77
|
+
return if File.exist?(dir) && File.directory?(dir)
|
78
|
+
cmd = "mkdir -p #{dir} >/dev/null 2>&1"
|
79
|
+
result = system(cmd)
|
80
|
+
raise "Can't create #{dir}" unless result
|
81
|
+
end
|
82
|
+
|
83
|
+
def interpolate(str)
|
84
|
+
wrap = "<<-EOS\n#{str}\nEOS"
|
85
|
+
eval wrap
|
86
|
+
end
|
87
|
+
|
88
|
+
def error(err) # Hmm, this is duplicated
|
89
|
+
str = "\n Error: #{err}"
|
90
|
+
puts str
|
91
|
+
puts err.backtrace
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
data/lib/post.rb
CHANGED
data/lib/runeblog.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'pp'
|
2
|
-
|
3
1
|
require 'find'
|
4
2
|
require 'yaml' # get rid of YAML later
|
5
3
|
require 'livetext'
|
@@ -14,36 +12,38 @@ require 'version'
|
|
14
12
|
###
|
15
13
|
|
16
14
|
class RuneBlog
|
15
|
+
|
16
|
+
DotFile = ".blog"
|
17
17
|
|
18
18
|
class << self
|
19
19
|
attr_accessor :blog
|
20
|
+
include Helpers
|
20
21
|
end
|
21
22
|
|
22
23
|
attr_reader :root, :views, :sequence
|
23
24
|
attr_accessor :view # overridden
|
24
25
|
|
26
|
+
include Helpers
|
27
|
+
|
25
28
|
def self.create_new_blog(dir = "data")
|
26
|
-
|
27
|
-
x.root, x.current_view, x.editor = dir, "no_default", "vi"
|
28
|
-
write_config(x, ".blog")
|
29
|
+
new_dotfile(root: dir)
|
29
30
|
create_dir(dir)
|
30
31
|
Dir.chdir(dir) do
|
31
32
|
create_dir("views")
|
32
33
|
create_dir("assets")
|
33
34
|
create_dir("src")
|
34
|
-
|
35
|
-
File.write("VERSION", "#{RuneBlog::VERSION}\nBlog created: " + Time.now.to_s )
|
35
|
+
new_sequence
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
def initialize
|
40
|
-
# Crude - FIXME later -
|
39
|
+
def initialize # assumes existing blog
|
40
|
+
# Crude - FIXME later -
|
41
|
+
# What views are there? Deployment, etc.
|
41
42
|
self.class.blog = self # Weird. Like a singleton - dumbass circular dependency?
|
42
|
-
|
43
|
-
|
44
|
-
@
|
45
|
-
@
|
46
|
-
@view = str2view(view_name)
|
43
|
+
@root, @view_name, @editor =
|
44
|
+
read_config(DotFile, :root, :current_view, :editor)
|
45
|
+
@views = get_views
|
46
|
+
@view = str2view(@view_name)
|
47
47
|
@sequence = get_sequence
|
48
48
|
end
|
49
49
|
|
@@ -89,7 +89,7 @@ class RuneBlog
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def self.exist?
|
92
|
-
File.exist?(
|
92
|
+
File.exist?(DotFile)
|
93
93
|
end
|
94
94
|
|
95
95
|
def create_view(arg)
|
@@ -172,7 +172,7 @@ class RuneBlog
|
|
172
172
|
def change_view(view)
|
173
173
|
x = OpenStruct.new
|
174
174
|
x.root, x.current_view, x.editor = @root, view, @editor # dumb - FIXME later
|
175
|
-
write_config(x,
|
175
|
+
write_config(x, DotFile)
|
176
176
|
self.view = view # error checking?
|
177
177
|
end
|
178
178
|
|
@@ -295,39 +295,5 @@ class RuneBlog
|
|
295
295
|
|
296
296
|
private
|
297
297
|
|
298
|
-
def subdirs(dir)
|
299
|
-
raise Exception.new("hell") if dir == "/views/"
|
300
|
-
dirs = Dir.entries(dir) - %w[. ..]
|
301
|
-
dirs.reject! {|x| ! File.directory?("#@root/views/#{x}") }
|
302
|
-
dirs
|
303
|
-
rescue => err
|
304
|
-
p err
|
305
|
-
end
|
306
|
-
|
307
|
-
def find_src_slugs
|
308
|
-
files = Dir.entries("#@root/src/").grep /\d{4}.*.lt3$/
|
309
|
-
files.map! {|f| File.basename(f) }
|
310
|
-
files = files.sort.reverse
|
311
|
-
files
|
312
|
-
end
|
313
|
-
|
314
|
-
def create_dir(dir)
|
315
|
-
return if File.exist?(dir) && File.directory?(dir)
|
316
|
-
cmd = "mkdir -p #{dir} >/dev/null 2>&1"
|
317
|
-
result = system(cmd)
|
318
|
-
raise "Can't create #{dir}" unless result
|
319
|
-
end
|
320
|
-
|
321
|
-
def interpolate(str)
|
322
|
-
wrap = "<<-EOS\n#{str}\nEOS"
|
323
|
-
eval wrap
|
324
|
-
end
|
325
|
-
|
326
|
-
def error(err) # Hmm, this is duplicated
|
327
|
-
str = "\n Error: #{err}"
|
328
|
-
puts str
|
329
|
-
puts err.backtrace
|
330
|
-
end
|
331
|
-
|
332
298
|
end
|
333
299
|
|
data/lib/skeleton.rb
CHANGED
data/lib/version.rb
CHANGED
data/lib/view.rb
CHANGED