runeblog 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/blog +37 -27
- data/data/VERSION +1 -1
- data/lib/runeblog.rb +19 -5
- 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: b5610e389e42975588026a817dbdccc04b202d9e
|
4
|
+
data.tar.gz: 0f52e5f757a729bb01625ea05d88c23df5d7208c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d88699dbf12f1cc9d5efd0ef87b5866bb2f94ba27b35abc1b266403bc72d6cfffd5afee808dea7beb9d1bc19a27ff88138264b17bb81abc44586f85d62054b39
|
7
|
+
data.tar.gz: 4ddad379e9c9eff2c0071aa1d6b8b14cef453c1d6c713abd056ce0ac2b87344543c9b11bc0950e3c871acaf22c0e6424e8ad909a48bc39a538f4c6cde96f1477
|
data/bin/blog
CHANGED
@@ -7,48 +7,48 @@ require 'runeblog'
|
|
7
7
|
trap("INT") { }
|
8
8
|
|
9
9
|
def execute_command
|
10
|
-
case @
|
11
|
-
when
|
12
|
-
|
13
|
-
|
14
|
-
when "new post"; new_post # same as above
|
15
|
-
when "list posts", "lsp"; list_posts
|
16
|
-
when "new view"; new_view(@arg)
|
17
|
-
when "lsv", "list views"; list_views
|
18
|
-
when "change view"; change_view(@arg)
|
19
|
-
when "import post"; import(@arg)
|
20
|
-
when "relink"; relink
|
21
|
-
when "rebuild"; rebuild
|
22
|
-
when "version"; puts RuneBlog::VERSION
|
10
|
+
case @meth
|
11
|
+
when :help, :quit, :new_post, :list_views, :relink, :rebuild, :version,
|
12
|
+
:list_posts, :do_nothing
|
13
|
+
self.send(@meth)
|
23
14
|
else
|
24
|
-
|
15
|
+
self.send(@meth, @arg)
|
25
16
|
end
|
26
|
-
puts
|
17
|
+
puts unless @meth == :do_nothing
|
27
18
|
end
|
28
19
|
|
29
20
|
def check(boolean, msg)
|
30
|
-
|
21
|
+
save = @cmd
|
22
|
+
@cmd = nil
|
23
|
+
raise msg unless boolean
|
24
|
+
@cmd = save
|
31
25
|
end
|
32
26
|
|
33
27
|
def expected(nw = 1)
|
34
|
-
|
28
|
+
save = @cmd
|
29
|
+
@cmd = nil
|
30
|
+
raise "Unexpected '#{@words[nw]}'" unless @words.size == nw
|
31
|
+
@cmd = save
|
35
32
|
end
|
36
33
|
|
37
34
|
def need_arg(nw = 1)
|
38
|
-
|
39
|
-
|
35
|
+
save = @cmd
|
36
|
+
@cmd = nil
|
37
|
+
raise "Unexpected '#{@words[nw+1]}'" if @words[nw+1]
|
38
|
+
raise "Need an arg here" unless @words[nw]
|
39
|
+
@cmd = save
|
40
40
|
@words[nw]
|
41
41
|
end
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
# when "new view"; new_view(@arg)
|
46
|
-
# when "new post"; new_post # same as above
|
47
|
-
# when "change view"; change_view(@arg)
|
48
|
-
# when "import post"; import(@arg)
|
43
|
+
def do_nothing
|
44
|
+
end
|
49
45
|
|
50
46
|
def parse_cmd
|
51
47
|
@cmd = gets.chomp
|
48
|
+
if @cmd == ""
|
49
|
+
@meth = :do_nothing
|
50
|
+
return @cmd
|
51
|
+
end
|
52
52
|
@arg = ""
|
53
53
|
@words = @cmd.split
|
54
54
|
case @words.first
|
@@ -88,6 +88,7 @@ def parse_cmd
|
|
88
88
|
@meth = :list_posts
|
89
89
|
expected(2)
|
90
90
|
else
|
91
|
+
@cmd = nil
|
91
92
|
raise "Unknown #{@words[1]}"
|
92
93
|
end
|
93
94
|
when "new"
|
@@ -100,9 +101,11 @@ def parse_cmd
|
|
100
101
|
@meth = :new_post
|
101
102
|
expected(2)
|
102
103
|
else
|
104
|
+
@cmd = nil
|
103
105
|
raise "Unknown '#{@words[1]}'"
|
104
106
|
end
|
105
107
|
else
|
108
|
+
@cmd = nil
|
106
109
|
raise "Unknown '#{@words[0]}'"
|
107
110
|
end
|
108
111
|
@cmd
|
@@ -117,7 +120,9 @@ end
|
|
117
120
|
|
118
121
|
def help
|
119
122
|
puts <<-EOS
|
123
|
+
|
120
124
|
Commands:
|
125
|
+
|
121
126
|
h, help This message
|
122
127
|
q, quit Exit the program
|
123
128
|
|
@@ -132,7 +137,6 @@ def help
|
|
132
137
|
|
133
138
|
relink Regenerate index for all views
|
134
139
|
rebuild Regenerate all posts and relink
|
135
|
-
|
136
140
|
EOS
|
137
141
|
end
|
138
142
|
|
@@ -144,9 +148,15 @@ STDOUT.sync = true
|
|
144
148
|
|
145
149
|
if @cmd.nil? # REPL
|
146
150
|
read_config
|
151
|
+
puts
|
147
152
|
loop do
|
148
153
|
print red("blog> ")
|
149
|
-
|
154
|
+
begin
|
155
|
+
@cmd = parse_cmd
|
156
|
+
rescue => err
|
157
|
+
puts err
|
158
|
+
next
|
159
|
+
end
|
150
160
|
execute_command
|
151
161
|
end
|
152
162
|
else # one command
|
data/data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
RuneBlog v 0.0.
|
1
|
+
RuneBlog v 0.0.16 2017-05-05 00:00:00 UTC
|
data/lib/runeblog.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
class RuneBlog
|
3
|
-
VERSION = "0.0.
|
3
|
+
VERSION = "0.0.16"
|
4
4
|
|
5
5
|
Path = File.expand_path(File.join(File.dirname(__FILE__)))
|
6
6
|
DefaultData = Path + "/../data"
|
@@ -53,7 +53,7 @@ data
|
|
53
53
|
|
54
54
|
require 'rubygems'
|
55
55
|
require 'ostruct'
|
56
|
-
|
56
|
+
require 'livetext'
|
57
57
|
|
58
58
|
|
59
59
|
### ask
|
@@ -64,6 +64,19 @@ def ask(prompt, meth = :to_s)
|
|
64
64
|
STDIN.gets.chomp.send(meth)
|
65
65
|
end
|
66
66
|
|
67
|
+
### quit
|
68
|
+
|
69
|
+
def quit
|
70
|
+
puts
|
71
|
+
exit
|
72
|
+
end
|
73
|
+
|
74
|
+
### version
|
75
|
+
|
76
|
+
def version
|
77
|
+
puts "\n " + RuneBlog::VERSION
|
78
|
+
end
|
79
|
+
|
67
80
|
### new_blog!
|
68
81
|
|
69
82
|
def new_blog!
|
@@ -81,7 +94,7 @@ end
|
|
81
94
|
|
82
95
|
def next_sequence
|
83
96
|
@config.sequence += 1
|
84
|
-
File.open("#{@config.root}/
|
97
|
+
File.open("#{@config.root}/sequence", "w") {|f| f.puts @config.sequence }
|
85
98
|
@config.sequence
|
86
99
|
end
|
87
100
|
|
@@ -149,8 +162,9 @@ end
|
|
149
162
|
|
150
163
|
def process_post(file)
|
151
164
|
lt ||= Livetext.new
|
152
|
-
|
153
|
-
|
165
|
+
# puts " Processing: #{Dir.pwd}/#{file}"
|
166
|
+
path = @config.root + "/src/#{file}"
|
167
|
+
lt.process_file(path)
|
154
168
|
@meta = lt.main.instance_eval { @meta }
|
155
169
|
@meta.slug = file.sub(/.lt3$/, "")
|
156
170
|
@meta
|