Skip to content

Commit

Permalink
Update all gems
Browse files Browse the repository at this point in the history
  • Loading branch information
Clemens Kofler authored and Tyler Mauthe committed Dec 24, 2017
1 parent c4071ea commit 4e2b7f4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 28 deletions.
21 changes: 8 additions & 13 deletions lib/dashing/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def authenticated?(token)
set :views, File.join(settings.root, 'dashboards')
set :default_dashboard, nil
set :auth_token, nil
set :template_languages, %i[html erb]

if File.exists?(settings.history_file)
set :history, YAML.load_file(settings.history_file)
Expand Down Expand Up @@ -84,9 +85,9 @@ def authenticated?(token)

get '/:dashboard' do
protected!
tilt_html_engines.each do |suffix, _|
file = File.join(settings.views, "#{params[:dashboard]}.#{suffix}")
return render(suffix.to_sym, params[:dashboard].to_sym) if File.exist? file
settings.template_languages.each do |language|
file = File.join(settings.views, "#{params[:dashboard]}.#{language}")
return render(language, params[:dashboard].to_sym) if File.exist?(file)
end

halt 404
Expand Down Expand Up @@ -119,10 +120,11 @@ def authenticated?(token)

get '/views/:widget?.html' do
protected!
tilt_html_engines.each do |suffix, engines|
file = File.join(settings.root, "widgets", params[:widget], "#{params[:widget]}.#{suffix}")
return engines.first.new(file).render if File.exist? file
settings.template_languages.each do |language|
file = File.join(settings.root, "widgets", params[:widget], "#{params[:widget]}.#{language}")
return Tilt[language].new(file).render if File.exist?(file)
end

"Drats! Unable to find a widget file named: #{params[:widget]} to render."
end

Expand Down Expand Up @@ -162,13 +164,6 @@ def first_dashboard
files.sort.first
end

def tilt_html_engines
Tilt.mappings.select do |_, engines|
default_mime_type = engines.first.default_mime_type
default_mime_type.nil? || default_mime_type == 'text/html'
end
end

def require_glob(relative_glob)
Dir[File.join(settings.root, relative_glob)].each do |file|
require file
Expand Down
31 changes: 16 additions & 15 deletions smashing.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@ Gem::Specification.new do |s|

s.files = Dir['README.md', 'javascripts/**/*', 'templates/**/*','templates/**/.[a-z]*', 'lib/**/*']

s.add_dependency('sass', '~> 3.2.12')
s.add_dependency('coffee-script', '~> 2.2.0')
s.add_dependency('execjs', '~> 2.0.2')
s.add_dependency('sinatra', '~> 1.4.4')
s.add_dependency('sinatra-contrib', '~> 1.4.2')
s.add_dependency('thin', '~> 1.6.1')
s.add_dependency('rufus-scheduler', '~> 3.2.0')
s.add_dependency('thor', '~> 0.19')
s.add_dependency('sprockets', '~> 2.10.1')
s.add_dependency('rack', '~> 1.5.4')
s.add_dependency('sass', '~> 3.4.24')
s.add_dependency('coffee-script', '~> 2.4.1')
s.add_dependency('execjs', '~> 2.7.0')
s.add_dependency('sinatra', '~> 2.0.0')
s.add_dependency('sinatra-contrib', '~> 2.0.0')
s.add_dependency('thin', '~> 1.7.0')
s.add_dependency('rufus-scheduler', '~> 3.4.2')
s.add_dependency('thor', '~> 0.19.4')
s.add_dependency('sprockets', '~> 3.7.1')
s.add_dependency('rack', '~> 2.0.0')

s.add_development_dependency('rake', '~> 10.1.0')
s.add_development_dependency('haml', '~> 4.0.4')
s.add_development_dependency('minitest', '~> 5.2.0')
s.add_development_dependency('mocha', '~> 0.14.0')
s.add_development_dependency('rake', '~> 12.0.0')
s.add_development_dependency('haml', '~> 5.0.1')
s.add_development_dependency('rack-test', '~> 0.6.3')
s.add_development_dependency('minitest', '~> 5.10.2')
s.add_development_dependency('mocha', '~> 1.2.1')
s.add_development_dependency('fakeweb', '~> 1.3.0')
s.add_development_dependency('simplecov', '~> 0.8.2')
s.add_development_dependency('simplecov', '~> 0.14.1')
end
4 changes: 4 additions & 0 deletions templates/project/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ require 'dashing'
configure do
set :auth_token, 'YOUR_AUTH_TOKEN'

# See http://www.sinatrarb.com/intro.html > Available Template Languages on
# how to add additional template languages.
set :template_languages, %i[html erb]

helpers do
def protected!
# Put any authentication code you want in here.
Expand Down
4 changes: 4 additions & 0 deletions test/app_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ def test_page_title_set_correctly
end

def test_get_haml_dashboard
app.template_languages << :haml

with_generated_project do |dir|
File.write(File.join(dir, 'dashboards/hamltest.haml'), '.gridster')
get '/hamltest'
Expand All @@ -113,6 +115,8 @@ def test_get_haml_dashboard
end

def test_get_haml_widget
app.template_languages << :haml

with_generated_project do |dir|
File.write(File.join(dir, 'widgets/clock/clock.haml'), '%h1 haml')
File.unlink(File.join(dir, 'widgets/clock/clock.html'))
Expand Down

0 comments on commit 4e2b7f4

Please sign in to comment.