Browse Source

new organisation

new_arc
LJ 11 years ago
parent
commit
027e1e8d99
  1. 0
      LICENSE
  2. 0
      README
  3. 32
      Rakefile
  4. 3
      config.ru
  5. 5
      rubyzome/classes/Error.rb
  6. 17
      rubyzome/classes/HTMLView.rb
  7. 17
      rubyzome/classes/JSONView.rb
  8. 5
      rubyzome/classes/RestController.rb
  9. 4
      rubyzome/classes/RestView.rb
  10. 9
      rubyzome/classes/RestfulDispatcher.rb
  11. 6
      rubyzome/classes/ServiceRestController.rb
  12. 11
      rubyzome/classes/XMLView.rb
  13. 0
      rubyzome/conf/config.rb
  14. 10
      rubyzome/controllers.rb
  15. 134
      rubyzome/controllers/helpers/UserAccountHelper.rb
  16. 83
      rubyzome/controllers/helpers/glue.rb
  17. 0
      rubyzome/db/db_migrate
  18. 0
      rubyzome/db/db_upgrade
  19. 0
      rubyzome/db/delete
  20. 0
      rubyzome/db/setup
  21. 6
      rubyzome/lib.rb
  22. 7
      rubyzome/lib/Error.rb
  23. 21
      rubyzome/load_local_app.rb
  24. 6
      rubyzome/models.rb
  25. 17
      rubyzome/models/Account.rb
  26. 17
      rubyzome/models/User.rb
  27. 27
      rubyzome/rubyzome.rb
  28. 102
      rubyzome/scripts/db/populate
  29. 105
      rubyzome/scripts/git/rz
  30. BIN
      rubyzome/scripts/logo/rubyzome.ico
  31. BIN
      rubyzome/scripts/logo/rubyzome.png
  32. 219
      rubyzome/scripts/logo/rubyzome.svg
  33. 16
      rubyzome/views.rb
  34. 19
      rubyzome/views/JSONView.rb
  35. 41
      rubyzome/views/html/templates/error.erb
  36. 30
      rubyzome/views/html/templates/main.erb
  37. 0
      rubyzome/www/js/rubyzome.js

0
rubyzome/README.markdown → LICENSE

0
README.markdown → README

32
Rakefile

@ -1,32 +0,0 @@
namespace "db" do
task :std_db_action, [:action] do |t,args|
require 'rubygems'
require 'global_config'
require 'dm-core'
require 'dm-migrations'
# Connect to DB
DataMapper.setup(:default, $db_url)
# Include all models
Dir["app/models/*.rb"].each { |file| require file }
# Reset tables
DataMapper.finalize
if args.action == 'migrate'
DataMapper.auto_migrate!
puts 'migration finished'
elsif args.action == 'upgrade'
DataMapper.auto_upgrade!
puts 'upgrade finished'
else
puts 'std_db_action [migrate|upgrade]'
end
end
task :migrate do
Rake.application.invoke_task("db:std_db_action[migrate]")
end
task :upgrade do
Rake.application.invoke_task("db:std_db_action[upgrade]")
end
end

3
config.ru

@ -5,8 +5,7 @@ require 'rubygems'
require 'rack'
require 'rack-rewrite'
require 'global_config.rb'
require 'rubyzome/conf/config.rb'
require 'rubyzome/rubyzome.rb'
use Rack::Rewrite do

5
rubyzome/classes/Error.rb

@ -0,0 +1,5 @@
# encoding: utf-8
class Error < StandardError
attr_accessor :code
end

17
rubyzome/views/HTMLView.rb → rubyzome/classes/HTMLView.rb

