Skip to content

Commit

Permalink
Merge branch 'rails-4'
Browse files Browse the repository at this point in the history
Conflicts:
	.travis.yml
	plugins/040-apps/app/views/apps/_is_installed.html.slim
cpg committed Jun 26, 2014
2 parents 59db304 + d814a2e commit 2a0fe0c
Showing 103 changed files with 608 additions and 880 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0-p195
ruby-2.0.0-p353
2 changes: 0 additions & 2 deletions .rvmrc

This file was deleted.

21 changes: 12 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
source 'https://rubygems.org'

gem 'rails', '3.2.17'
gem "rails", '~>4.1.1'

gem 'mysql2'
gem "yettings"

group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'sass-rails' , '~>4.0.3'
gem 'coffee-rails'

gem 'therubyracer'
gem 'therubyracer'

gem 'uglifier'
end
gem 'uglifier'

gem "activeresource", require: "active_resource"
gem 'protected_attributes'
gem 'actionpack-action_caching'
gem 'rails-observers'

gem 'jbuilder'
gem 'ya2yaml'

gem 'themes_for_rails'
gem 'themes_for_rails', :git => "https://github.com/amahi/themes_for_rails.git"

gem 'jquery-rails'
gem 'jquery-ui-rails'
@@ -43,7 +46,7 @@ group :development do

# FIXME: for Fedora only
if ((open('/etc/issue').grep(/fedora/i).length > 0) rescue false)
gem 'minitest'
gem "minitest"
end
end

206 changes: 114 additions & 92 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,42 +1,54 @@
GIT
remote: https://github.com/amahi/themes_for_rails.git
revision: e0f2e834ce27f19b287e964f18f027a9b4f172bb
specs:
themes_for_rails (0.5.1)
rails (>= 3.0.0)

GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.17)
actionpack (= 3.2.17)
actionmailer (4.1.1)
actionpack (= 4.1.1)
actionview (= 4.1.1)
mail (~> 2.5.4)
actionpack (3.2.17)
activemodel (= 3.2.17)
activesupport (= 3.2.17)
builder (~> 3.0.0)
actionpack (4.1.1)
actionview (= 4.1.1)
activesupport (= 4.1.1)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
actionpack-action_caching (1.1.1)
actionpack (>= 4.0.0, < 5.0)
actionview (4.1.1)
activesupport (= 4.1.1)
builder (~> 3.1)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.5)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
activemodel (3.2.17)
activesupport (= 3.2.17)
builder (~> 3.0.0)
activerecord (3.2.17)
activemodel (= 3.2.17)
activesupport (= 3.2.17)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.17)
activemodel (= 3.2.17)
activesupport (= 3.2.17)
activesupport (3.2.17)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
activemodel (4.1.1)
activesupport (= 4.1.1)
builder (~> 3.1)
activerecord (4.1.1)
activemodel (= 4.1.1)
activesupport (= 4.1.1)
arel (~> 5.0.0)
activeresource (4.0.0)
activemodel (~> 4.0)
activesupport (~> 4.0)
rails-observers (~> 0.1.1)
activesupport (4.1.1)
i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
addressable (2.3.6)
arel (3.0.3)
authlogic (3.4.1)
arel (5.0.1.20140414130214)
authlogic (3.4.2)
activerecord (>= 3.2)
activesupport (>= 3.2)
request_store (~> 1.0.5)
request_store (~> 1.0)
bcrypt (3.1.7)
builder (3.0.4)
capybara (2.2.1)
builder (3.2.2)
capybara (2.3.0)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
@@ -46,19 +58,19 @@ GEM
capybara (>= 1.0, < 3)
launchy
cliver (0.3.2)
coffee-rails (3.2.2)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.7.0)
daemons (1.1.9)
diff-lcs (1.2.5)
docile (1.1.3)
docile (1.1.5)
erubis (2.7.0)
eventmachine (1.0.3)
execjs (2.0.2)
execjs (2.2.0)
factory_girl (4.4.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.4.1)
@@ -70,11 +82,10 @@ GEM
rake
hike (1.2.3)
i18n (0.6.9)
jbuilder (2.0.6)
jbuilder (2.1.1)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
journey (1.0.4)
jquery-rails (3.1.0)
jquery-rails (3.1.1)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (4.2.1)
@@ -88,67 +99,70 @@ GEM
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.25.1)
mini_portile (0.5.3)
minitest (5.3.3)
multi_json (1.9.2)
mysql2 (0.3.15)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
poltergeist (1.5.0)
mini_portile (0.6.0)
minitest (5.3.5)
multi_json (1.10.1)
mysql2 (0.3.16)
nokogiri (1.6.2.1)
mini_portile (= 0.6.0)
poltergeist (1.5.1)
capybara (~> 2.1)
cliver (~> 0.3.1)
multi_json (~> 1.0)
websocket-driver (>= 0.2.0)
polyglot (0.3.4)
polyglot (0.3.5)
protected_attributes (1.0.8)
activemodel (>= 4.0.1, < 5.0)
psych (2.0.5)
quiet_assets (1.0.2)
quiet_assets (1.0.3)
railties (>= 3.1, < 5.0)
rack (1.4.5)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.4)
rack
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.17)
actionmailer (= 3.2.17)
actionpack (= 3.2.17)
activerecord (= 3.2.17)
activeresource (= 3.2.17)
activesupport (= 3.2.17)
bundler (~> 1.0)
railties (= 3.2.17)
railties (3.2.17)
actionpack (= 3.2.17)
activesupport (= 3.2.17)
rack-ssl (~> 1.3.2)
rails (4.1.1)
actionmailer (= 4.1.1)
actionpack (= 4.1.1)
actionview (= 4.1.1)
activemodel (= 4.1.1)
activerecord (= 4.1.1)
activesupport (= 4.1.1)
bundler (>= 1.3.0, < 2.0)
railties (= 4.1.1)
sprockets-rails (~> 2.0)
rails-observers (0.1.2)
activemodel (~> 4.0)
railties (4.1.1)
actionpack (= 4.1.1)
activesupport (= 4.1.1)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
thor (>= 0.18.1, < 2.0)
raindrops (0.13.0)
rake (10.3.1)
rake (10.3.2)
rb-readline (0.5.1)
rdoc (3.12.2)
json (~> 1.4)
ref (1.0.5)
request_store (1.0.5)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
rspec-rails (2.14.2)
request_store (1.0.6)
rspec-core (3.0.2)
rspec-support (~> 3.0.0)
rspec-expectations (3.0.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.0.0)
rspec-mocks (3.0.2)
rspec-support (~> 3.0.0)
rspec-rails (3.0.1)
actionpack (>= 3.0)
activemodel (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
sass (3.3.6)
sass-rails (3.2.6)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0)
rspec-mocks (~> 3.0.0)
rspec-support (~> 3.0.0)
rspec-support (3.0.2)
sass (3.2.19)
sass-rails (4.0.3)
railties (>= 4.0.0, < 5.0)
sass (~> 3.2.0)
sprockets (~> 2.8, <= 2.11.0)
sprockets-rails (~> 2.0)
scrypt (1.2.1)
ffi-compiler (>= 0.0.2)
rake
@@ -160,15 +174,17 @@ GEM
slim (2.0.2)
temple (~> 0.6.6)
tilt (>= 1.3.3, < 2.1)
sprockets (2.2.2)
sprockets (2.11.0)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.1.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
sqlite3 (1.3.9)
temple (0.6.7)
themes_for_rails (0.5.1)
rails (>= 3.0.0)
therubyracer (0.12.1)
libv8 (~> 3.16.14.0)
ref
@@ -177,15 +193,17 @@ GEM
eventmachine (>= 1.0.0)
rack (>= 1.0.0)
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.39)
uglifier (2.5.0)
tzinfo (1.2.1)
thread_safe (~> 0.1)
uglifier (2.5.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
unicorn (4.8.2)
unicorn (4.8.3)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
@@ -199,6 +217,8 @@ PLATFORMS
ruby

DEPENDENCIES
actionpack-action_caching
activeresource
authlogic
bcrypt
capybara
@@ -211,17 +231,19 @@ DEPENDENCIES
minitest
mysql2
poltergeist
protected_attributes
psych
quiet_assets
rails (= 3.2.17)
rails (~> 4.1.1)
rails-observers
rb-readline
rspec-rails
sass-rails
sass-rails (~> 4.0.3)
scrypt
simplecov
slim
sqlite3
themes_for_rails
themes_for_rails!
therubyracer
thin
thor
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@

bundle:
bundle install --without test --path vendor/bundle --binstubs bin/ --deployment
(cd vendor/bundle/ruby/gems/; find . -type f -exec grep -l '/this/will/be/overwritten/or/wrapped/anyways/do/not/worry/ruby' {} \; | xargs sed -i -e 's|/this/will/be/overwritten/or/wrapped/anyways/do/not/worry/ruby|/usr/bin/ruby|') || true
/usr/bin/bundle install --without test --path vendor/bundle --binstubs bin/ --deployment
(cd vendor/bundle/ruby/ && find . -type f -exec grep -l '/usr/bin/ruby' {} \; | xargs sed -i -e 's|/usr/bin/ruby|/usr/bin/ruby|') || true
# clean up things that are not needed at run time
(cd vendor/bundle/ruby/ && rm -rf cache) || true
(cd vendor/bundle/ruby/gems && rm -rf rails-*/guides */spec */doc */doc-api) || true
(cd vendor/bundle/ruby/gems && rm -rf */test */tests) || true
(cd vendor/bundle/ruby/ && find . \( -name '*.[coa]' -or -name '*.cc' -or -name '*.md' -or -name '.git' \) -exec rm -rf {} \;) || true

distclean: clean
rm -rf vendor/bundle
Binary file modified app/assets/images/logo16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/assets/images/rails.png
Binary file not shown.
2 changes: 1 addition & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -13,5 +13,5 @@
//= require lib/application
//= require lib/templates
//= require lib/smart-links

//= require lib/debug
//= require spinner
24 changes: 24 additions & 0 deletions app/assets/javascripts/lib/debug.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Amahi Home Server
# Copyright (C) 2007-2013 Amahi
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License v3
# (29 June 2007), as published in the COPYING file.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# file COPYING for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Amahi
# team at http://www.amahi.org/ under "Contact Us."

# Debug JS functionality


$(document).on "ajax:success", ".debug-form", (event, results) ->
if results.status is "ok"
$('#debug-submit-form').html("<p class='alert alert-info'> Error Log Succesfully Submitted</p>")
else
$('#debug-submit-form').html("<p class='alert alert-danger'>Debug report failed. Please do try again later.</p>")
4 changes: 2 additions & 2 deletions app/assets/stylesheets/login.css.scss
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ a {text-decoration: none;}
margin: 20px auto 7em auto;
}

