-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.rb
More file actions
85 lines (67 loc) · 2.1 KB
/
config.rb
File metadata and controls
85 lines (67 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# CodeRay syntax highlighting in Haml
# activate :code_ray
# Helpers
helpers do
def text_field(name, options = {})
label_tag(name, :caption => options.delete(:caption)) <<
text_field_tag(name, options.merge(:class => name))
end
def textarea(name)
File.read("source/textareas/"+ name)
end
end
set :css_dir, 'css'
set :js_dir, 'js'
set :images_dir, 'img'
# set :views, File.dirname(__FILE__)
# Build-specific configuration
configure :build do
filename = 'source/js/markup-editor.js'
VERSION = File.read("VERSION").strip
updated_file = File.read(filename).gsub(/(^\s\*.*v)[\d\.]+$/, '\1' + VERSION)
File.open(filename, "w") do |file|
file.puts updated_file
end
require 'closure-compiler'
File.open('source/js/markup-editor-min.js','w') do |file|
# closure = Closure::Compiler.new(:compilation_level => 'ADVANCED_OPTIMIZATIONS')
closure = Closure::Compiler.new
file.puts closure.compile(updated_file)
end
# For example, change the Compass output style for deployment
# activate :minify_css
# Minify Javascript on build
# activate :minify_javascript
# Enable cache buster
# activate :cache_buster
# Use relative URLs
# activate :relative_assets
# Compress PNGs after build (gem install middleman-smusher)
# require "middleman-smusher"
# activate :smusher
# Generate ugly/obfuscated HTML from Haml
# activate :ugly_haml
# set :http_prefix, "file:///home/jonas/projects/markup_editor/build/"
set :http_prefix, "/markup-editor"
end
if development?
require 'rack-livereload'
use Rack::LiveReload,
:source => :vendored,
:ignore => [ %r{/doc} ]
end
map "/doc" do
run Rack::Directory.new(Dir.pwd + "/source/doc")
end
require 'rack/coderay'
use Rack::Coderay, "//pre[@lang]", :ignore => [ %r{/doc} ]
# Hack to fix haml output
class Rack::Coderay::Parser
private
def coderay_render(text, language) #:nodoc:
text = text.to_s.gsub(/
/i, "\n").gsub("<", '<').gsub(">", '>').gsub("&", '&').gsub(""", '"')
::CodeRay.scan(text, language.to_sym).div(self.coderay_options)
end
end
require 'lib/markup'
use Rack::Markup