@ -1,11 +1,9 @@
# encoding: utf-8
module Rubyzome
# La classe pour renvoyer les valeurs en HTML
require 'erubis'
require 'rubyzome/views/RestView.rb'
class HTMLView < RestView
# La classe pour renvoyer les valeurs en HTML
require 'erubis'
require 'rubyzome/classes/RestView.rb'
class HTMLView < RestView
attr_accessor :request
# make @template a class variable and not
@ -145,10 +143,9 @@ module Rubyzome
@object=object
render_error
end
end
end
# TODO: think to create a Rubyzome contant Rubyzome::Views::TemplateDir
HTMLView.template=File.read('rubyzome/views/html/templates/main.erb')
HTMLView.error_template=File.read('rubyzome/views/html/templates/error.erb')
# HTMLView.template=File.read('rubyzome/views/html/templates/main.erb')
# HTMLView.error_template=File.read('rubyzome/views/html/templates/error.erb')
# TODO: create three standard sub-template: header, content and footer. Most of time, only content should vary.
end

17
rubyzome/classes/JSONView.rb

@ -0,0 +1,17 @@
# encoding: utf-8
require 'json'
require 'rubyzome/classes/RestView.rb'
class JSONView < RestView
def initialize
@head = {'Content-Type' => 'application/json', 'charset' => 'UTF-8' }
end
def content(object)
JSON object
end
def error(object)
content(object)
end
end

5
rubyzome/controllers/RestController.rb → rubyzome/classes/RestController.rb

@ -1,8 +1,6 @@
# encoding: utf-8
module Rubyzome
class RestController
class RestController
# ajoute un attribut Request
# contenant les détails des requêtes
attr_accessor :request
@ -45,5 +43,4 @@ module Rubyzome
end
end
end
end
end

4
rubyzome/views/RestView.rb → rubyzome/classes/RestView.rb

@ -1,7 +1,6 @@
# encoding: utf-8
module Rubyzome
class RestView
class RestView
attr_accessor :head
attr_accessor :code_return
def init_code_return_from_object(object)
@ -23,5 +22,4 @@ module Rubyzome
return self.content(object)
end
end
end
end

9
rubyzome/RestfulDispatcher.rb → rubyzome/classes/RestfulDispatcher.rb

@ -3,11 +3,8 @@
# The code in this file is part of the Rubyzome framework
# Rubyzome framework belongs to Luc Juggery and Yann Esposito
module Rubyzome
# The RestfulDispatcher class handle the automatic routing of the
# application using filename and classname.
class RestfulDispatcher
# Classe handling incoming requests
class RestfulDispatcher
@view = nil
# Select the view to be used to render the object
@ -252,6 +249,4 @@ module Rubyzome
end
return modelname, classname, function_name
end
end
end

6
rubyzome/controllers/ServiceRestController.rb → rubyzome/classes/ServiceRestController.rb

@ -1,8 +1,7 @@
# encoding: utf-8
module Rubyzome
require 'rubyzome/controllers/RestController.rb'
class ServiceRestController < RestController
require 'rubyzome/classes/RestController.rb'
class ServiceRestController < RestController
def service_name
@request[ (self.class.to_s.gsub(/Controller/,'').downcase + '_id' ).intern ].intern
@ -40,5 +39,4 @@ module Rubyzome
return {}
end
end
end

11
rubyzome/views/XMLView.rb → rubyzome/classes/XMLView.rb

@ -1,12 +1,11 @@
# encoding: utf-8
module Rubyzome
require 'nokogiri'
require 'rubyzome/classes/RestView.rb'
require 'nokogiri'
require 'rubyzome/views/RestView.rb'
# Class used to send back XML
class XMLView < RestView
# Class used to send back XML
class XMLView < RestView
def initialize
@head = {'Content-Type' => 'text/xml', 'charset' => 'UTF-8' }
end
@ -67,5 +66,5 @@ module Rubyzome
end
xml_item
end
end
end

0
global_config.rb → rubyzome/conf/config.rb

10
rubyzome/controllers.rb

@ -1,10 +0,0 @@
# encoding: utf-8
module Rubyzome
# include Rubyzome default controllers
Dir["rubyzome/controllers/*.rb"].each { |file| require file }
# include Rubyzome helpers
Dir["rubyzome/controllers/helpers/*.rb"].each { |file| require file }
end

