Module: Fredit
Defined Under Namespace
Classes: Engine
Constant Summary collapse
- LINK_CSS =
"margin:0;margin-top:-1em;padding:1px;font-size:10px;background-color:#a3f66c;border:1px solid #666;"
Instance Method Summary collapse
- #editables ⇒ Object
- #entries(glob) ⇒ Object
-
#link(x) ⇒ Object
TODO change this to be compatible with HAML.
- #rel_path(path) ⇒ Object
- #rel_paths(paths) ⇒ Object
- #template_editable?(template) ⇒ Boolean
Instance Method Details
#editables ⇒ Object
27 28 29 30 31 32 |
# File 'lib/fredit.rb', line 27 def editables css = entries('public/stylesheets/**/*.css') js = entries('public/javascripts/**/*.js') views = entries('app/views/**/*.html.{erb,haml}') {:css => css, :views => views, :javascript => js} end |
#entries(glob) ⇒ Object
23 24 25 |
# File 'lib/fredit.rb', line 23 def entries(glob) Dir[Rails.root + glob].entries.map {|e| rel_path(e)} end |
#link(x) ⇒ Object
TODO change this to be compatible with HAML
18 19 20 21 |
# File 'lib/fredit.rb', line 18 def link(x) s = %Q| <a style="#{LINK_CSS}" href="/fredit?file=#{URI.escape(x)}" target="_blank">#{x}</a> | s.strip.html_safe end |
#rel_path(path) ⇒ Object
9 10 11 |
# File 'lib/fredit.rb', line 9 def rel_path(path) path.sub(Rails.root.to_s + '/', '') end |
#rel_paths(paths) ⇒ Object
13 14 15 |
# File 'lib/fredit.rb', line 13 def rel_paths(paths) paths.map {|x| rel_path(x)} end |
#template_editable?(template) ⇒ Boolean
34 35 36 37 38 |
# File 'lib/fredit.rb', line 34 def template_editable?(template) template.identifier.index(Rails.root.to_s) == 0 && template.formats && template.formats.include?(:html) end |