sinatra-editable 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sinatra/editable.rb +7 -9
- metadata +2 -2
data/lib/sinatra/editable.rb
CHANGED
@@ -25,7 +25,7 @@ module Sinatra
|
|
25
25
|
app.set :editable_templater, :html
|
26
26
|
|
27
27
|
app.get "#{app.editable_route}/*" do
|
28
|
-
path = "#{settings.root}/#{settings.editable_dir}/#{params[:splat].
|
28
|
+
path = "#{settings.root}/#{settings.editable_dir}/#{params[:splat].shift}.#{settings.editable_templater}"
|
29
29
|
if File.exist?(path)
|
30
30
|
File.read(path)
|
31
31
|
else
|
@@ -45,14 +45,15 @@ module Sinatra
|
|
45
45
|
raise "Bad templater option"
|
46
46
|
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
splat = params[:splat].shift.split('/')
|
49
|
+
file_basename = splat.pop.gsub(/\/$/,'')
|
50
|
+
|
51
|
+
dir = "#{settings.root}/#{settings.editable_dir}/#{splat.join('/')}"
|
52
|
+
|
52
53
|
html_path = "#{dir}/#{file_basename}.html"
|
53
54
|
template_path = "#{dir}/#{file_basename}.#{settings.editable_templater}"
|
54
55
|
|
55
|
-
FileUtils.mkdir_p dir unless File.exist?(
|
56
|
+
FileUtils.mkdir_p dir unless File.exist?(dir)
|
56
57
|
|
57
58
|
if new_template
|
58
59
|
File.open(template_path,'w') do |f|
|
@@ -74,6 +75,3 @@ module Sinatra
|
|
74
75
|
|
75
76
|
register Editable
|
76
77
|
end
|
77
|
-
|
78
|
-
|
79
|
-
# create settings for route prefix, make helper to needed JS, which must be generated or with the proper route
|