134
rubyzome/controllers/helpers/UserAccountHelper.rb

@ -1,134 +0,0 @@
module Rubyzome
module AccountUserHelper
### AUTHENTICATION ###
def check_admin_authentication
if @request[:l] != 'adm' then
raise Error, "Only admin is authorized to perform this action"
end
if @request[:p] != 'adm' then
raise Error, "Authentication failed, please check your login and password"
end
end
def check_authentication
user=User.first({:nickname => @request[:l]})
if user.nil?
raise Error, "Authentication failed, user with login #{@request[:l]} does not exist"
end
if(@request[:p] != Account.first({:user => user}).password) then
raise Error, "Authentication failed, please check username and password"
end
end
### ACCOUNT STUFF ###
def get_account(id=:account_id)
account_id = @request[id]
if(account_id.nil?) then
raise Error, "No user provided"
end
user = User.first({:nickname => account_id})
if(user.nil?) then
raise Error, "User #{account_id} does not exist"
end
account = user.account
if(account.nil?) then
raise Error, "No account linked to user #{user_id}"
end
return account
end
### USER STUFF ###
def get_user(id=:user_id)
user_id = @request[id]
if(user_id.nil?) then
raise Error, "No user provided"
end
user = User.first({:nickname => user_id})
if(user.nil?) then
raise Error, "User #{user_id} does not exist"
end
return user
end
### SENSOR STUFF ###
def get_sensor(id=:sensor_id)
sensor_id = @request[id]
if(sensor_id.nil?) then
raise Error, "No sensor provided"
end
sensor = Sensor.first({:sensor_hr => sensor_id})
if(sensor.nil?) then
raise Error,"Sensor #{sensor_id} does not exist"
end
return sensor
end
### MEASURE STUFF ###
def get_measure(id=:measure_id)
measure_id = @request[id]
if(measure_id.nil?) then
raise Error, "No measure provided"
end
measure = Measure.first({:measure_hr => measure_id})
if(measure.nil?) then
raise Error,"Measure #{measure_id} does not exist"
end
return measure
end
### OWNERSHIP ###
def check_ownership_user_account(user,account)
if account.user != user
raise Error, "Account is not linked to user #{user.nickname}"
end
end
def check_ownership_user_sensor(user,sensor)
if sensor.user != user then
raise Error, "Sensor #{sensor.sensor_hr} does not belong to User #{user.nickname}"
end
end
def check_ownership_sensor_measure(sensor,measure)
if measure.sensor != sensor then
raise Error, "Measure #{measure.measure_hr} does not belong to Sensor #{sensor.sensor_hr}"
end
end
### ONLY USED IN USER PART ###
def check_ownership_requestor_user(requestor,user)
if requestor.nickname != user.nickname
raise Error, "Requestor #{requestor.nickname} and user requested #{user.nickname} do not match"
end
end
### UTIL ###
def clean_id(hash)
hash.delete(:id)
hash.delete(:user_id)
hash.delete(:account_id)
hash.delete(:sensor_id)
hash
end
### STAT PURPOSES ###
def get_start_date
days_nbr = 1
days_nbr = @request[:days_nbr] if not @request[:days_nbr].nil?
start_date = DateTime.now - days_nbr.to_i
return start_date
end
end
end

83
rubyzome/controllers/helpers/glue.rb

