sinatra-editable 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/sinatra/editable.rb +8 -8
  2. metadata +2 -2
@@ -5,14 +5,14 @@ module Sinatra
5
5
 
6
6
  module Helpers
7
7
  def editable(item)
8
- path = "#{options.root}/#{options.editable_dir}/#{item.to_s}.html"
8
+ path = "#{settings.root}/#{settings.editable_dir}/#{item.to_s}.html"
9
9
  if editable_exist?(item)
10
10
  File.read(path)
11
11
  end
12
12
  end
13
13
 
14
14
  def editable_exist?(item)
15
- path = "#{options.root}/#{options.editable_dir}/#{item.to_s}.html"
15
+ path = "#{settings.root}/#{settings.editable_dir}/#{item.to_s}.html"
16
16
  File.exist?(path)
17
17
  end
18
18
  end
@@ -24,8 +24,8 @@ module Sinatra
24
24
  app.set :editable_dir, 'editable'
25
25
  app.set :editable_templater, :html
26
26
 
27
- app.get "/editable/*" do
28
- path = "#{options.root}/#{options.editable_dir}/#{params[:splat].join('/')}.#{options.editable_templater}"
27
+ app.get "#{app.editable_route}/*" do
28
+ path = "#{settings.root}/#{settings.editable_dir}/#{params[:splat].join('/')}.#{settings.editable_templater}"
29
29
  if File.exist?(path)
30
30
  File.read(path)
31
31
  else
@@ -33,8 +33,8 @@ module Sinatra
33
33
  end
34
34
  end
35
35
 
36
- app.put "/editable/*" do
37
- case options.editable_templater
36
+ app.put "#{app.editable_route}/*" do
37
+ case settings.editable_templater
38
38
  when :textile
39
39
  new_template = params[:content]
40
40
  new_html = RedCloth.new(new_template).to_html
@@ -47,10 +47,10 @@ module Sinatra
47
47
 
48
48
  file_basename = params[:splat].pop.gsub(/\/$/,'')
49
49
 
50
- dir = "#{options.root}/#{options.editable_dir}/#{params[:splat].join('/')}"
50
+ dir = "#{settings.root}/#{settings.editable_dir}/#{params[:splat].join('/')}"
51
51
 
52
52
  html_path = "#{dir}/#{file_basename}.html"
53
- template_path = "#{dir}/#{file_basename}.#{options.editable_templater}"
53
+ template_path = "#{dir}/#{file_basename}.#{settings.editable_templater}"
54
54
 
55
55
  FileUtils.mkdir_p dir unless File.exist?(File.dirname(dir))
56
56
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Robert Crim