.message-error {
.alert-danger{
margin: 0 0 16px 8px;
padding: 12px;
border: 1px solid #C00000;
@@ -71,7 +71,7 @@ a {text-decoration: none;}
background-color: #e0ffda;
}

.message-notice {
.alert-info {
margin: 0 0 16px 8px;
padding: 12px;
border: 1px solid #FAB762;
28 changes: 28 additions & 0 deletions app/assets/themes/default/stylesheets/style.css.scss
Original file line number Diff line number Diff line change
@@ -1558,3 +1558,31 @@ textarea {border: 1px solid #ccc;}
.hide {
display: none;
}

//Markup for alert boxes
.alert {
padding: 15px;
margin-bottom: 20px;
border: 1px solid transparent;
border-radius: 4px;
}
.alert-success {
color: #3c763d;
background-color: #dff0d8;
border-color: #d6e9c6;
}
.alert-info {
color: #31708f;
background-color: #d9edf7;
border-color: #bce8f1;
}
.alert-danger {
color: #a94442;
background-color: #f2dede;
border-color: #ebccd1;
}
//Debug Tab Design
.debug-form{
margin-top:10px !important;
margin-left: 20px !important;
}
12 changes: 6 additions & 6 deletions app/controllers/aliases_controller.rb
Original file line number Diff line number Diff line change
@@ -18,8 +18,8 @@ class AliasesController < ApplicationController

before_filter :admin_required

VALID_NAME = Regexp.new "^[A-Za-z0-9\-]+$"
VALID_ADDRESS = Regexp.new '^(|\d(\d?\d?)|\d(\d?\d?)\.\d(\d?\d?)\.\d(\d?\d?)\.\d(\d?\d?))$'
VALID_NAME = Regexp.new "\A[A-Za-z0-9\-]+\z"
VALID_ADDRESS = Regexp.new '\A(|\d(\d?\d?)|\d(\d?\d?)\.\d(\d?\d?)\.\d(\d?\d?)\.\d(\d?\d?))\z'

def initialize
@page_title = 'DNS Aliases'
@@ -160,7 +160,7 @@ def new_alias_check
render :partial => 'aliases/name_bad'
return
end
a = DnsAlias.find_by_alias(n)
a = DnsAlias.where(:alias=>n).first
if a.nil?
# no such alias, ok to create it
@name = n
@@ -195,19 +195,19 @@ def valid_address?(addr)
# NOTE: do not allow aliases to the hda as a blank address
return false if addr.blank?
return false unless (addr =~ VALID_ADDRESS)
if addr =~ Regexp.new('^(\d+)\.(\d+)\.(\d+)\.(\d+)$')
if addr =~ Regexp.new('\A(\d+)\.(\d+)\.(\d+)\.(\d+)\z')
[$1, $2, $3, $4].each { |ip| return false if ip.to_i > 254 }
return true
end
valid_short_address?(addr)
end

def is_address_full?(addr)
(addr =~ Regexp.new('^(\d+)\.(\d+)\.(\d+)\.(\d+)$')) ? true : false
(addr =~ Regexp.new('\A(\d+)\.(\d+)\.(\d+)\.(\d+)\z')) ? true : false
end

def valid_short_address?(addr)
if addr =~ Regexp.new('^(\d+)$')
if addr =~ Regexp.new('\A(\d+)\z')
v = addr.to_i
return true unless v < 0 or v > 254
end
14 changes: 7 additions & 7 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -37,17 +37,17 @@ def before_filter_hook
set_direction
check_for_amahi_app
prepare_theme
adv = Setting.find_by_name('advanced')
adv = Setting.where(:name=>'advanced').first
@advanced = adv && adv.value == '1'
end

def check_for_amahi_app
server = request.env['SERVER_NAME']
dom = Setting.get_by_name('domain')
if server && server != 'hda' && server =~ /^(.*)\.#{dom}$/
if server && server != 'hda' && server =~ /\A(.*)\.#{dom}\z/
server = $1
end
if server && server != 'hda' && DnsAlias.find_by_name(server)
if server && server != 'hda' && DnsAlias.where(:name=>server).first
redirect_to "http://hda/hda_app_#{server}"
end
end
@@ -75,8 +75,8 @@ def setup_router
rd = RouterDriver.current_router = (r ? r.value : "")
# return the class proper if valid
@router = Kernel.const_get(rd) unless rd.blank?
u = Setting.network.find_by_name('router_username')
p = Setting.network.find_by_name('router_password')
u = Setting.network.where(:name=>'router_username').first
p = Setting.network.where(:name=>'router_password').first
RouterDriver.set_auth(unobfuscate(u.value), unobfuscate(p.value)) if p and u and p.value and u.value
rescue
# shhh. comment out the rescue for debugging
@@ -165,7 +165,7 @@ def current_user
def login_required
unless current_user
store_location
flash[:notice] = I18n.t('must_be_logged_in')
flash[:info] = I18n.t('must_be_logged_in')
redirect_to new_user_session_path
return false
end
@@ -181,7 +181,7 @@ def admin_required
return false if login_required == false
unless current_user.admin?
store_location
flash[:notice] = t('must_be_admin')
flash[:info] = t('must_be_admin')
redirect_to new_user_session_url
return false
end
4 changes: 2 additions & 2 deletions app/controllers/calendar_controller.rb
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ def remove
FileUtils.rm_rf(".DAV/" + calname + ".dir")
@calendars = Dir["*.ics"]
end
@has_ical = App.find_by_name 'iCalendar' != nil
@has_ical = App.where(:name => 'iCalendar').first != nil
render :partial => 'calendar/calendar', :collection => @calendars, :locals => { :has_ical => @has_ical }
end

@@ -52,7 +52,7 @@ def new
end
@calendars = Dir["*.ics"]
end
@has_ical = App.find_by_name 'iCalendar' != nil
@has_ical = App.where(:name=>'iCalendar').first != nil
render :partial => 'calendar/calendar', :collection => @calendars, :locals => { :has_ical => @has_ical }
end

51 changes: 51 additions & 0 deletions app/controllers/debug_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Amahi Home Server
# Copyright (C) 2007-2013 Amahi
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License v3
# (29 June 2007), as published in the COPYING file.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# file COPYING for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Amahi
# team at http://www.amahi.org/ under "Contact Us."

class DebugController < ApplicationController

before_filter :admin_required
layout 'debug'

def index
@page_title = t('debug')
end

def logs
@page_title = t('debug')
end

def system
@page_title = t('debug')
end


def submit
AmahiApi.api_key = Setting.get "api-key"
report = SystemUtils.run 'tail -200 /var/hda/platform/html/log/production.log'
er = AmahiApi::ErrorReport.new(:report => report, :comments => params[:comments], :subject => params[:subject])
begin
if er.save
render :json =>{:status=>'ok'}
else
render :json =>{:status=>'failed',:errors=> er.errors}
end
rescue
render :json =>{:status=>'failed',:errors=> er.errors}
end
end


end
5 changes: 2 additions & 3 deletions app/controllers/front_controller.rb
Original file line number Diff line number Diff line change
@@ -4,12 +4,12 @@
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License v3
# (29 June 2007), as published in the COPYING file.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# file COPYING for more details.
#
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Amahi
# team at http://www.amahi.org/ under "Contact Us."
@@ -24,5 +24,4 @@ def index
@apps = App.in_dashboard
@news = AmahiNews.top()
end

end
16 changes: 8 additions & 8 deletions app/controllers/hosts_controller.rb
Original file line number Diff line number Diff line change
@@ -17,8 +17,8 @@
class HostsController < ApplicationController
before_filter :admin_required

VALID_NAME = Regexp.new "^[A-Za-z][A-Za-z0-9\-]+$"
VALID_ADDRESS = Regexp.new '^(|\d(\d?\d?)|\d(\d?\d?)\.\d(\d?\d?)\.\d(\d?\d?)\.\d(\d?\d?))$'
VALID_NAME = Regexp.new "\A[A-Za-z][A-Za-z0-9\-]+\z"
VALID_ADDRESS = Regexp.new '\A(|\d(\d?\d?)|\d(\d?\d?)\.\d(\d?\d?)\.\d(\d?\d?)\.\d(\d?\d?))\z'
MAC_P = '(\d|[A-Fa-f])(\d|[A-Fa-f])'
# This is the range at which DHCP starts. Strictly below is valid

@@ -122,7 +122,7 @@ def update_address
render :text => a.address
return
end
h = Host.find_by_address addr
h = Host.where(:address=>addr).first
if h.nil?
# no such address, ok to use it
a.address = addr
@@ -140,7 +140,7 @@ def update_mac
render :text => a.mac
return
end
h = Host.find_by_mac mac
h = Host.where(:mac=>mac).first
if h.nil?
# no such address, ok to use it
a.mac = mac
@@ -172,7 +172,7 @@ def new_host_check
render :partial => 'hosts/name_bad'
return
end
a = Host.find_by_host(n)
a = Host.where(:host=>n).first
if a.nil?
# no such alias, ok to create it
@name = n
@@ -190,7 +190,7 @@ def new_address_check
render :partial => 'hosts/address_bad'
return
end
a = Host.find_by_address(n)
a = Host.where(:address=>n).first
if a.nil?
# no such address, ok to create it
@name = n
@@ -208,7 +208,7 @@ def new_mac_check
render :partial => 'hosts/mac_bad'
return
end
a = Host.find_by_mac(n)
a = Host.where(:mac=>n).first
if a.nil?
# no such mac, ok to create it
@name = n
@@ -242,7 +242,7 @@ def valid_name?(nm)
end

def valid_short_address?(addr)
if addr =~ Regexp.new('^(\d+)$')
if addr =~ Regexp.new('\A(\d+)\z')
v = addr.to_i
return true if v > 0 and v < VALID_DHCP_ADDRESS_RANGE
end
10 changes: 5 additions & 5 deletions app/controllers/share_controller.rb
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
class ShareController < ApplicationController
before_filter :admin_required

VALID_NAME = Regexp.new "^\\w[\\w ]+$"
VALID_NAME = Regexp.new "\A\\w[\\w ]+\z"
# Disk Pool minimum free: default og 10GB, but for root,
# 20GB. so that when all drives are full, / should still have 10GB free.
DP_MIN_FREE_DEFAULT = 10
@@ -97,7 +97,7 @@ def new_share_name_check
render :partial => 'share/name_invalid'
return false
end
share = Share.find_by_name(sn)
share = Share.where(:name=>sn).first
if share
render :partial => 'share/name_not_available'
return false
@@ -118,7 +118,7 @@ def new_share_path_check
render :partial => 'share/path_invalid'
return false
end
share = Share.find_by_path(sp)
share = Share.where(:path=>sp).first
if share
render :partial => 'share/path_not_available'
return false
@@ -296,7 +296,7 @@ def update_disk_pool_copies

def toggle_disk_pool_partition
path = params[:path]
part = DiskPoolPartition.find_by_path(path)
part = DiskPoolPartition.where(:path=>path).first
if part
# was enabled - disable it by deleting it
# FIXME - see http://bugs.amahi.org/issues/show/510
@@ -318,7 +318,7 @@ def toggle_disk_pool_partition

def is_valid_domain_name(domain)
return false if domain.size > 15 || domain.size < 1
return false unless domain =~ /^[A-z][A-z_0-9]*$/
return false unless domain =~ /\A[A-z][A-z_0-9]*\z/
true
end

19 changes: 10 additions & 9 deletions app/controllers/user_sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -4,12 +4,12 @@
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License v3
# (29 June 2007), as published in the COPYING file.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# file COPYING for more details.
#
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Amahi
# team at http://www.amahi.org/ under "Contact Us."
@@ -34,7 +34,7 @@ def start
else
# initial system initialization
@user = User.new
flash[:notice] = t("amahi_initialization")
flash[:info] = t("amahi_initialization")
@title = t("amahi_initialization")
end
end
@@ -45,9 +45,10 @@ def create
remember_me = params[:remember_me]
@user_session = UserSession.new(:login => username, :password => password, :remember_me => remember_me)
if @user_session.save
flash[:success] = t 'logged_in_successfully'
redirect_to root_url
else
flash[:error] = t 'not_a_valid_user_or_password'
flash[:danger] = t 'not_a_valid_user_or_password'
render :action => 'new'
end
end
@@ -57,7 +58,7 @@ def destroy
@user_session = UserSession.find
@user_session.destroy
# FIXME-translate
flash[:notice] = t('you_have_been_logged_out')
flash[:info] = t('you_have_been_logged_out')
redirect_to root_path
end

@@ -67,7 +68,7 @@ def initialize_system
pwd = params[:password]
conf = params[:password_confirmation]
unless valid_admin_password?(pwd, conf)
flash[:error] = t 'not_a_valid_user_or_password'
flash[:danger] = t 'not_a_valid_user_or_password'
@user = User.new
sleep 1
render :action => 'start'
@@ -80,13 +81,13 @@ def initialize_system
# FIXME-cpg: very hackish constant for regular uid (1000)
unless name and uid and uid >= 1000
# not a system user. should we create one?
flash[:error] = t 'not_a_valid_user_or_password'
flash[:danger] = t 'not_a_valid_user_or_password'
@user = User.new
render :action => 'start'
return
end
# the user exists in the system .. does it exist in the database?
u = User.find_by_login(systemusername)
u = User.where(:login=>systemusername).first
if u
@user = u
else
@@ -102,7 +103,7 @@ def initialize_system
initialize_default_settings
redirect_to root_url
else
flash[:error] = t 'not_a_valid_user_or_password'
flash[:danger] = t 'not_a_valid_user_or_password'
render :action => 'start'
end
end
17 changes: 13 additions & 4 deletions app/helpers/tabs_helper.rb
Original file line number Diff line number Diff line change
@@ -17,13 +17,22 @@
module TabsHelper

def tab_class(tab)
klass = params[:controller] == tab.id ? 'active' : ''
if params[:controller] == tab.id
klass = 'active'
else
subtab = Tab.find(params[:controller])
if subtab==nil
if Tab.ischild(params[:controller],tab)
klass = 'active'
end
end
end
klass += " empty" unless tab.subtabs?
klass
end

def subtab_class(action = nil)
params[:action] == action ? 'active' : ''
def subtab_class(action = nil, tab_id)
((action == params[:action] && params[:controller] == tab_id) or (action == params[:controller] && Tab.find(params[:controller])==nil) ) ? 'active' : ''
end

def nav_class(tabs)
@@ -38,7 +47,7 @@ def debug_tab?
end

def advanced?
(s = Setting.find_by_name 'advanced') && s.set?
(s = Setting.where(:name=>'advanced').first) && s.set?
end

def debug?
18 changes: 9 additions & 9 deletions app/models/app.rb
Original file line number Diff line number Diff line change
@@ -41,9 +41,9 @@ class App < ActiveRecord::Base
has_many :children, :class_name => "AppDependency", :foreign_key => 'dependency_id'
has_many :dependencies, :through => :app_dependencies

scope :installed, where(:installed => true)
scope :in_dashboard, where(:show_in_dashboard => true).installed
scope :latest_first, :order => 'updated_at desc'
scope :installed, ->{where(:installed => true)}
scope :in_dashboard,-> {where(:show_in_dashboard => true).installed}
scope :latest_first, ->{order('updated_at desc')}

before_destroy :before_destroy_hook

@@ -111,7 +111,7 @@ def self.available
AmahiApi::api_key = Setting.value_by_name("api-key")
begin
AmahiApi::App.find(:all).map do |online_app|
App.find_by_identifier(online_app.id) ? nil : App.new(online_app.id, online_app)
App.where(:identifier=>online_app.id).first ? nil : App.new(online_app.id, online_app)
end.compact
rescue
[]
@@ -157,14 +157,14 @@ def install_status
end

def self.installation_status(identifier)
status = Setting.find_by_kind_and_name(identifier, 'install_status')
status = Setting.where(:kind=>identifier,:name=> 'install_status').first
return 0 unless status
status.value.to_i
end

def install_status=(value)
# create it dynamically if it does not exist
status = Setting.find_or_create_by(self.identifier, 'install_status', value)
status = Setting.where(:kind=>self.identifier, :name=> 'install_status').first_or_create
if value.nil?
status && status.destroy
return nil
@@ -213,7 +213,7 @@ def install_bg
self.create_db(:name => installer.database) if installer.database && !installer.database.blank?
# if it has a share, create it and install it
if installer.share
sh = Share.find_by_name installer.share
sh = Share.where(:name=>installer.share).first
if sh
# FIXME: autohook to it. this is for legacy shares. not needed in new installs
self.share = sh
@@ -376,7 +376,7 @@ def install_app_deps(installer)
return [] if deps.nil? or deps.blank?
deps.strip!
deps.split(/[, ]+/).map do |identifier|
a = App.find_by_identifier identifier
a = App.where(:identifier=>identifier).first
unless a
a = App.new identifier
a.install_bg
@@ -469,7 +469,7 @@ def webapp_name(name)
i = 0
add = ""
begin
wa = Webapp.find_by_name(name + add)
wa = Webapp.where(:name=>(name + add)).first
return (name+add) if wa.nil?
raise "cannot find a suitable webapp name. giving up at #{name+add}." if i > 29
i += 1
8 changes: 4 additions & 4 deletions app/models/db.rb
Original file line number Diff line number Diff line change
@@ -4,12 +4,12 @@
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License v3
# (29 June 2007), as published in the COPYING file.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# file COPYING for more details.
#
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Amahi
# team at http://www.amahi.org/ under "Contact Us."
@@ -40,7 +40,7 @@ def hostname
private

def after_create_hook
c = connection
c = self.class.connection
password = name
user = name
host = 'localhost'
@@ -58,7 +58,7 @@ def after_destroy_hook
Dir.chdir(DB_BACKUPS_DIR) do
system("ln -sf #{filename} latest-#{name}.bz2")
end
c = connection
c = self.class.connection
host = 'localhost'
c.execute "drop user '#{user}'@'#{host}';"
c.execute "drop database if exists `#{name}`;"
2 changes: 1 addition & 1 deletion app/models/dns_alias.rb
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ class DnsAlias < ActiveRecord::Base
after_destroy :restart
after_save :restart

scope :user_visible, where(["address != ?", ''])
scope :user_visible,->{where(["address != ?", ''])}

attr_accessible :name, :address

11 changes: 10 additions & 1 deletion app/models/plugin.rb
Original file line number Diff line number Diff line change
@@ -52,7 +52,12 @@ def install(installer, source)

# uninstall when the object is destroyed
def before_destroy
location = File.join(Rails.root, "plugins", "#{1000+id}-#{path}")
base = File.basename path
location = File.join(Rails.root, "plugins", "#{1000+id}-#{base}")
array = []
array <<"#{location}/db/migrate"
puts "Reverting the changes to the database made by the plugin"
ActiveRecord::Migrator.down(array,nil)
FileUtils.rm_rf location
# restart the rails stack -- FIXME: this is too much a restart would be best
c = Command.new "touch /var/hda/platform/html/tmp/restart.txt"
@@ -75,6 +80,10 @@ def dir2plugin(source, config)
FileUtils.rm_rf destination
FileUtils.mv source, destination
# FIXME: eventually we need to do migrations, probably here
array = []
array <<"#{destination}/db/migrate"
puts "Migrating database of the plugin, if applicable"
ActiveRecord::Migrator.up(array, nil)
# restart the rails stack -- FIXME: this is too much a restart would be best
c = Command.new "touch /var/hda/platform/html/tmp/restart.txt"
c.execute
14 changes: 7 additions & 7 deletions app/models/setting.rb
Original file line number Diff line number Diff line change
@@ -20,16 +20,16 @@ class Setting < ActiveRecord::Base

attr_accessible :name, :value, :kind

scope :by_name, lambda{|name| where(:name => name)}
scope :by_kind, lambda{|kind| where(:kind => kind)}
scope :by_name, lambda{|name| where(:name => name)}
scope :by_kind, lambda{|kind| where(:kind => kind)}

scope :general, by_kind(GENERAL)
scope :network, by_kind(NETWORK)
scope :shares, by_kind(SHARES)
scope :general, ->{by_kind(GENERAL)}
scope :network, ->{by_kind(NETWORK)}
scope :shares, ->{by_kind(SHARES)}

validates :value,
:length => { :maximum => 15 },
:format => { :with => /^[a-zA-Z][a-zA-Z0-9]{0,14}$/ },
:format => { :with => /\A[a-zA-Z][a-zA-Z0-9]{0,14}\z/ },
:if => Proc.new { |x| x.kind.eql?(Setting::GENERAL) && x.name.eql?('workgroup') },
:on => :update

@@ -49,7 +49,7 @@ def get(name)
end

def set(name, value, kind=GENERAL)
self.find_or_create_by_name(:name => name).update_attributes(value: value, kind: kind)
self.where(:name => name).first_or_create.update_attributes(value: value, kind: kind)
end

def get_kind(kind, name)
4 changes: 2 additions & 2 deletions app/models/share.rb
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ class Share < ActiveRecord::Base
DEFAULT_SHARES = [ "Books", "Pictures", "Movies", "Videos", "Music", "Docs", "Public" ].each {|s| I18n.t s }
PDC_SETTINGS = "/var/hda/domain-settings"

default_scope order("name")
default_scope {order("name")}
# scope :in_disk_pool, where([ "disk_pool_copies > ?", 0])

has_many :cap_accesses, :dependent => :destroy
@@ -43,7 +43,7 @@ class Share < ActiveRecord::Base
attr_accessible :name, :path, :rdonly, :visible, :tags, :extras

validates :name, :presence => true,
:format => { :with => /^\w[\w ]+$/ },
:format => { :with => /\A\w[\w ]+\z/ },
:length => { :maximum => 32 },
:uniqueness => { :case_sensitive => false }

2 changes: 1 addition & 1 deletion app/models/theme.rb
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ def self.available
tl = all
Dir.chdir(File.join(Rails.root, THEME_ROOT)) do
Dir.glob("*").sort.each do |theme_dir|
next if find_by_css theme_dir
next if where(:css=>theme_dir).first
theme_init_file = File.join(theme_dir, "init.rb")
if File.exist? theme_init_file
load theme_init_file
6 changes: 3 additions & 3 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@

class User < ActiveRecord::Base

scope :admins, where(:admin => true)
scope :admins, ->{ where(:admin => true)}

begin
acts_as_authentic do |c|
@@ -37,7 +37,7 @@ class User < ActiveRecord::Base
attr_accessible :login, :name, :password, :password_confirmation, :admin

validates :login, :presence => true,
:format => { :with => /^[A-Za-z][A-Za-z0-9]+$/ },
:format => { :with => /\A[A-Za-z][A-Za-z0-9]+\z/ },
:length => { :in => 3..32 },
:uniqueness => { :case_sensitive => false },
:user_not_exist_in_system => {:message => 'already exists in system', :on => :create}
@@ -71,7 +71,7 @@ def system_all_new_users
res = []
Dir.chdir("/home") do
Dir.glob("*").sort.reverse.each do |login|
unless User.find_by_login login
unless User.where(:login=> login).first
name, uid = system_find_name_by_username login
# FIXME-cpg: Fedora specific constant 500 here
res << { :login => login, :name => name } unless name.nil? or name.blank? or uid < 500
3 changes: 2 additions & 1 deletion app/models/webapp.rb
Original file line number Diff line number Diff line change
@@ -97,13 +97,14 @@ def conf_file
else # generic
f = File.open(BASE % "generic")
end
server_aliases = self.aliases.split(/[, ]+/).select{ |s| ! (s.empty? || DnsAlias.find_by_alias(s)) }
server_aliases = self.aliases.split(/[, ]+/).select{ |s| ! (s.empty? || DnsAlias.where(:alias=>s).first) }
server_aliases += self.webapp_aliases.map{|wa| wa.name}
aliases = server_aliases.count > 0 ? ("ServerAlias " + server_aliases.join(" ")) : ""
conf = f.readlines.join
conf = conf.gsub(/HDA_APP_NAME/, name)
conf = conf.gsub(/APP_ROOT_DIR/, path)
conf = conf.gsub(/HDA_DOMAIN/, domain) unless domain.empty?
conf = conf.gsub(/HDA_AUTHFILE/, "#{path}/htpasswd")
conf = conf.gsub(/HDA_ACCESS/, login_required ? access_conf : '')
conf = conf.gsub(/APP_ALIASES/, aliases || '')
begin
4 changes: 2 additions & 2 deletions app/models/webapp_alias.rb
Original file line number Diff line number Diff line change
@@ -20,12 +20,12 @@ class WebappAlias < ActiveRecord::Base

after_save :save_webapp
after_destroy :save_webapp

attr_accessible :name, :webapp_id
validates :name,
:presence => true,
:uniqueness => true,
:length => { :within => 1..254 },
:format => { :with => /^[a-z0-9][a-z0-9-]*(\.[a-z0-9][a-z0-9-]*){0,5}$/i }
:format => { :with => /\A[a-z0-9][a-z0-9-]*(\.[a-z0-9][a-z0-9-]*){0,5}\z/i }

def to_s
name
2 changes: 1 addition & 1 deletion app/views/aliases/_new.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<br />

<%= button_to_function " #{t('new_alias')} &raquo; ", update_page { |page|
<%= button_to " #{t('new_alias')} &raquo; ", update_page { |page|
page.hide 'new-alias-to-step1'
page[:alias_alias].value = ""
page[:alias_address].value = ""
6 changes: 3 additions & 3 deletions app/views/aliases/_one.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<%
name = [h(one.alias), @domain].join '.'
name = h($1) if one.alias =~ /(.*)\.$/
name = h($1) if one.alias =~ /(.*)\.\z/
(base, addr) = case one.address
when ''
[@net, @self]
when /^\d+$/
when /\A\d+\z/
[@net, [@net, h(one.address)].join('.')]
else
['', h(one.address)]
@@ -22,7 +22,7 @@
<table id="alias_row_<%= uid %>" class="settings stretchtoggle" onmouseup="<%= h toggler %>">
<tr>
<td class="settings-col1 aliases-col1">
<%= link_to_function(h(name), '') %>
<%= link_to(h(name), '') %>
</td>
<td class="settings-col2 aliases-col2" id="alias_ip_<%= uid %>">
<%= h(addr) %>
2 changes: 1 addition & 1 deletion app/views/aliases/_step1.html.erb
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@
<tr><td>&nbsp;</td></tr>
<tr>
<td>&nbsp;</td><td>&nbsp;</td><td>
<%= link_to_function t('cancel'), update_page { |page|
<%= link_to t('cancel'), update_page { |page|
page.hide 'new-alias-step1'
page.show 'new-alias-to-step1'
page[:alias_alias].value = ""
51 changes: 0 additions & 51 deletions app/views/debug/_app_logs.rhtml

This file was deleted.

2 changes: 0 additions & 2 deletions app/views/debug/_debug_submit_failed.rjs

This file was deleted.

5 changes: 0 additions & 5 deletions app/views/debug/_debug_submit_worked.rjs

This file was deleted.

18 changes: 18 additions & 0 deletions app/views/debug/_form.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
- message_string = "\n\nExplain the sequence of events leading to the error\nin as much detail as you can.\n\nThe more *concrete detail* you can add,\nthe higher chances we fix the problem quickly!"

= form_for :debug, :remote => true, :html => {\
:class => 'debug-form',\
:id => 'submit-debug-form'\
} do |f|
.control-group
h3.debug-form Help improve Amahi by sending crash reports and anonymous usage data.
.control-group
.controls= f.text_field :subject, :size => 32, :maxlength => 40, :placeholder => "Describe what failed here ...",:class=> "form-control debug-form"
.control-group
.controls
= text_area_tag :comments, '', :rows => 10, :cols => 80, :placeholder => message_string, :class=> "form-control debug-form"
.control-group.create-btn
.controls
= spinner
= button_tag 'Submit', :type => 'submit', :id => 'debug_button', :class => 'btn btn-submit btn-info btn-sm debug-form', :data=>{:confirm=>"Machine logs will be submitted to Amahi for debug.\nThis will help improve Amahi!\nWould you like to submit?"}
= link_to t('cancel'), '#', :class => 'close-area cancel-link debug-form', :data => {:related=> '#debug-button'}, :onclick=>"$('#debug-submit-form').hide('slow');"
4 changes: 0 additions & 4 deletions app/views/debug/_logs.rhtml

This file was deleted.

6 changes: 0 additions & 6 deletions app/views/debug/_system.rhtml

This file was deleted.

9 changes: 9 additions & 0 deletions app/views/debug/index.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

= button_tag 'Submit for Debug', :type => 'button', :class => 'open-area btn btn-create', :id => "debug-button", :data => { :related => "#debug-submit-form" }

#debug-submit-form[style="display:none;"]
fieldset
legend &nbsp; Debug Report &nbsp;
= render 'form'
pre
= SystemUtils.run "tail -100 #{Rails.root}/log/production.log"
3 changes: 3 additions & 0 deletions app/views/debug/logs.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pre
= SystemUtils.run "grep -v \"hda dhcpd:\" #{Platform.file_name(:syslog)} | tail -100 | tac"

4 changes: 4 additions & 0 deletions app/views/debug/system.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pre
= SystemUtils.uptime
= SystemUtils.run 'cat /proc/cpuinfo'
= SystemUtils.run 'cat /proc/meminfo'
2 changes: 1 addition & 1 deletion app/views/firewall/_new.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<br />

<%= button_to_function " #{t 'new_firewall_rule'} &raquo; ", update_page { |page|
<%= button_to " #{t 'new_firewall_rule'} &raquo; ", update_page { |page|
page.hide 'new-firewall-to-step1'
page.show 'new-firewall-step1'
}, :id => "new-firewall-to-step1" %>
2 changes: 1 addition & 1 deletion app/views/firewall/_rule.html.erb
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
<table id="fw_rule_row_<%= uid %>" class="settings stretchtoggle" onmouseup="<%= h toggler %>">
<tr>
<td class="settings-col1 fw-rules-col1">
<%= link_to_function(name, '') %>
<%= link_to(name, '') %>
</td>
<td class="settings-col2 fw-rules-col2" id="fw_rule_state_<%= uid %>">
<%= active ? "Active" : "Inactive" %>
2 changes: 1 addition & 1 deletion app/views/hosts/_new.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<br />

<%= button_to_function " #{t('new_static_ip')} &raquo; ", update_page { |page|
<%= button_to " #{t('new_static_ip')} &raquo; ", update_page { |page|
page.hide 'new-host-to-step1'
page[:host_host].value = ""
page[:host_address].value = ""
2 changes: 1 addition & 1 deletion app/views/hosts/_one.html.erb
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
<table id="host_row_<%= uid %>" class="settings stretchtoggle" onmouseup="<%= h toggler %>">
<tr>
<td class="settings-col1 hosts-col1">
<%= link_to_function(h(name), '') %>
<%= link_to(h(name), '') %>
</td>
<td class="settings-col2 hosts-col2" id="host_ip_<%= uid %>">
<%= h(addr) %>
2 changes: 1 addition & 1 deletion app/views/hosts/_step1.html.erb
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@
<tr><td>&nbsp;</td></tr>
<tr>
<td>&nbsp;</td><td>&nbsp;</td><td>
<%= link_to_function t('cancel'), update_page { |page|
<%= link_to t('cancel'), update_page { |page|
page.hide 'new-host-step1'
page.show 'new-host-to-step1'
page[:host_host].value = ""
63 changes: 63 additions & 0 deletions app/views/layouts/debug.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
doctype 5
html[dir="#{@locale_direction}" lang="#{I18n.locale}" xml:lang="#{I18n.locale}"]
head
meta charset="utf-8"
title = full_page_title

= stylesheet_link_tag 'application'

- if theme.name != "default" and theme.disable_inheritance == false
= stylesheet_link_tag(theme_stylesheet_path('style', theme.default))
= stylesheet_link_tag(theme_stylesheet_path('rtl', theme.default)) if rtl?

= theme_stylesheet_link_tag 'style'
= theme_stylesheet_link_tag('rtl') if rtl?
- amahi_plugins.each do |p|
= stylesheet_link_tag p[:class].underscore

/[ if lt IE 9 ]
= javascript_include_tag 'http://html5shim.googlecode.com/svn/trunk/html5.js'
= javascript_tag {render 'shared/js_vars'}
= javascript_include_tag 'application'
- amahi_plugins.each do |p|
= javascript_include_tag p[:class].underscore

= javascript_tag {'$.fx.off = true;' if Rails.env.test?}
- for header in theme.headers do
= header =~ /\.js$/ ? javascript_include_tag(header) : header

link rel="search" type="application/opensearchdescription+xml" title="HDA Search" href="/search.xml"
link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"

= csrf_meta_tags

body

= render 'layouts/header'

#content
= render 'layouts/subheader'
= render 'shared/flash_messages'
#app.inner
#tabs
nav.preftab
ul
li.active
a href='/tab/debug'
= t 'debug'
ul
li[class="#{request.fullpath == '/tab/debug' ? 'active' : ''}"]
= link_to "App Logs", '/tab/debug'
li[class="#{request.fullpath == '/tab/debug/logs' ? 'active' : ''}"]
= link_to "Logs", '/tab/debug/logs'
li[class="#{request.fullpath == '/tab/debug/system' ? 'active' : ''}"]
= link_to "System Info", '/tab/debug/system'
#preferences
.preftab
= yield

= render 'layouts/footer'

#js-templates[style="display:none"]
= yield :js_templates
2 changes: 1 addition & 1 deletion app/views/server/_one.html.erb
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
<table id="server_row_<%= uid %>" class="settings stretchtoggle" onmouseup="<%= h toggler %>">
<tr>
<td class="settings-col1 servers-col1">
<%= link_to_function(server.comment, '') %>
<%= link_to(server.comment, '') %>
</td>
<td class="settings-col2 servers-col2" id="server_status_<%= uid %>">
<%= status %>
3 changes: 2 additions & 1 deletion app/views/shared/_flash_messages.html.slim
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#errors
- flash.each do |name, msg|
div[id="flash_#{name}"]= msg
div[class=" alert alert-#{name}"]
strong = msg
4 changes: 2 additions & 2 deletions app/views/shared/_tabs.html.slim
Original file line number Diff line number Diff line change
@@ -9,9 +9,9 @@
ul
- if @advanced
- tab.advanced_subtabs.each do |subtab|
li[class=subtab_class(subtab.id)]
li[class=subtab_class(subtab.id,tab.id)]
= link_to t(subtab.label), subtab.url
- else
- tab.basic_subtabs.each do |subtab|
li[class=subtab_class(subtab.id)]
li[class=subtab_class(subtab.id,tab.id)]
= link_to t(subtab.label), subtab.url
2 changes: 1 addition & 1 deletion app/views/user_sessions/new.html.slim
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
a[href="http://www.amahi.org/" title="Powered by Amahi"] Amahi Server Login

- flash.each do |name, msg|
div[class="message-#{name}"]= msg
div[class="alert alert-#{name}"]= msg

= form_for @user_session do |f|
p
2 changes: 1 addition & 1 deletion app/views/user_sessions/start.html.slim
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
a[href="http://www.amahi.org/" title="Powered by Amahi"] Amahi Server Login

- flash.each do |name, msg|
div[class="message-#{name}"]= msg
div[class="alert alert-#{name}"]= msg

= form_for @user, :url => initialize_system_path(@user.login) do |f|
p
9 changes: 2 additions & 7 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -2,12 +2,7 @@

require 'rails/all'

if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
Bundler.require(:default, Rails.env)

module AmahiHDA
class Application < Rails::Application
@@ -55,7 +50,7 @@ class Application < Rails::Application
config.active_record.whitelist_attributes = true

# Enable the asset pipeline
config.assets.enabled = true
# config.assets.enabled = true

# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.1'
21 changes: 11 additions & 10 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -6,8 +6,9 @@
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false

config.eager_load = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
#config.whiny_nils = true

# Show full error reports and disable caching
config.consider_all_requests_local = true
@@ -19,18 +20,18 @@
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log

# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
# # Only use best-standards-support built into browsers
# config.action_dispatch.best_standards_support = :builtin

# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict
# # Raise exception on mass assignment protection for Active Record models
# config.active_record.mass_assignment_sanitizer = :strict

# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
config.active_record.auto_explain_threshold_in_seconds = 0.5
# # Log the query plan for queries taking more than this (works
# # with SQLite, MySQL, and PostgreSQL)
# config.active_record.auto_explain_threshold_in_seconds = 0.5

# Do not compress assets
config.assets.compress = false
# # Do not compress assets
# config.assets.compress = false

# Expands the lines which load the assets
config.assets.debug = true
3 changes: 2 additions & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
# Code is not reloaded between requests
config.cache_classes = true

config.eager_load = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
@@ -12,7 +13,7 @@
config.serve_static_assets = true

# Compress JavaScripts and CSS
config.assets.compress = false
config.assets.js_compressor = :uglifier

# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true
5 changes: 3 additions & 2 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -7,12 +7,13 @@
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true

config.eager_load = false
# Configure static asset server for tests with Cache-Control for performance
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"

# Log error messages when you accidentally call methods on nil
config.whiny_nils = true
# config.whiny_nils = true

# Show full error reports and disable caching
config.consider_all_requests_local = true
@@ -30,7 +31,7 @@
config.action_mailer.delivery_method = :test

# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict
# config.active_record.mass_assignment_sanitizer = :strict

# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr
1 change: 1 addition & 0 deletions config/initializers/secret_token.rb
Original file line number Diff line number Diff line change
@@ -5,3 +5,4 @@
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
AmahiHDA::Application.config.secret_token = '8e134f84fdc7df1d23c1c8c4bad7d807589cfb2f1099e838c0f4c7fb5c2d9d8edfae608899239afb41762528cd46aea3dd1d7afccbead5f844151eac2b72f21c'
AmahiHDA::Application.config.secret_key_base = '8e134f84fdc7df1d23c1c8c4bad7d807589cfb2f1099e838c0f4c7fb5c2d9d8edfae608899239afb41762528cd46aea3dd1d7afccbead5f844151eac2b72f21c'
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@

# login
log_in: Log In
logged_in_successfully: "Logged in successfully"
not_a_valid_user_or_password: "Error: Incorrect username or password"
first_time_admin_setup: "First admin setup. Please re-create your user password."
remember_me: Remember me
18 changes: 10 additions & 8 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@

AmahiHDA::Application.routes.draw do

themes_for_rails
amahi_plugin_routes

match 'login' => 'user_sessions#new', :as => :login
match 'logout' => 'user_sessions#destroy', :as => :logout
match 'start' => 'user_sessions#start', :as => :start
match 'user_sessions/initialize_system' => 'user_sessions#initialize_system', :as => :initialize_system

match 'login' => 'user_sessions#new', :as => :login, via: [:get]
match 'logout' => 'user_sessions#destroy', :as => :logout, via: [:get]
match 'start' => 'user_sessions#start', :as => :start, via: [:get]
match 'user_sessions/initialize_system' => 'user_sessions#initialize_system', :as => :initialize_system, via: [:get,:post]
get '/tab/debug'=>'debug#index'
post '/tab/debug'=>'debug#submit'
get '/tab/debug/system'=>'debug#system'
get '/tab/debug/logs'=>'debug#logs'
resources :shares do
collection do
get 'disk_pooling'
@@ -35,10 +37,10 @@

resources :user_sessions, :hosts, :aliases

match 'search/:action' => 'search', :as => :search
match 'search/:action' => 'search', :as => :search, via: [:get,:post]

root :to => 'front#index'

match ':controller(/:action(/:id))(.:format)'
match ':controller(/:action(/:id))(.:format)', via: [:get]

end
28 changes: 26 additions & 2 deletions doc/plugins.md
Original file line number Diff line number Diff line change
@@ -22,13 +22,23 @@ Each plugin has to have a file called `config/amahi_plugin.yml` with details of
name: Foo Bar Tab
# class to be mounted
class: FooBar
# kind of plugin (so far we only support 'tab' plugins)
kind: tab
# url where it will be mounted in the platform
url: /tab/foobar

No two apps have may use the same class or url to be mounted.

In case you are adding plugin as a subtab under a tab(Fuzzbar) :

# human readable name (no localization supported yet)
# for example, it may be used as the text of the tab or the page title, etc.
name: Foo Bar Sub Tab
# class to be mounted
class: FooBar
kind: subtab
# url where it will be mounted in the platform
url: /tab/fuzzbar/foobar

## Adding Tabs and Subtabs

To add visible tabs in a plugin, one has to do it programmatically at plugin initialization time with what in RoR is known as an initializer.
@@ -37,10 +47,13 @@ Example for initialization for a plugin (e.g. plugin/foo_bar/config/initializers

```ruby
# plugin initialization -- set up a tab by calling Tab.new:
#Checks for Existing tab with the same controller.
unless t = Tab.find("foobar")
# - first argument to Tab.new is the controller that it will hooked up to
# - second argument is a string, the label for the tab. This will support internationalization in the future
# - third argument is the route it should be mounted on, example /tab/foobar
t = Tab.new("foobar", "FooBar", "/tab/apps")
t = Tab.new("foobar", "FooBar", "/tab/apps")
end
# add any subtabs to this tab with what you need.
# The params are
# - controller
@@ -53,6 +66,17 @@ t.add("expert", "Expert Settings", true)
t.add("other", "Other Settings")
```

To add a plugin as a subtab of an existing tab(Fuzzbar) :
```ruby
# plugin initialization -- set up a tab by calling Tab.new:
#Checks for Existing tab with the same controller.
unless t = Tab.find("fuzzbar")
t = Tab.new("fuzzbar", "FuzzBar", "/tab/Fuzzbar")
end
t.add("foobar", "Foobar")
```


## Principles

* One folder = One plugin. This is a must. To install an Amahi plugin manually, all there needs to be done is copy a single folder into the plugins/ directory and done. It's good for manual installation, it's good for automatic installation.
4 changes: 2 additions & 2 deletions lib/generators/plugin/plugin_generator.rb
Original file line number Diff line number Diff line change
@@ -110,8 +110,8 @@ class Engine < ::Rails::Engine
# root of the plugin
root :to => '#{plural_name}#index'
# examples of controllers built in this generator. delete at will
match 'settings' => '#{plural_name}#settings'
match 'advanced' => '#{plural_name}#advanced'
match 'settings' => '#{plural_name}#settings',:via=> :all
match 'advanced' => '#{plural_name}#advanced',:via => :all
end
FILE
end
2 changes: 1 addition & 1 deletion lib/partition_utils.rb
Original file line number Diff line number Diff line change
@@ -77,7 +77,7 @@ def disk_stats(path)
# return total bytes, free bytes
[blocks * bsize, bfree * bsize]
rescue => e
RAILS_DEFAULT_LOGGER.error("******** disk stats error for #{path}: #{e.inspect}")
Rails.logger.error("******** disk stats error for #{path}: #{e.inspect}")
[0, 0]
end
end
2 changes: 1 addition & 1 deletion lib/set_theme.rb
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ class << self

def find
begin
theme_setting = Setting.find_or_create_by_name(:name => 'theme', :value => self.default)
theme_setting = Setting.where(:name => 'theme').first_or_create
path = theme_setting.value
theme_path = init_file_exists?(path) ? path : self.default
theme = init(theme_path)
35 changes: 35 additions & 0 deletions lib/tab.rb
Original file line number Diff line number Diff line change
@@ -45,6 +45,41 @@ def advanced_subtabs
subtabs
end

# Return the Tab(if exists) with id:contoller. Otherwise creates a new Tab
def self.find_or_create(controller, label, url)
tabs = self.find(controller)
if tabs==nil
tabs = Tab.new(controller, label, url)
end
tabs
end

#Returns Tab with id:controller
def self.find(controller)
tabs = []
AmahiHDA::Application.config.tabs.each do |tab|
if tab.id==controller
tabs << tab
break
end
end
tabs.first
end

#checks if tab has a subtab with id:controller
def self.ischild(controller,tab)
child = false
if tab.subtabs?
tab.subtabs.each do |subtab|
if(subtab.id == controller)
child = true
break
end
end
end
child
end

private

# keep top-level tabs in an app variable, due to complex initialzation issues
4 changes: 2 additions & 2 deletions plugins/010-users/app/views/users/_auth.html.slim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
td.top
label #{t('authentication')}
td.top
= link_to_function content_tag('i', '', class: 'auth'), "$(this).parent().children('.pubkey-area').toggle('slow')",
= link_to content_tag('i', '', class: 'auth'), '#', :onclick=>"$(this).parent().children('.pubkey-area').toggle('slow')",
:title => t('manage_your_public_key'),
:class => 'control-action',:id=>"user-auth-control-action-#{user.id}"
= theme_image_tag("ok.png", :class => 'ok', :style => 'display:none')
@@ -15,4 +15,4 @@ td.top
.control-group
.controls
= submit_tag t('update_key'), :class => 'btn'
= link_to_function t('cancel'), "$(this).parents('.pubkey-area').hide('slow')", :class => 'cancel-link'
= link_to t('cancel'), '#', :onclick=>"$(this).parents('.pubkey-area').hide('slow')", :class => 'cancel-link'
4 changes: 2 additions & 2 deletions plugins/010-users/app/views/users/_password.html.slim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
td.top
label #{t('password')}
td.top
= link_to_function content_tag('i', '', class: 'password'), "$(this).parent().find('.password-edit').toggle('slow')",
= link_to content_tag('i', '', class: 'password'),'#', :onclick=> "$(this).parent().find('.password-edit').toggle('slow')",
:class => 'control-action',:id=>"user-password-control-action-#{user.id}"
= form_for user, url: users_engine.update_password_user_path(user), remote: true, method: :put, html: { class: 'update-password update-form form-horizontal' } do |f|
.password-edit[style="display:none"]
@@ -15,5 +15,5 @@ td.top
.controls
= spinner
= f.submit t('change'), :class => 'btn',:id=>"submit_password_#{user.id}"
= link_to_function t('cancel'), "$(this).parents('.password-edit').hide('slow').find('input[type=password]').val('')", :class => 'cancel-link'
= link_to t('cancel'), '#', :onclick=>"$(this).parents('.password-edit').hide('slow').find('input[type=password]').val('')", :class => 'cancel-link'
.messages
2 changes: 2 additions & 0 deletions plugins/010-users/config/initializers/plugin_init.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# plugin initialization
t = Tab.new("users", "users", "/tab/users")
# add any subtabs with what you need. params are controller and the label
t.add('index', "details")
# disable settings for now
# t.add('settings', "settings")
2 changes: 1 addition & 1 deletion plugins/010-users/config/routes.rb
Original file line number Diff line number Diff line change
@@ -9,5 +9,5 @@
put 'update_pubkey'
end
end
match 'settings' => 'users#settings'
match 'settings' => 'users#settings' ,via: [:get,:post]
end
4 changes: 2 additions & 2 deletions plugins/020-shares/app/views/shares/_permissions.html.slim
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
.permissions
= spinner
= link_to content_tag('span', '', :class => 'tools'), clear_permissions_share_path(share), :remote => true, :method => 'put',
:confirm => t('this_will_clear_permissions_wide', :share => share.name), :class => 'clear-permissions remote-btn',
:class => 'clear-permissions remote-btn',
:title => t('this_will_clear_permissions_wide', :share => share.name),
:data => { :success => t('permissions_cleared'), :error => t('permissions_clearning_error') }
:data => { :confirm => t('this_will_clear_permissions_wide', :share => share.name), :success => t('permissions_cleared'), :error => t('permissions_clearning_error') }
span.messages
4 changes: 2 additions & 2 deletions plugins/020-shares/config/routes.rb
Original file line number Diff line number Diff line change
@@ -2,6 +2,6 @@
# root of the plugin
root :to => 'shares#index'
# examples of controllers built in this generator. delete at will
match 'settings' => 'shares#settings'
match 'advanced' => 'shares#advanced'
match 'settings' => 'shares#settings', via: [:get,:post]
match 'advanced' => 'shares#advanced', via: [:get,:post]
end
4 changes: 2 additions & 2 deletions plugins/030-disks/app/views/disks/index.html.slim
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@
th
= t 'temperature'
| &nbsp;(
= link_to_function "F", '$("#disks-table .temperature").toggle()', class: 'temperature', style: 'display:none'
= link_to_function "C", '$("#disks-table .temperature").toggle()', class: 'temperature'
= link_to "F", '#', :onclick=> '$("#disks-table .temperature").toggle()', class: 'temperature', style: 'display:none'
= link_to "C", '#', :onclick=> '$("#disks-table .temperature").toggle()', class: 'temperature'
| )
tbody
- @disks.each do | disk |
2 changes: 1 addition & 1 deletion plugins/030-disks/config/routes.rb
Original file line number Diff line number Diff line change
@@ -2,5 +2,5 @@
# root of the plugin
root :to => 'disks#index'
# examples of controllers built in this generator. delete at will
match 'mounts' => 'disks#mounts'
match 'mounts' => 'disks#mounts', via: [:get,:post]
end
10 changes: 5 additions & 5 deletions plugins/040-apps/app/controllers/apps_controller.rb
Original file line number Diff line number Diff line change
@@ -34,13 +34,13 @@ def installed

def install
identifier = params[:id]
@app = App.find_by_identifier identifier
@app = App.where(:identifier=>identifier).first
App.install identifier unless @app
end

def install_progress
identifier = params[:id]
@app = App.find_by_identifier identifier
@app = App.where(:identifier=>identifier).first

if @app
@app.reload
@@ -56,13 +56,13 @@ def install_progress

def uninstall
identifier = params[:id]
@app = App.find_by_identifier identifier
@app = App.where(:identifier=>identifier).first
@app.uninstall if @app
end

def uninstall_progress
identifier = params[:id]
@app = App.find_by_identifier identifier
@app = App.where(:identifier=>identifier).first
if @app
@app.reload
@progress = @app.install_status
@@ -76,7 +76,7 @@ def uninstall_progress

def toggle_in_dashboard
identifier = params[:id]
app = App.find_by_identifier identifier
app = App.where(:identifier=>identifier).first
if app.installed
app.show_in_dashboard = ! app.show_in_dashboard
app.save
52 changes: 0 additions & 52 deletions plugins/040-apps/app/controllers/webapp_alias_controller.rb

This file was deleted.

146 changes: 0 additions & 146 deletions plugins/040-apps/app/controllers/webapp_controller.rb

This file was deleted.

6 changes: 3 additions & 3 deletions plugins/040-apps/app/helpers/apps_helper.rb
Original file line number Diff line number Diff line change
@@ -17,9 +17,9 @@
module AppsHelper

def short_desc(app)
desc = app.description ? app.description.gsub(/<[^>]+>/, '') : t('no_description_supplied')
desc = truncate(strip_tags(desc), :length => 70, :omission => '&nbsp;...') if desc.length > 70
desc.html_safe
return t('no_description_supplied') unless app.description
# truncate if too long
truncate(strip_tags(app.description), length: 90)
end

def name_with_warning(app)
7 changes: 3 additions & 4 deletions plugins/040-apps/app/views/apps/_is_installed.html.slim
Original file line number Diff line number Diff line change
@@ -20,21 +20,20 @@

- if app.webapp
div.app-url= link_to(app.full_url, app.full_url, :target => '_blank')
= render 'in_dashboard', :app => app

- if app.plugin
div.app-url= link_to(app.plugin.name, app.plugin.path, :target => '_blank')
= spinner

- if app.theme
div.app-url= link_to(t('manage_themes'), settings_engine.themes_path)

- if app.webapp
= render 'in_dashboard', :app => app
= spinner

br
br
br

= spinner
span.progress
- unless app.has_dependents?
span.install-button
4 changes: 0 additions & 4 deletions plugins/040-apps/app/views/webapp/_body.html.erb

This file was deleted.

3 changes: 0 additions & 3 deletions plugins/040-apps/app/views/webapp/_index.html.erb

This file was deleted.

41 changes: 0 additions & 41 deletions plugins/040-apps/app/views/webapp/_list.html.erb

This file was deleted.

12 changes: 0 additions & 12 deletions plugins/040-apps/app/views/webapp/_login_required.html.erb

This file was deleted.

5 changes: 0 additions & 5 deletions plugins/040-apps/app/views/webapp/_name_available.rjs

This file was deleted.

4 changes: 0 additions & 4 deletions plugins/040-apps/app/views/webapp/_name_bad.rjs

This file was deleted.

4 changes: 0 additions & 4 deletions plugins/040-apps/app/views/webapp/_name_unavailable.rjs

This file was deleted.

30 changes: 0 additions & 30 deletions plugins/040-apps/app/views/webapp/_new.html.erb

This file was deleted.

3 changes: 0 additions & 3 deletions plugins/040-apps/app/views/webapp/_path_available.rjs

This file was deleted.

3 changes: 0 additions & 3 deletions plugins/040-apps/app/views/webapp/_path_bad.rjs

This file was deleted.

3 changes: 0 additions & 3 deletions plugins/040-apps/app/views/webapp/_path_exists.rjs

This file was deleted.

59 changes: 0 additions & 59 deletions plugins/040-apps/app/views/webapp/_step1.rhtml

This file was deleted.

120 changes: 0 additions & 120 deletions plugins/040-apps/app/views/webapp/_webapp.html.erb

This file was deleted.

18 changes: 0 additions & 18 deletions plugins/040-apps/app/views/webapp/_webapp_aliases.html.erb

This file was deleted.

16 changes: 0 additions & 16 deletions plugins/040-apps/app/views/webapp_alias/new.js.erb

This file was deleted.

7 changes: 3 additions & 4 deletions plugins/040-apps/config/routes.rb
Original file line number Diff line number Diff line change
@@ -2,14 +2,13 @@
# root of the plugin
root :to => 'apps#index'
# examples of controllers built in this generator. delete at will
match 'installed' => 'apps#installed'
match 'webapps' => 'apps#advanced'
match 'installed' => 'apps#installed', via: [:get,:post]

post 'install/:id' => 'apps#install', as: 'install'
get 'install_progress/:id' => 'apps#install_progress', as: 'install_progress'
match 'install_progress/:id' => 'apps#install_progress', as: 'install_progress', via: [:get,:post]

post 'uninstall/:id' => 'apps#uninstall', as: 'uninstall'
get 'uninstall_progress/:id' => 'apps#uninstall_progress', as: 'uninstall_progress'
match 'uninstall_progress/:id' => 'apps#uninstall_progress', as: 'uninstall_progress', via: [:get,:post]

put 'toggle_in_dashboard/:id' => 'apps#toggle_in_dashboard', as: 'toggle_in_dashboard'
end
Original file line number Diff line number Diff line change
@@ -20,3 +20,11 @@ $ ->
$ ->
$(".preftab").on "ajax:success", "#locale", ->
window.location.reload(true)

$(document).on "click", ".remote-check", (event)->
checkbox = $(this)
checkbox.prop("checked",!checkbox.prop("checked"))
true

$(document).on "ajax:complete",".remote-check", ->
$(this).prop("checked",!$(this).prop("checked"))
6 changes: 3 additions & 3 deletions plugins/080-settings/app/controllers/settings_controller.rb
Original file line number Diff line number Diff line change
@@ -21,8 +21,8 @@ class SettingsController < ApplicationController
def index
@page_title = t 'settings'
@available_locales = locales_implemented
@advanced_settings = Setting.find_by_name('advanced')
@guest = Setting.find_by_name("guest-dashboard")
@advanced_settings = Setting.where(:name=>'advanced').first
@guest = Setting.where(:name=>"guest-dashboard").first
@version = Platform.platform_versions
end

@@ -120,7 +120,7 @@ def themes
end

def activate_theme
s = Setting.find_by_name "theme"
s = Setting.where(:name=> "theme").first
s.value = params[:id]
s.save!
# redirect rather than render, so that it re-displays with the new theme
4 changes: 2 additions & 2 deletions plugins/080-settings/app/views/settings/index.html.slim
Original file line number Diff line number Diff line change
@@ -42,14 +42,14 @@ div.settings-fields.settings-wrap
method: :post,
class: 'btn-system',
id: 'btn-poweroff',
confirm: t('this_will_power_off')
data: {confirm: t('this_will_power_off')}
= link_to t('reboot'),
settings_engine.reboot_path,
remote: true,
method: :post,
class: 'btn-system',
id: 'btn-reboot',
confirm: t('this_will_reboot')
data: {confirm: t('this_will_reboot')}
div.settings-fields#info-table
table
tr
30 changes: 16 additions & 14 deletions plugins/080-settings/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
Settings::Engine.routes.draw do
# root of the plugin
root :to => 'settings#index'
match 'change_language' => 'settings#change_language'
match 'toggle_setting' => 'settings#toggle_setting'
match 'reboot' => 'settings#reboot'
match 'poweroff' => 'settings#poweroff'
match 'servers' => 'settings#servers'
match 'servers/:id/refresh' => 'settings#refresh', as: 'refresh'
match 'servers/:id/start' => 'settings#start', as: 'start'
match 'servers/:id/stop' => 'settings#stop', as: 'stop'
match 'servers/:id/restart' => 'settings#restart', as: 'restart'
match 'servers/:id/toggle_monitored' => 'settings#toggle_monitored', as: 'toggle_monitored'
match 'servers/:id/toggle_start_at_boot' => 'settings#toggle_start_at_boot', as: 'toggle_start_at_boot'
match 'refresh' => 'settings#refresh'
match 'themes' => 'settings#themes'
match 'activate_theme' => 'settings#activate_theme'
match 'change_language' => 'settings#change_language', via: [:get,:post]
match 'toggle_setting' => 'settings#toggle_setting', via: [:get,:post]
match 'reboot' => 'settings#reboot', via: [:get,:post]
match 'poweroff' => 'settings#poweroff', via: [:get,:post]
match 'servers' => 'settings#servers', via: [:get,:post]
match 'servers/:id/refresh' => 'settings#refresh', as: 'refresh', via: [:get,:post]
match 'servers/:id/start' => 'settings#start', as: 'start', via: [:get,:post]
match 'servers/:id/stop' => 'settings#stop', as: 'stop', via: [:get,:post]
match 'servers/:id/restart' => 'settings#restart', as: 'restart', via: [:get,:post]
match 'servers/:id/toggle_monitored' => 'settings#toggle_monitored', as: 'toggle_monitored', via: [:get,:post]
match 'servers/:id/toggle_start_at_boot' => 'settings#toggle_start_at_boot', as: 'toggle_start_at_boot', via: [:get,:post]
match 'refresh' => 'settings#refresh', via: [:get,:post]
match 'themes' => 'settings#themes', via: [:get,:post]
match 'activate_theme' => 'settings#activate_theme', via: [:get,:post]

put 'revoke_app' => 'settings#revoke_app', as: 'revoke_app'
end
2 changes: 1 addition & 1 deletion script/install-app
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ def main(app_id, install)
exit 1
end
begin
app = install ? App.new(app_id) : App.find_by_identifier(app_id)
app = install ? App.new(app_id) : App.where(:identifier=>app_id).first
raise "Error: cannot find #{app_id} to #{install ? "install" : "uninstall"}!" unless app
install_or_uninstall install, app_id, app
rescue => e
6 changes: 3 additions & 3 deletions spec/features/admin_creation_spec.rb
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
end

scenario "first login for admin should see the setup page and setup first admin" do
(s = Setting.find_by_name('initialized')) && s.destroy
(s = Setting.where(:name=>'initialized').first) && s.destroy
username = "newuser"
User.stub(:system_find_name_by_username) { ["New User", 1000, username] }
visit start_path
@@ -17,8 +17,8 @@
fill_in "password", :with => "secret"
fill_in "password_confirmation", :with => "secret"
click_button "Create"
user = User.find_by_login username
user.admin.should be_true
user = User.where(:login => username).first
user.admin.should be_truthy
end

end
2 changes: 1 addition & 1 deletion spec/features/front_page_spec.rb
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
end

scenario "should be the dashboard if \"guest dashboard\" is enabled" do
setting = Setting.find_by_name("guest-dashboard")
setting = Setting.where(:name=>"guest-dashboard").first
setting.value = "1"
setting.save
visit root_path
1 change: 0 additions & 1 deletion spec/features/network_spec.rb
Original file line number Diff line number Diff line change
@@ -31,6 +31,5 @@
wait_for_ajax
page.should have_content("testdns")
page.should have_content("192.168.1.10")
page.save_screenshot("checking.png")
end
end
5 changes: 3 additions & 2 deletions spec/features/user_create_spec.rb
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@
fill_in "user_password", :with => "secret"
click_button "user_create_button"
wait_for_ajax
page.should have_content 'is too short (minimum is 4 characters)'
page.should have_content "doesn't match Password"
end
scenario 'when password doesnt match' do
visit users_engine.users_path
@@ -76,7 +76,8 @@
fill_in "user_password_confirmation", :with => "notsecret"
click_button "user_create_button"
wait_for_ajax
page.should have_content "doesn't match confirmation"
page.save_screenshot('image1.jpg')
page.should have_content "doesn't match Password"
end
end
end

0 comments on commit 2a0fe0c

Please sign in to comment.