@ -1,83 +0,0 @@
module ResourcesFromRequest
# get ressource object from name
#
# in general request are in the form:
# MainRessources with params [
# login_param,
# general_param,
# subresource_1_id,
# subresource_2_id,
# ... ,
# subresource_n_id ]
# Most of time the controller need to access the object
# associated to subresource_x_id
# to get it, we need the model associated to the subresource_x_id
# most of time it is the name of the subresource_x_id which provide
# the associated model name.
# For example todolist_id is most of time
# used to match a Todolist object.
# Sometime there could be strange name to access
# get_resource("todolist")
# will return
# resource = Todolist.first({:id => request[:todolist_id]})
#
# For example as Todolist as :uid as primary key, we should have
# reclaimed:
# get_resource({ resource_name=>"todolist",db_key => :uid })
#
# and if we provided the user to send todoidentifier
# instead of todolist_id in the HTTP request we should
# have done
# get_resource({ resource_name =>"todolist",:uid,:todoidentifier)
#
# and if todolist wasn't for Todolist model but for Egg
# we should have written
# get_resource({:db_key => :uid,
# :req_id => :todoidentifier,
# :model_name => "Egg"})
#
# PARAMETERS
# or a simple string (resource_name)
# or a hash containing following key (not all mandatory)
# :resource_name mandatory if :req_id
# and :model_name not given)
# :req_id the name of the HTTP parameter
# used to identify resource
# :model_name the model class name
# :db_key the primary key of the model
def get_resource(params)
# A bit of introspection
if params.is_a?(String)
resource_name=params
elsif params.is_a?(Hash)
resource_name=params[:resource_name]
db_key=params[:db_key]
req_id=params[:req_id]
model_name=params[:model_name]
else
raise Error, "get_resource should take a String or Hash parameter"
end
# set default database id associated with ressource if needed
req_id=%{#{resource_name}_id}.intern if req_id == nil
# set the model name from the ressource name if needed
model_name=resource_name.capitalize if model_name == nil
# set the db primary key if needed
db_key=:id if db_key == nil
# get the given (by parameter) identifier of the ressource
ressource_id = @request[req_id]
# if no parameter is given demand from it
if(ressource_id.nil?) then
raise Error, "I lack the parameter #{req_id}"
end
# get the object from DB using ressource id to identify it
ressource = Kernel.const_get(model_name).first({db_key => ressource_id})
# raise an error if no ressource is found
if(ressource.nil?) then
raise Error, "#{ressource_id} does not exist"
end
return ressource
end
end

0
rubyzome/scripts/db/db_migrate → rubyzome/db/db_migrate

0
rubyzome/scripts/db/db_upgrade → rubyzome/db/db_upgrade

0
rubyzome/scripts/db/delete → rubyzome/db/delete

0
rubyzome/scripts/db/setup → rubyzome/db/setup

6
rubyzome/lib.rb

@ -1,6 +0,0 @@
# encoding: utf-8
module Rubyzome
# include Rubyzome helpers
Dir["rubyzome/lib/*.rb"].each { |file| require file }
end

7
rubyzome/lib/Error.rb

@ -1,7 +0,0 @@
# encoding: utf-8
module Rubyzome
class Error < StandardError
attr_accessor :code
end
end

21
rubyzome/load_local_app.rb

@ -1,21 +0,0 @@
# encoding: utf-8
module Rubyzome
# TODO: centralize configuration for example: default is app/ directory (should be different)
# Include all controllers
Dir["app/controllers/*.rb"].each { |file| require file }
# Include all specific views (if any)
Dir["app/views/*/*.rb"].each do |file|
require file
viewname=File.basename(file,File.extname(file))
typename=File.basename(File.dirname(file))
$views['/'+typename+'/'+viewname]=Kernel.const_get(viewname)
end
DataMapper.setup(:default,$db_url)
# Include all models
Dir["app/models/*.rb"].each { |file| require file }
DataMapper.finalize
end

6
rubyzome/models.rb

@ -1,6 +0,0 @@
# encoding: utf-8
module Rubyzome
# TODO: sanitize models to be super-class
Dir["rubyzome/models/*.rb"].each { |file| require file }
end

17
rubyzome/models/Account.rb

@ -1,17 +0,0 @@
# encoding: utf-8
module Rubyzome
module AccountUserHelper
class Account
# Includes
include DataMapper::Resource
# Properties
property :id, Serial
property :password, String
# Associations
belongs_to :user
end
end
end

17
rubyzome/models/User.rb

@ -1,17 +0,0 @@
# encoding: utf-8
module Rubyzome
module AccountUserHelper
class User
# Includes
include DataMapper::Resource
# Properties
property :id, Serial
property :nickname, String
# Associations
has 1, :account, :model => "Account"
end
end
end

27
rubyzome/rubyzome.rb

@ -1,19 +1,24 @@
# encoding: utf-8
# Rubyzome central file which load all submodules
# and subclasses
# Rubyzome central file which load all submodules and subclasses
module Rubyzome
require 'dm-core'
# Include all rubyzome classes
require 'rubyzome/lib.rb'
require 'rubyzome/controllers.rb'
require 'rubyzome/views.rb'
require 'rubyzome/models.rb'
Dir["rubyzome/classes/*.rb"].each { |file| puts file; require file }
def self.const_missing(c)
Object.const_get(c)
end
# load the classes for the defined application
require 'rubyzome/load_local_app.rb'
# load the class that will handle server requests
require 'rubyzome/RestfulDispatcher.rb'
# Include all application specific classes
Dir["app/models/*.rb"].each { |file| require file }
Dir["app/views/*/*.rb"].each do |file|
require file
viewname=File.basename(file,File.extname(file))
typename=File.basename(File.dirname(file))
$views['/'+typename+'/'+viewname]=Kernel.const_get(viewname)
end
Dir["app/controllers/*.rb"].each { |file| require file }
DataMapper.setup(:default,$db_url)
DataMapper.finalize
end

102
rubyzome/scripts/db/populate

@ -1,102 +0,0 @@
#!/usr/bin/env ruby
require 'rubygems'
require 'dm-core'
# require 'date'
require 'time'
require 'faker'
include "global_config.rb"
# inclusion de tous les modèles
DataMapper.setup(:default, $db_url)
Dir["app/models/*.rb"].each { |file| require file }
DataMapper.finalize
# connexion à la base de donnée
require "rubyzome/lib/db.rb"
# Comment that could be added by admin, based on user average consumption
comments = {
0..500 => "Very low consumption",
501..1000 => "Low consumption",
1001..1500 => "Normal consumption",
1501..2000 => "Medium consumption",
2001..2500 => "Consumption quite high",
2501..3000 => "High consumption, please reduce it :-)"
}
# User creation
nb_users=30
(1..nb_users).each do |user_nb|
# Get dummy
# - firstname
# - lastname
# - email
# - nickname
# - country
# - zip code
# - city
# - street
firstname = Faker::Name.first_name
lastname = Faker::Name.last_name
nickname = "#{firstname.downcase}#{lastname.downcase}"
# puts "User #{user_nb}:#{nickname}"
user_hash = { :nickname => "#{nickname}",
:status => "" }
account_hash = {:firstname => "#{firstname}",
:lastname => "#{lastname}",
:email => "#{firstname.downcase}.#{lastname.downcase}@yahoo.com",
:password => "guest",
:country => "US",
:zip => Faker::Address.zip_code,
:city => Faker::Address.city,
:street => Faker::Address.street_address}
# Create user entry
user = User.new(user_hash)
user.save
# Create account entry
account_hash[:user] = user
account=Account.new(account_hash)
account.save
# Create sensors for each users
nb_sensors=3
(1..nb_sensors).each do |sensor_nb|
# puts "Sensor:#{sensor_nb}"
sensor=Sensor.new( :sensor_hr => "#{nickname}_#{sensor_nb}",
:description => "Sensor #{sensor_nb} of #{firstname} #{lastname}",
:address => "Same as user",
:user => user)
sensor.save
# Create measure for each sensor: one measure each 30 minutes for the past 2 days
nb_measures=96
total = 0
(1..nb_measures).each do |measure_nb|
# puts "Measure:#{measure_nb}"
d = Time.now - measure_nb * 5 * 60
measure = Measure.new( :measure_hr => "#{nickname}_#{sensor_nb}_#{measure_nb}",
:date => d,
:consumption => rand(3000),
:sensor => sensor)
measure.save
total = total + measure.consumption.to_f
end
# Get measure average
average = total / nb_measures
# Set comment to user depending upon his average consumption
comment = ""
comments.each do |k,v|
if k.include?(average) then
comment = v
end
end
user.status = comment
user.save
end
end

105
rubyzome/scripts/git/rz

@ -1,105 +0,0 @@
#!/usr/bin/env ruby
# encoding: utf-8
# architecture
#
# master <-> rubyzome
# master -> grid
# grid -> gp | gpadm
#
# merge using two of these branches should be
# restricted to these rules
# merge to one of these branch and an unknown one should
# raise a warning, and may the option to add this new branch
# to the hierarchy
$architecture={
:master => [ :rubyzome, :grid, :todogether ],
:rubyzome => [ :master ],
:grid => [ :gp, :gpadm ] }
def get_current_branch()
(`git branch --no-color | awk '$1 == "*" {print $2}'`).chop.intern
end
if ARGV.length == 0
puts %{Script for rubyzome developper to dodge git merge error"
usage: $0:t [git_command or local_command]
local commands:
allmerges: merge from top to down}
exit 0
end
require 'set'
$known_branches=Set.new
$architecture.each do |k,v|
$known_branches.add(k)
v.each { |b| $known_branches.add(b) }
end
def rec_merge(branch)
if $architecture[branch].nil?
return
end
$architecture[branch].each do |b|
if $flag.has_key?(b.to_s + branch.to_s)
next
end
flagname=branch.to_s + b.to_s
if $flag.has_key?(flagname)
next
end
if system %{rz checkout #{b}}
if get_current_branch != b
puts "Can't checkout to #{b}"
exit 2
end
if system %{rz merge #{branch}}
$flag[flagname]=true
rec_merge(b)
else
exit 1
end
else
exit 1
end
end
end
def do_all_merges
puts 'Will merge from father to sons'
current_branch=get_current_branch
$flag={}
rec_merge(:master)
system %{git co #{current_branch}}
end
def do_merge
current_branch=get_current_branch
src_branch=ARGV[1].intern
puts %{do_merge: #{src_branch} => #{current_branch}}
if $known_branches.include?(current_branch)
if $known_branches.include?(src_branch)
if $architecture.has_key?(src_branch) and
$architecture[src_branch].include?(current_branch)
system %{git merge #{src_branch}}
else
puts %{Forbidden merge: #{src_branch} => #{current_branch}}
end
else
puts %{Warning! #{src_branch} not mentionned in rb configuration}
sleep 2
f system %{git merge #{src_branch}}
puts %{Warning! #{src_branch} not mentionned in rb configuration}
end
end
end
case ARGV[0]
when 'allmerges' then do_all_merges
when 'merge' then do_merge
else system %{git #{ARGV.join(' ')}}
end

BIN
rubyzome/scripts/logo/rubyzome.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

BIN
rubyzome/scripts/logo/rubyzome.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

219
rubyzome/scripts/logo/rubyzome.svg

@ -1,219 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="512"
height="512"
id="svg2"
version="1.1"
inkscape:version="0.47pre4 r22446"
sodipodi:docname="rubyzome.svg"
inkscape:export-filename="/home/e640846/Sites/gp/rubyzome/scripts/logo/rubyzome.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<defs
id="defs4">
<linearGradient
id="linearGradient3653">
<stop
style="stop-color:#ff0606;stop-opacity:1;"
offset="0"
id="stop3655" />
<stop
style="stop-color:#aa0000;stop-opacity:1;"
offset="1"
id="stop3657" />
</linearGradient>
<linearGradient
id="linearGradient3595">
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="0"
id="stop3597" />
<stop
style="stop-color:#7e7e7e;stop-opacity:0;"
offset="1"
id="stop3599" />
</linearGradient>
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective10" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3595"
id="linearGradient3601"
x1="371.42856"
y1="135.21933"
x2="371.42856"
y2="218.07648"
gradientUnits="userSpaceOnUse" />
<inkscape:perspective
id="perspective3611"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3595-4"
id="linearGradient3601-0"
x1="371.42856"
y1="135.21933"
x2="371.42856"
y2="218.07648"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient3595-4">
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="0"
id="stop3597-8" />
<stop
style="stop-color:#7e7e7e;stop-opacity:0;"
offset="1"
id="stop3599-5" />
</linearGradient>
<linearGradient
y2="218.07648"
x2="371.42856"
y1="135.21933"
x1="371.42856"
gradientUnits="userSpaceOnUse"
id="linearGradient3620"
xlink:href="#linearGradient3595-4"
inkscape:collect="always" />
<filter
inkscape:collect="always"
id="filter3649"
color-interpolation-filters="sRGB">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="9.2347821"
id="feGaussianBlur3651" />
</filter>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3653"
id="radialGradient3659"
cx="358.57812"
cy="348.07812"
fx="358.57812"
fy="348.07812"
r="182.42188"
gradientTransform="matrix(1,0,0,1.4071949,0,-141.73562)"
gradientUnits="userSpaceOnUse" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3653"
id="radialGradient3706"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,1.4071949,0,-141.73562)"
cx="358.57812"
cy="348.07812"
fx="358.57812"
fy="348.07812"
r="182.42188" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3595"
id="linearGradient3708"
gradientUnits="userSpaceOnUse"
x1="371.42856"
y1="135.21933"
x2="371.42856"
y2="218.07648" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3595-4"
id="linearGradient3710"
gradientUnits="userSpaceOnUse"
x1="371.42856"
y1="135.21933"
x2="371.42856"
y2="218.07648" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.35"
inkscape:cx="326.15388"
inkscape:cy="215.981"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1103"
inkscape:window-height="801"
inkscape:window-x="0"
inkscape:window-y="25"
inkscape:window-maximized="0" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-176.15625,-92.78125)">
<g
id="g3693"
transform="matrix(0.82025383,0,0,0.8270887,134.17352,57.33313)">
<path
id="path3641"
d="m 354.59375,90.4375 c -56.28759,0.808508 -109.82728,35.53482 -133.92294,86.07841 -19.59565,39.53173 -20.68486,87.86494 -2.88956,128.26534 -39.70778,46.57211 -52.94873,113.79694 -34.375,172.125 18.74021,61.96571 72.561,111.39137 135.96875,124.6875 57.14174,12.82193 119.74069,-3.89116 162.53125,-43.46875 42.7452,-38.24349 65.41546,-97.39027 59.15625,-154.59375 -3.66378,-36.14298 -18.35863,-70.94078 -41.71875,-98.71875 22.75256,-51.00504 14.24032,-114.18082 -21.25,-157.21875 -29.39984,-36.89663 -76.15886,-58.718847 -123.5,-57.15625 z"
style="fill:#2b0000;fill-opacity:1;stroke:#000000;stroke-width:2;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;filter:url(#filter3649)" />
<g
id="g3682">
<path
style="opacity:0.96000001;fill:url(#radialGradient3706);fill-opacity:1;stroke:#000000;stroke-width:2;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 358.5625,92.375 c -83.63169,0 -151.40625,67.77456 -151.40625,151.40625 0,21.83859 4.61687,42.58987 12.9375,61.34375 -26.79967,31.62056 -42.9375,72.55362 -42.9375,117.25 0,100.20023 81.20602,181.40625 181.40625,181.40625 C 458.76273,603.78125 540,522.57523 540,422.375 540,377.68719 523.8217,336.77432 497.03125,305.15625 505.36148,286.39337 510,265.63318 510,243.78125 510,160.14956 442.19419,92.375 358.5625,92.375 z"
id="path2816" />
<path
sodipodi:type="arc"
style="fill:url(#linearGradient3708);fill-opacity:1;stroke:none"
id="path2821"
sodipodi:cx="371.42856"
sodipodi:cy="176.6479"
sodipodi:rx="71.428574"
sodipodi:ry="41.42857"
d="m 442.85713,176.6479 c 0,22.88037 -31.97966,41.42857 -71.42857,41.42857 -39.44891,0 -71.42858,-18.5482 -71.42858,-41.42857 0,-22.88036 31.97967,-41.42857 71.42858,-41.42857 39.44891,0 71.42857,18.54821 71.42857,41.42857 z"
transform="matrix(1.44,0,0,1.4827586,-176.279,-105.2783)" />
<path
sodipodi:type="arc"
style="fill:url(#linearGradient3710);fill-opacity:1;stroke:none"
id="path2821-1"
sodipodi:cx="371.42856"
sodipodi:cy="176.6479"
sodipodi:rx="71.428574"
sodipodi:ry="41.42857"
d="m 442.85713,176.6479 c 0,22.88037 -31.97966,41.42857 -71.42857,41.42857 -39.44891,0 -71.42858,-18.5482 -71.42858,-41.42857 0,-22.88036 31.97967,-41.42857 71.42858,-41.42857 39.44891,0 71.42857,18.54821 71.42857,41.42857 z"
transform="matrix(1.72,0,0,2.1034483,-280.279,-28.06469)" />
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 8.0 KiB

16
rubyzome/views.rb

@ -1,16 +0,0 @@
# encoding: utf-8
module Rubyzome
# load all standard views
if not defined? $views
$views={}
end
Dir["rubyzome/views/*.rb"].each do |file|
require file
if file == "/rubyzome/views/RestView.rb"
next
end
viewname=File.basename(file,File.extname(file))
$views[viewname]=Rubyzome.const_get(viewname)
end
end

19
rubyzome/views/JSONView.rb

@ -1,19 +0,0 @@
# encoding: utf-8
module Rubyzome
require 'json'
require 'rubyzome/views/RestView.rb'
class JSONView < RestView
def initialize
@head = {'Content-Type' => 'application/json', 'charset' => 'UTF-8' }
end
def content(object)
JSON object
end
def error(object)
content(object)
end
end
end

41
rubyzome/views/html/templates/error.erb

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="shortcut icon" type="image/x-icon" href="/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/css/main.css" />
<script type="text/javascript" src="/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/js/index.js"></script>
<% e=@object[:exception] %>
<title><%= @object[:error].to_s %> - <%= @object[:exception].message %></title>
</head>
<body>
<div id="entete">
<h1><%= @object[:error].to_s %></h1>
<h2><%= @object[:exception].message %></h2>
</div>
<div id="content">
<p><%= puts @object %></p>
<table>
<tr>
<th>file</th>
<th>line</th>
<th>detail</th>
</tr>
<% e.backtrace.each do |line| %>
<tr><td><%= line.split(':').join('</td><td>') %></td></tr>
<% end %>
</table>
</div>
<div id="bottom">
<div id="promotion">
Designed by <a href="http://yannesposito.com">Yann Esposito</a> &amp; <a href="http://lucarea.com">Luc Juggery</a>.
</div>
</div>
</body>
</html>

30
rubyzome/views/html/templates/main.erb

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="shortcut icon" type="image/x-icon" href="/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/css/main.css" />
<script type="text/javascript" src="/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/js/index.js"></script>
<title><%= @title %></title>
</head>
<body>
<div id="entete">
<h1><%= @title %></h1>
<h2><%= @subtitle %></h2>
</div>
<div id="content">
<%= @content %>
</div>
<div id="bottom">
<div id="promotion">
Designed by <a href="http://yannesposito.com">Yann Esposito</a> &amp; <a href="http://lucarea.com">Luc Juggery</a>.
</div>
</div>
</body>
</html>

0
rubyzome/api/rubyzome.js → rubyzome/www/js/rubyzome.js

Loading…
Cancel
Save