solutus 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/solutus.rb +75 -9
- data/resources/editFile.html +1 -3
- data/resources/index.html +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 615a04274d007c7612352ad3ac5c941de06dea56621269225c1e0cb4f71ff07b
|
4
|
+
data.tar.gz: a35acf50ab7948dd020bb8530779fc2ec2f9ad544c6f27626ebb6008610947c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66220afe441695e91441e285cbe68b19655e831a96bb951ea2ba92fb558a2cc3ba40af44be913ceecc6283df1c6d37a6808089fc402252b43497345f246f109c
|
7
|
+
data.tar.gz: 619a7e1e9d7cc3e366d04feebc881204d5520133762ef6717cf3cc5cc0969a6e31afa97e5d5a35b7f8b03db4a624f3490404e107d6b2f5b62fe76910215a5b3b
|
data/lib/solutus.rb
CHANGED
@@ -30,7 +30,7 @@ class Solutus
|
|
30
30
|
PASSWORD_FILE = "password.txt"
|
31
31
|
DAY_ENDINGS = ["th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th", "th", "st"]
|
32
32
|
|
33
|
-
VERSION = '0.1.
|
33
|
+
VERSION = '0.1.8'
|
34
34
|
|
35
35
|
LOG_FILE = 'log'
|
36
36
|
|
@@ -57,6 +57,7 @@ class Solutus
|
|
57
57
|
|
58
58
|
class Solutus_Server < Sinatra::Base
|
59
59
|
CSS = File.read(File.join(File.dirname(File.expand_path(__FILE__)), '../resources', "style.css"))
|
60
|
+
FILE_EXCLUDES = ['password.txt', '.gitignore', 'nohup.out', 'log']
|
60
61
|
enable :sessions
|
61
62
|
|
62
63
|
set :public_folder, SITE_PATH
|
@@ -146,6 +147,30 @@ class Solutus
|
|
146
147
|
"saved page @ #{path}"
|
147
148
|
end
|
148
149
|
|
150
|
+
get "/newpage" do
|
151
|
+
dir = params['dir']
|
152
|
+
filename = params['filename']
|
153
|
+
dir = File.join(SITE_PAGES_PATH, dir)
|
154
|
+
path = File.join(dir, filename) + '.yml'
|
155
|
+
if !File.directory?(dir)
|
156
|
+
FileUtils.mkdir_p(dir)
|
157
|
+
end
|
158
|
+
f = File.new(path, 'w')
|
159
|
+
title = 'Page Title'
|
160
|
+
text = <<HERE
|
161
|
+
template: default
|
162
|
+
title: #{title}
|
163
|
+
content: |
|
164
|
+
<h1>#{title}</h1>
|
165
|
+
<p>
|
166
|
+
Some Content
|
167
|
+
</p>
|
168
|
+
HERE
|
169
|
+
f.write(text)
|
170
|
+
write_log("Created page #{path} from #{request.ip}")
|
171
|
+
redirect "/edit"
|
172
|
+
end
|
173
|
+
|
149
174
|
post "/newpost" do
|
150
175
|
if !session[:verified]
|
151
176
|
return render_login("You were logged out.")
|
@@ -195,7 +220,11 @@ class Solutus
|
|
195
220
|
return render_login("You were logged out.")
|
196
221
|
end
|
197
222
|
path = params['path']
|
198
|
-
|
223
|
+
if File.file?(path)
|
224
|
+
render_edit_file(path)
|
225
|
+
else
|
226
|
+
'error, not a file'
|
227
|
+
end
|
199
228
|
end
|
200
229
|
|
201
230
|
post "/savefile" do
|
@@ -203,6 +232,10 @@ class Solutus
|
|
203
232
|
return 'error'
|
204
233
|
end
|
205
234
|
path = params['path']
|
235
|
+
if FILE_EXCLUDES.include?(path.split("/"[-1]))
|
236
|
+
write_log("security breach attempt @ #{path} from #{request.ip}")
|
237
|
+
return 'security error'
|
238
|
+
end
|
206
239
|
content = params['content']
|
207
240
|
f = File.open(path, 'w')
|
208
241
|
f.write(content)
|
@@ -216,8 +249,8 @@ class Solutus
|
|
216
249
|
if !session[:verified]
|
217
250
|
return "error"
|
218
251
|
end
|
219
|
-
Solutus.command("
|
220
|
-
"
|
252
|
+
Solutus.command("build")
|
253
|
+
"built"
|
221
254
|
end
|
222
255
|
|
223
256
|
get "/:page" do
|
@@ -351,6 +384,19 @@ class Solutus
|
|
351
384
|
settings.global_settings.each do |key, val|
|
352
385
|
result[key.to_sym] = val
|
353
386
|
end
|
387
|
+
dirs = Dir.entries(SITE_PAGES_PATH)
|
388
|
+
puts dirs
|
389
|
+
dir_res = ''
|
390
|
+
dirs.each do |d|
|
391
|
+
if File.directory?(File.join(SITE_PAGES_PATH, d)) && d != ".."
|
392
|
+
val = d + "/"
|
393
|
+
if val == '.'
|
394
|
+
val = "/"
|
395
|
+
end
|
396
|
+
dir_res += "<option value='#{d}'>#{val}</option>"
|
397
|
+
end
|
398
|
+
end
|
399
|
+
result[:page_paths] = dir_res
|
354
400
|
result[:blogs] = blog_select
|
355
401
|
result[:pages] = page_select
|
356
402
|
result[:css] = CSS
|
@@ -375,11 +421,17 @@ class Solutus
|
|
375
421
|
dirs = [".", "static/css", "templates", "pages/site-pages"]
|
376
422
|
dirs.each do |dir|
|
377
423
|
result += "<optgroup label='#{dir}'>"
|
378
|
-
|
424
|
+
if dir == "."
|
425
|
+
files = Dir.entries(dir).select {|f| !File.directory? f}
|
426
|
+
else
|
427
|
+
files = Solutus.relative_path_to_all_files_in_dir(dir)
|
428
|
+
end
|
379
429
|
files.each do |filename|
|
380
|
-
if !
|
430
|
+
if !FILE_EXCLUDES.include?(filename)
|
381
431
|
path = File.join(dir, filename)
|
382
|
-
|
432
|
+
if File.file?(path)
|
433
|
+
result += "<option value=\"#{path}\">#{filename}</option>\n"
|
434
|
+
end
|
383
435
|
end
|
384
436
|
end
|
385
437
|
result += "</optgroup>"
|
@@ -418,7 +470,6 @@ class Solutus
|
|
418
470
|
|
419
471
|
def self.command(*args)
|
420
472
|
start_time = Time.now
|
421
|
-
|
422
473
|
if args.length >= 1
|
423
474
|
if ["-v", "--version"].include?(args[0])
|
424
475
|
puts VERSION
|
@@ -588,7 +639,7 @@ HERE
|
|
588
639
|
end
|
589
640
|
|
590
641
|
@@page_urls = Array.new
|
591
|
-
|
642
|
+
relative_path_to_all_files_in_dir(SITE_PAGES_PATH).each do |entry|
|
592
643
|
next if entry == "." || entry == ".."
|
593
644
|
puts "Rendering page #{entry}"
|
594
645
|
path = File.join(SITE_PAGES_PATH, entry)
|
@@ -790,6 +841,21 @@ HERE
|
|
790
841
|
result
|
791
842
|
end
|
792
843
|
|
844
|
+
def self.relative_path_to_all_files_in_dir(dir)
|
845
|
+
result = Array.new
|
846
|
+
Dir.entries(dir).each do |entry|
|
847
|
+
next if entry == "." || entry == ".."
|
848
|
+
path = File.join(dir, entry)
|
849
|
+
if File.file?(path)
|
850
|
+
result.push(entry)
|
851
|
+
elsif File.directory?(path)
|
852
|
+
result = result + relative_path_to_all_files_in_dir(path).collect {|x| File.join(entry, x)}
|
853
|
+
end
|
854
|
+
end
|
855
|
+
result
|
856
|
+
end
|
857
|
+
|
858
|
+
|
793
859
|
def self.create_password(password)
|
794
860
|
content = Digest::MD5.hexdigest password
|
795
861
|
if File.file?(PASSWORD_FILE)
|
data/resources/editFile.html
CHANGED
@@ -6,9 +6,8 @@
|
|
6
6
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.38.0/mode/htmlmixed/htmlmixed.js"></script>
|
7
7
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.38.0/theme/lesser-dark.css">
|
8
8
|
<style type="text/css">
|
9
|
-
|
9
|
+
{{css}}
|
10
10
|
</style>
|
11
|
-
{{{stylesheets}}}
|
12
11
|
</head>
|
13
12
|
|
14
13
|
<body>
|
@@ -20,7 +19,6 @@
|
|
20
19
|
<script>
|
21
20
|
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById('editor'), {
|
22
21
|
lineNumbers: true,
|
23
|
-
styleActiveLine: true,
|
24
22
|
matchBrackets: true,
|
25
23
|
theme: 'lesser-dark'
|
26
24
|
});
|
data/resources/index.html
CHANGED
@@ -24,6 +24,18 @@
|
|
24
24
|
</fieldset>
|
25
25
|
</form>
|
26
26
|
</p>
|
27
|
+
|
28
|
+
<p>
|
29
|
+
<form method="get" action="/newpage">
|
30
|
+
<fieldset>
|
31
|
+
<legend>New Page</legend>
|
32
|
+
Page subdirectory:
|
33
|
+
<select name='dir'>{{{page_paths}}}</select>
|
34
|
+
<p>Page name: <input type='text' name='filename'></p>
|
35
|
+
<p><button type="submit">Create page</button></fieldset></p>
|
36
|
+
</fieldset>
|
37
|
+
</form>
|
38
|
+
</p>
|
27
39
|
{{/advanced}}
|
28
40
|
{{^advanced}}
|
29
41
|
<p>
|