Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions config.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
helpers do
def js_as_plain(id)
f = open("docs/js/samples/" + id + ".js")
js = f.read
f.close
js
raise ArgumentError unless id =~ /\A[a-zA-Z0-9_-]+\z/

base = File.expand_path('docs/js/samples', __dir__)
path = File.expand_path("#{id}.js", base)
raise ArgumentError unless path.start_with?(base + File::SEPARATOR)

File.read(path)
end
def data_as_plain(name)
f = open("docs/data/" + name)
data = f.read
f.close
data
raise ArgumentError unless name =~ /\A[a-zA-Z0-9._-]+\z/

base = File.expand_path('docs/data', __dir__)
path = File.expand_path(name, base)
raise ArgumentError unless path.start_with?(base + File::SEPARATOR)

File.read(path)
end
def css_as_plain(name)
f = open("docs/css/samples/" + name)
css = f.read
f.close
css
raise ArgumentError unless name =~ /\A[a-zA-Z0-9._-]+\z/

base = File.expand_path('docs/css/samples', __dir__)
path = File.expand_path(name, base)
raise ArgumentError unless path.start_with?(base + File::SEPARATOR)

File.read(path)
end
def get_css_name(path)
path.gsub('.html', '')
Expand Down