deltacloud-core 0.1.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/DISCLAIMER +8 -0
- data/{COPYING → LICENSE} +0 -0
- data/NOTICE +13 -0
- data/Rakefile +50 -51
- data/bin/deltacloudd +8 -1
- data/config.ru +0 -2
- data/config/drivers.yaml +48 -0
- data/deltacloud-core.gemspec +75 -0
- data/deltacloud.rb +3 -2
- data/lib/deltacloud/backend_capability.rb +15 -3
- data/lib/deltacloud/base_driver.rb +0 -2
- data/lib/deltacloud/base_driver/base_driver.rb +85 -89
- data/lib/deltacloud/base_driver/features.rb +61 -7
- data/lib/deltacloud/base_driver/mock_driver.rb +42 -43
- data/lib/deltacloud/core_ext.rb +18 -0
- data/lib/deltacloud/core_ext/integer.rb +31 -0
- data/lib/deltacloud/core_ext/string.rb +50 -0
- data/lib/deltacloud/drivers/azure/azure_driver.rb +71 -22
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +641 -584
- data/lib/deltacloud/drivers/ec2/ec2_mock_driver.rb +0 -2
- data/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb +167 -0
- data/lib/deltacloud/drivers/gogrid/gogrid_client.rb +39 -1
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +41 -25
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob1.yml +6 -3
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob2.yml +6 -3
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob3.yml +4 -2
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob4.yml +5 -2
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob5.yml +4 -2
- data/lib/deltacloud/drivers/mock/data/instances/inst0.yml +1 -0
- data/lib/deltacloud/drivers/mock/data/instances/inst1.yml +1 -0
- data/lib/deltacloud/drivers/mock/data/instances/inst2.yml +1 -0
- data/lib/deltacloud/drivers/mock/data/storage_volumes/vol1.yml +1 -0
- data/lib/deltacloud/drivers/mock/data/storage_volumes/vol2.yml +1 -0
- data/lib/deltacloud/drivers/mock/data/storage_volumes/vol3.yml +1 -0
- data/lib/deltacloud/drivers/mock/mock_driver.rb +138 -30
- data/lib/deltacloud/drivers/opennebula/cloud_client.rb +13 -15
- data/lib/deltacloud/drivers/opennebula/occi_client.rb +13 -15
- data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +13 -15
- data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +224 -113
- data/lib/deltacloud/drivers/rhevm/rhevm_client.rb +332 -0
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +221 -170
- data/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb +0 -1
- data/lib/deltacloud/drivers/sbc/sbc_client.rb +247 -0
- data/lib/deltacloud/drivers/sbc/sbc_driver.rb +297 -0
- data/lib/deltacloud/drivers/terremark/terremark_driver.rb +0 -2
- data/lib/deltacloud/hardware_profile.rb +1 -3
- data/lib/deltacloud/helpers.rb +0 -2
- data/lib/deltacloud/helpers/application_helper.rb +86 -12
- data/lib/deltacloud/helpers/blob_stream.rb +19 -2
- data/lib/deltacloud/helpers/conversion_helper.rb +0 -2
- data/lib/deltacloud/helpers/hardware_profiles_helper.rb +0 -2
- data/lib/deltacloud/method_serializer.rb +0 -2
- data/lib/deltacloud/models/base_model.rb +0 -2
- data/lib/deltacloud/models/blob.rb +1 -2
- data/lib/deltacloud/models/bucket.rb +0 -2
- data/lib/deltacloud/models/image.rb +0 -2
- data/lib/deltacloud/models/instance.rb +19 -2
- data/lib/deltacloud/models/instance_profile.rb +4 -2
- data/lib/deltacloud/models/key.rb +0 -2
- data/lib/deltacloud/models/load_balancer.rb +0 -2
- data/lib/deltacloud/models/realm.rb +0 -2
- data/lib/deltacloud/models/storage_snapshot.rb +0 -2
- data/lib/deltacloud/models/storage_volume.rb +4 -2
- data/lib/deltacloud/runner.rb +132 -0
- data/lib/deltacloud/state_machine.rb +0 -2
- data/lib/deltacloud/validation.rb +9 -7
- data/lib/drivers.rb +36 -48
- data/lib/sinatra/accept_media_types.rb +26 -0
- data/lib/sinatra/lazy_auth.rb +16 -0
- data/lib/sinatra/rabbit.rb +112 -54
- data/lib/sinatra/rack_driver_select.rb +50 -16
- data/lib/sinatra/rack_etag.rb +79 -0
- data/lib/sinatra/rack_matrix_params.rb +84 -0
- data/lib/sinatra/rack_runtime.rb +47 -0
- data/lib/sinatra/static_assets.rb +16 -0
- data/lib/sinatra/url_for.rb +31 -4
- data/public/favicon.ico +0 -0
- data/public/images/bread-bg.png +0 -0
- data/public/images/error.png +0 -0
- data/public/images/pending.png +0 -0
- data/public/images/running.png +0 -0
- data/public/images/stopped.png +0 -0
- data/public/javascripts/application.js +35 -0
- data/public/stylesheets/compiled/application.css +59 -5
- data/public/stylesheets/compiled/screen.css +1 -1
- data/server.rb +293 -29
- data/support/fedora/deltacloud-core +78 -0
- data/support/fedora/deltacloud-core.spec +143 -0
- data/support/fedora/deltacloudd +78 -18
- data/support/fedora/rubygem-deltacloud-core.spec +76 -40
- data/tests/common.rb +172 -0
- data/tests/drivers/mock/api_test.rb +133 -0
- data/tests/drivers/mock/hardware_profiles_test.rb +134 -0
- data/tests/drivers/mock/images_test.rb +126 -0
- data/tests/drivers/mock/instance_states_test.rb +71 -0
- data/tests/drivers/mock/instances_test.rb +236 -0
- data/tests/drivers/mock/realms_test.rb +93 -0
- data/tests/drivers/mock/setup.rb +3 -0
- data/tests/drivers/mock/url_for_test.rb +67 -0
- data/tests/drivers/rackspace/api_test.rb +41 -0
- data/tests/drivers/rackspace/hardware_profiles_test.rb +53 -0
- data/tests/drivers/rackspace/images_test.rb +40 -0
- data/tests/drivers/rackspace/instances_test.rb +161 -0
- data/tests/drivers/rackspace/realms_test.rb +36 -0
- data/tests/drivers/rackspace/setup.rb +14 -0
- data/tests/drivers/rhevm/api_test.rb +39 -0
- data/tests/drivers/rhevm/hardware_profiles_test.rb +53 -0
- data/tests/drivers/rhevm/images_test.rb +42 -0
- data/tests/drivers/rhevm/instances_test.rb +179 -0
- data/tests/drivers/rhevm/realms_test.rb +35 -0
- data/tests/drivers/rhevm/setup.rb +14 -0
- data/tests/rabbit_test.rb +52 -0
- data/views/api/show.html.haml +2 -5
- data/views/blobs/new.html.haml +17 -1
- data/views/blobs/show.html.haml +6 -0
- data/views/blobs/show.xml.haml +5 -1
- data/views/buckets/index.html.haml +1 -12
- data/views/buckets/index.xml.haml +3 -5
- data/views/docs/operation.html.haml +23 -11
- data/views/drivers/index.html.haml +15 -0
- data/views/drivers/index.xml.haml +7 -0
- data/views/drivers/show.html.haml +20 -0
- data/views/drivers/show.xml.haml +7 -0
- data/views/error.html.haml +31 -0
- data/views/errors/auth_exception.xml.haml +2 -1
- data/views/errors/backend_capability_failure.xml.haml +2 -1
- data/views/errors/backend_error.html.haml +3 -0
- data/views/errors/backend_error.xml.haml +2 -2
- data/views/errors/validation_failure.xml.haml +3 -2
- data/views/images/index.html.haml +1 -6
- data/views/images/index.xml.haml +2 -0
- data/views/images/new.html.haml +14 -0
- data/views/images/show.xml.haml +2 -0
- data/views/instances/index.html.haml +8 -6
- data/views/instances/index.xml.haml +4 -0
- data/views/instances/new.html.haml +40 -11
- data/views/instances/run.html.haml +9 -0
- data/views/instances/run.xml.haml +7 -0
- data/views/instances/run_command.html.haml +16 -0
- data/views/instances/show.html.haml +14 -0
- data/views/instances/show.xml.haml +12 -4
- data/views/layout.html.haml +7 -2
- data/views/load_balancers/index.html.haml +1 -1
- data/views/load_balancers/new.html.haml +2 -2
- data/views/load_balancers/show.html.haml +1 -1
- data/views/storage_snapshots/index.html.haml +3 -0
- data/views/storage_snapshots/new.html.haml +9 -0
- data/views/storage_volumes/attach.html.haml +20 -0
- data/views/storage_volumes/index.html.haml +16 -1
- data/views/storage_volumes/index.xml.haml +1 -10
- data/views/storage_volumes/new.html.haml +17 -0
- data/views/storage_volumes/show.html.haml +8 -0
- data/views/storage_volumes/show.xml.haml +25 -3
- metadata +197 -127
- data/lib/deltacloud/drivers/rackspace/rackspace_client.rb +0 -130
- data/parse.rb +0 -7
- data/test.rb +0 -3
- data/views/api/drivers.xml.haml +0 -6
@@ -1,21 +1,55 @@
|
|
1
|
-
|
1
|
+
#
|
2
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
3
|
+
# contributor license agreements. See the NOTICE file distributed with
|
4
|
+
# this work for additional information regarding copyright ownership. The
|
5
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
6
|
+
# "License"); you may not use this file except in compliance with the
|
7
|
+
# License. You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
13
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
14
|
+
# License for the specific language governing permissions and limitations
|
15
|
+
# under the License.
|
2
16
|
|
3
|
-
|
4
|
-
|
5
|
-
@opts = opts
|
6
|
-
end
|
17
|
+
module Rack
|
18
|
+
class DriverSelect
|
7
19
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
@app.call(env)
|
13
|
-
ensure
|
14
|
-
Thread.current[:driver] = original_driver
|
15
|
-
end
|
20
|
+
def initialize(app, opts={})
|
21
|
+
@app = app
|
22
|
+
@opts = opts
|
23
|
+
end
|
16
24
|
|
17
|
-
|
18
|
-
|
19
|
-
|
25
|
+
HEADER_TO_ENV_MAP = {
|
26
|
+
'HTTP_X_DELTACLOUD_DRIVER' => :driver,
|
27
|
+
'HTTP_X_DELTACLOUD_PROVIDER' => :provider
|
28
|
+
}
|
29
|
+
|
30
|
+
def call(env)
|
31
|
+
original_settings = { }
|
32
|
+
req = Rack::Request.new(env)
|
33
|
+
if req.params['api'] and req.params['api']['driver']
|
34
|
+
env['HTTP_X_DELTACLOUD_DRIVER'] = req.params['api']['driver']
|
35
|
+
end
|
36
|
+
if req.params['api'] and req.params['api']['provider']
|
37
|
+
env['HTTP_X_DELTACLOUD_PROVIDER'] = req.params['api']['provider']
|
38
|
+
end
|
39
|
+
HEADER_TO_ENV_MAP.each do |header, name|
|
40
|
+
original_settings[name] = Thread.current[name]
|
41
|
+
new_setting = extract_header(env, header)
|
42
|
+
Thread.current[name] = new_setting if new_setting
|
43
|
+
end
|
20
44
|
|
45
|
+
@app.call(env)
|
46
|
+
ensure
|
47
|
+
original_settings.each { |name, value| Thread.current[name] = value }
|
48
|
+
end
|
49
|
+
|
50
|
+
def extract_header(env, header)
|
51
|
+
env[header].downcase if env[header]
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
21
55
|
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# Copyright (c) 2008 The Committers
|
2
|
+
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to
|
5
|
+
# deal in the Software without restriction, including without limitation the
|
6
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
7
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
16
|
+
# THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
17
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
18
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
|
+
|
20
|
+
require 'digest/md5'
|
21
|
+
|
22
|
+
module Rack
|
23
|
+
# Automatically sets the ETag header on all String bodies.
|
24
|
+
#
|
25
|
+
# The ETag header is skipped if ETag or Last-Modified headers are sent or if
|
26
|
+
# a sendfile body (body.responds_to :to_path) is given (since such cases
|
27
|
+
# should be handled by apache/nginx).
|
28
|
+
#
|
29
|
+
# On initialization, you can pass two parameters: a Cache-Control directive
|
30
|
+
# used when Etag is absent and a directive when it is present. The first
|
31
|
+
# defaults to nil, while the second defaults to "max-age=0, privaute, must-revalidate"
|
32
|
+
class ETag
|
33
|
+
DEFAULT_CACHE_CONTROL = "max-age=0, private, must-revalidate".freeze
|
34
|
+
|
35
|
+
def initialize(app, no_cache_control = nil, cache_control = DEFAULT_CACHE_CONTROL)
|
36
|
+
@app = app
|
37
|
+
@cache_control = cache_control
|
38
|
+
@no_cache_control = no_cache_control
|
39
|
+
end
|
40
|
+
|
41
|
+
def call(env)
|
42
|
+
status, headers, body = @app.call(env)
|
43
|
+
|
44
|
+
if etag_status?(status) && etag_body?(body) && !http_caching?(headers)
|
45
|
+
digest, body = digest_body(body)
|
46
|
+
headers['ETag'] = %("#{digest}") if digest
|
47
|
+
end
|
48
|
+
|
49
|
+
if not headers['Cache-Control'] and digest
|
50
|
+
headers['Cache-Control'] = digest ? @cache_control : @no_cache_control
|
51
|
+
end
|
52
|
+
|
53
|
+
[status, headers, body]
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def etag_status?(status)
|
59
|
+
status == 200 || status == 201
|
60
|
+
end
|
61
|
+
|
62
|
+
def etag_body?(body)
|
63
|
+
!body.respond_to?(:to_path)
|
64
|
+
end
|
65
|
+
|
66
|
+
def http_caching?(headers)
|
67
|
+
headers.key?('ETag') || headers.key?('Last-Modified')
|
68
|
+
end
|
69
|
+
|
70
|
+
def digest_body(body)
|
71
|
+
parts = []
|
72
|
+
body.each { |part| parts << part }
|
73
|
+
string_body = parts.join
|
74
|
+
digest = Digest::MD5.hexdigest(string_body) unless string_body.empty?
|
75
|
+
[digest, parts]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright ownership. The
|
4
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the
|
6
|
+
# License. You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations
|
14
|
+
# under the License.
|
15
|
+
|
16
|
+
# Methods added to this helper will be available to all templates in the application.
|
17
|
+
|
18
|
+
module Rack
|
19
|
+
|
20
|
+
require 'cgi'
|
21
|
+
|
22
|
+
class MatrixParams
|
23
|
+
def initialize(app)
|
24
|
+
@app = app
|
25
|
+
end
|
26
|
+
|
27
|
+
# This will allow to use 'matrix' params in requests, like:
|
28
|
+
#
|
29
|
+
# http://example.com/library;section=nw/books;topic=money;binding=hardcover
|
30
|
+
#
|
31
|
+
# Will result in this params matrix:
|
32
|
+
#
|
33
|
+
# => params['library']['section'] = 'nw'
|
34
|
+
# => params['books']['topic'] = 'money'
|
35
|
+
# => params['books']['binding'] = 'hardcover'
|
36
|
+
#
|
37
|
+
# All HTTP methods are supported, in case of POST they will be passed as a
|
38
|
+
# regular <form> parameters.
|
39
|
+
|
40
|
+
def call(env)
|
41
|
+
# Copy PATH_INFO to REQUEST_URI if Rack::Test
|
42
|
+
env['REQUEST_URI'] = env['PATH_INFO'] if env['rack.test']
|
43
|
+
|
44
|
+
# Split URI to components and then extract ;var=value pairs
|
45
|
+
uri_components = env['REQUEST_URI'].split('/')
|
46
|
+
matrix_params = {}
|
47
|
+
uri_components.each do |component|
|
48
|
+
sub_components, value = component.split(/\;(\w+)\=/), nil
|
49
|
+
next unless sub_components.first # Skip subcomponent if it's empty (usually /)
|
50
|
+
while param=sub_components.pop do
|
51
|
+
if value
|
52
|
+
matrix_params[sub_components.first] ||= {}
|
53
|
+
matrix_params[sub_components.first].merge!(
|
54
|
+
param => value
|
55
|
+
)
|
56
|
+
value=nil
|
57
|
+
next
|
58
|
+
else
|
59
|
+
value = param
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# If request method is POST, simply include matrix params in form_hash
|
65
|
+
env['rack.request.form_hash'].merge!(matrix_params) if env['rack.request.form_hash']
|
66
|
+
|
67
|
+
# For other methods it's a way complicated ;-)
|
68
|
+
if env['REQUEST_METHOD']!='POST' and not matrix_params.keys.empty?
|
69
|
+
# Rewrite current path and query string and strip all matrix params from it
|
70
|
+
env['REQUEST_PATH'], env['PATH_INFO'] = env['REQUEST_URI'].gsub(/;([^\/]*)/, '').gsub(/\?(.*)$/, '')
|
71
|
+
env['PATH_INFO'] = env['REQUEST_PATH']
|
72
|
+
env['QUERY_STRING'].gsub!(/;([^\/]*)/, '')
|
73
|
+
new_params = matrix_params.collect do |component, params|
|
74
|
+
params.collect { |k,v| "#{component}[#{k}]=#{CGI::escape(v.to_s)}" }
|
75
|
+
end.flatten
|
76
|
+
# Add matrix params as a regular GET params
|
77
|
+
env['QUERY_STRING'] += '&' if not env['QUERY_STRING'].empty?
|
78
|
+
env['QUERY_STRING'] += "#{new_params.join('&')}"
|
79
|
+
end
|
80
|
+
@app.call(env)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Copyright (c) 2008 The Committers
|
2
|
+
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to
|
5
|
+
# deal in the Software without restriction, including without limitation the
|
6
|
+
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
7
|
+
# sell copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
16
|
+
# THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
17
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
18
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
|
+
|
20
|
+
module Rack
|
21
|
+
# Sets an "X-Runtime" response header, indicating the response
|
22
|
+
# time of the request, in seconds
|
23
|
+
#
|
24
|
+
# You can put it right before the application to see the processing
|
25
|
+
# time, or before all the other middlewares to include time for them,
|
26
|
+
# too.
|
27
|
+
class Runtime
|
28
|
+
def initialize(app, name = nil)
|
29
|
+
@app = app
|
30
|
+
@header_name = "X-Runtime"
|
31
|
+
@header_name << "-#{name}" if name
|
32
|
+
end
|
33
|
+
|
34
|
+
def call(env)
|
35
|
+
start_time = Time.now
|
36
|
+
status, headers, body = @app.call(env)
|
37
|
+
request_time = Time.now - start_time
|
38
|
+
|
39
|
+
if !headers.has_key?(@header_name)
|
40
|
+
headers[@header_name] = "%0.6f" % request_time
|
41
|
+
end
|
42
|
+
|
43
|
+
[status, headers, body]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
@@ -1,3 +1,19 @@
|
|
1
|
+
#
|
2
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
3
|
+
# contributor license agreements. See the NOTICE file distributed with
|
4
|
+
# this work for additional information regarding copyright ownership. The
|
5
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
6
|
+
# "License"); you may not use this file except in compliance with the
|
7
|
+
# License. You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
13
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
14
|
+
# License for the specific language governing permissions and limitations
|
15
|
+
# under the License.
|
16
|
+
|
1
17
|
require 'sinatra/base'
|
2
18
|
require 'sinatra/url_for'
|
3
19
|
|
data/lib/sinatra/url_for.rb
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
#
|
2
|
+
# Based on https://github.com/emk/sinatra-url-for/
|
3
|
+
# Commit 1df339284203f8f6ed8d
|
4
|
+
#
|
5
|
+
# Original license:
|
6
|
+
# Copyright (C) 2009 Eric Kidd
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining a
|
9
|
+
# copy of this software and associated documentation files (the
|
10
|
+
# "Software"), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
13
|
+
# persons to whom the Software is furnished to do so, subject to the
|
14
|
+
# following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be included
|
17
|
+
# in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
20
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
22
|
+
# NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
23
|
+
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
24
|
+
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
25
|
+
# USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
|
1
27
|
require 'uri'
|
2
28
|
|
3
29
|
module Sinatra
|
@@ -20,12 +46,13 @@ module Sinatra
|
|
20
46
|
when :path_only
|
21
47
|
base = request.script_name
|
22
48
|
when :full
|
23
|
-
scheme = request.scheme
|
24
|
-
|
25
|
-
|
49
|
+
scheme = request.env['HTTP_X_FORWARDED_SCHEME'] || request.scheme
|
50
|
+
port = request.env['HTTP_X_FORWARDED_PORT'] || request.port
|
51
|
+
if ((scheme == 'http' && port.to_s == '80') ||
|
52
|
+
(scheme == 'https' && port.to_s == '443'))
|
26
53
|
port = ""
|
27
54
|
else
|
28
|
-
port = ":#{
|
55
|
+
port = ":#{port}"
|
29
56
|
end
|
30
57
|
request_host = HOSTNAME ? HOSTNAME : request.host
|
31
58
|
base = "#{scheme}://#{request_host}#{port}#{request.script_name}"
|
data/public/favicon.ico
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -16,3 +16,38 @@ $(document).ready(function() {
|
|
16
16
|
}
|
17
17
|
|
18
18
|
})
|
19
|
+
|
20
|
+
function more_fields()
|
21
|
+
{
|
22
|
+
//increment the hidden input that captures how many meta_data are passed
|
23
|
+
var meta_params = document.getElementsByName('meta_params')
|
24
|
+
current_number_params = eval(meta_params[0].value)+1
|
25
|
+
meta_params[0].value = current_number_params
|
26
|
+
var new_meta = document.getElementById('metadata_holder').cloneNode(true);
|
27
|
+
new_meta.id = 'metadata_holder' + current_number_params;
|
28
|
+
new_meta.style.display = 'block';
|
29
|
+
var nodes = new_meta.childNodes;
|
30
|
+
for (var i=0;i < nodes.length;i++) {
|
31
|
+
var theName = nodes[i].name;
|
32
|
+
if (theName)
|
33
|
+
nodes[i].name = theName + current_number_params;
|
34
|
+
}
|
35
|
+
var insertHere = document.getElementById('metadata_holder');
|
36
|
+
insertHere.parentNode.insertBefore(new_meta,insertHere);
|
37
|
+
}
|
38
|
+
|
39
|
+
function less_fields()
|
40
|
+
{
|
41
|
+
var meta_params = document.getElementsByName('meta_params')
|
42
|
+
current_val = eval(meta_params[0].value)
|
43
|
+
if (current_val == 0)
|
44
|
+
{
|
45
|
+
return;
|
46
|
+
}
|
47
|
+
else
|
48
|
+
{
|
49
|
+
var theDiv = document.getElementById('metadata_holder'+current_val)
|
50
|
+
theDiv.parentNode.removeChild(theDiv)
|
51
|
+
meta_params[0].value = eval(current_val)-1
|
52
|
+
}
|
53
|
+
}
|
@@ -6,7 +6,6 @@ html, body {
|
|
6
6
|
font-weight: inherit;
|
7
7
|
font-style: inherit;
|
8
8
|
font-size: 100%;
|
9
|
-
font-family: inherit;
|
10
9
|
vertical-align: baseline; }
|
11
10
|
|
12
11
|
/* line 12, ../../../../../../../../.gem/ruby/1.8/gems/compass-0.8.17/frameworks/blueprint/stylesheets/blueprint/modules/_reset.sass */
|
@@ -461,7 +460,6 @@ html {
|
|
461
460
|
|
462
461
|
/* line 12, ../../../app/stylesheets/application.sass */
|
463
462
|
body {
|
464
|
-
font-family: "Trebuchet MS";
|
465
463
|
font-size: 90%; }
|
466
464
|
/* line 15, ../../../app/stylesheets/application.sass */
|
467
465
|
body a {
|
@@ -479,7 +477,9 @@ body {
|
|
479
477
|
|
480
478
|
/* line 21, ../../../app/stylesheets/application.sass */
|
481
479
|
#header {
|
480
|
+
border-radius: 5px 5px 0 0;
|
482
481
|
padding: 1em;
|
482
|
+
margin-top : 0.5em;
|
483
483
|
background-image: url('/images/topbar-bg.png'); }
|
484
484
|
/* line 24, ../../../app/stylesheets/application.sass */
|
485
485
|
#header img {
|
@@ -494,7 +494,7 @@ body {
|
|
494
494
|
border-top: 1px solid #BBB;
|
495
495
|
padding-top: 1ex;
|
496
496
|
text-align: right;
|
497
|
-
color: #
|
497
|
+
color: #777;
|
498
498
|
font-size: 70%; }
|
499
499
|
|
500
500
|
/* line 38, ../../../app/stylesheets/application.sass */
|
@@ -538,7 +538,8 @@ body {
|
|
538
538
|
|
539
539
|
/* line 70, ../../../app/stylesheets/application.sass */
|
540
540
|
ul.breadcrumb {
|
541
|
-
|
541
|
+
border-radius : 0 0 5px 5px;
|
542
|
+
background: #eeeeee url('/images/bread-bg.png') repeat-x top left;
|
542
543
|
border: 1px solid #6498c5;
|
543
544
|
padding: 1ex;
|
544
545
|
font-size: 90%;
|
@@ -551,7 +552,8 @@ ul.breadcrumb {
|
|
551
552
|
display: inline; }
|
552
553
|
/* line 81, ../../../app/stylesheets/application.sass */
|
553
554
|
ul.breadcrumb li.subsequent:before {
|
554
|
-
|
555
|
+
color : #aaa;
|
556
|
+
content: " \25b6 "; }
|
555
557
|
|
556
558
|
/* line 84, ../../../app/stylesheets/application.sass */
|
557
559
|
table {
|
@@ -613,3 +615,55 @@ table.docs td { border : 1px solid #ccc }
|
|
613
615
|
table.docs table td { border : none }
|
614
616
|
|
615
617
|
td form.link { display : inline }
|
618
|
+
li.docs {
|
619
|
+
float : right;
|
620
|
+
}
|
621
|
+
|
622
|
+
li.docs {
|
623
|
+
font-size : 80%;
|
624
|
+
}
|
625
|
+
|
626
|
+
.error h1 {
|
627
|
+
background : url('/images/error.png') no-repeat center left;
|
628
|
+
height : 35px;
|
629
|
+
padding-left : 55px;
|
630
|
+
padding-top : 10px;
|
631
|
+
}
|
632
|
+
|
633
|
+
.error p {
|
634
|
+
padding : 1em 0.5em;
|
635
|
+
margin : 1em 0;
|
636
|
+
font-size : 115%;
|
637
|
+
border : 1px solid #c00;
|
638
|
+
background : #fbd1d1;
|
639
|
+
}
|
640
|
+
|
641
|
+
.new_instance {
|
642
|
+
border : 1px solid #ccc;
|
643
|
+
border-radius : 5px;
|
644
|
+
background : #eee;
|
645
|
+
clear : both;
|
646
|
+
}
|
647
|
+
|
648
|
+
.new_instance p {
|
649
|
+
margin : 5px;
|
650
|
+
clear : both;
|
651
|
+
}
|
652
|
+
|
653
|
+
.new_instance p label {
|
654
|
+
float : left;
|
655
|
+
width : 190px;
|
656
|
+
}
|
657
|
+
|
658
|
+
.new_instance p input[type=text]{
|
659
|
+
border : 1px solid #ccc;
|
660
|
+
font-size : 115%;
|
661
|
+
border-radius : 5px;
|
662
|
+
width : 220px;
|
663
|
+
}
|
664
|
+
|
665
|
+
h3.description {
|
666
|
+
float : right;
|
667
|
+
font-size : 70%;
|
668
|
+
color : #ccc;
|
669
|
+
}
|