spontaneous 0.2.0.alpha7 → 0.2.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +10 -4
- data/Readme.markdown +1 -1
- data/application/css/definitions.css.scss +5 -0
- data/application/css/dialogue.css.scss +62 -0
- data/application/js/content.js +1 -1
- data/application/js/dom.js +1 -1
- data/application/js/event_source.js +3 -0
- data/application/js/{field_types/date_field.js → field/date.js} +2 -2
- data/application/js/{field_types/file_field.js → field/file.js} +2 -2
- data/application/js/{field_types/image_field.js → field/image.js} +54 -20
- data/application/js/{field_types/long_string_field.js → field/long_string.js} +2 -2
- data/application/js/{field_types/markdown_field.js → field/markdown.js} +2 -2
- data/application/js/{field_types/select_field.js → field/select.js} +2 -2
- data/application/js/{field_types/string_field.js → field/string.js} +21 -7
- data/application/js/{field_types/webvideo_field.js → field/webvideo.js} +2 -2
- data/application/js/field.js +2 -2
- data/application/js/publish.js +99 -19
- data/application/js/spontaneous.js +8 -8
- data/application/js/top_bar.js +6 -4
- data/db/migrations/20130109125023_add_page_publish_lock.rb +17 -0
- data/db/migrations/20130111161934_convert_bcrypt_passwords.rb +22 -0
- data/db/migrations/20130114120000_create_revision_tables.rb +106 -0
- data/db/migrations/20130116220423_add_index_to_archive.rb +9 -0
- data/lib/spontaneous/box.rb +53 -18
- data/lib/spontaneous/box_style.rb +2 -3
- data/lib/spontaneous/change.rb +39 -13
- data/lib/spontaneous/cli/fields.rb +29 -0
- data/lib/spontaneous/cli/init.rb +2 -2
- data/lib/spontaneous/cli/migrate.rb +0 -1
- data/lib/spontaneous/cli/server.rb +14 -10
- data/lib/spontaneous/cli/site.rb +20 -9
- data/lib/spontaneous/cli.rb +8 -6
- data/lib/spontaneous/collections/box_set.rb +11 -0
- data/lib/spontaneous/collections/field_set.rb +24 -1
- data/lib/spontaneous/concern.rb +37 -0
- data/lib/spontaneous/config.rb +3 -4
- data/lib/spontaneous/crypt/version.rb +130 -0
- data/lib/spontaneous/crypt.rb +84 -0
- data/lib/spontaneous/data_mapper/content_model/associations.rb +199 -0
- data/lib/spontaneous/data_mapper/content_model/column_accessors.rb +52 -0
- data/lib/spontaneous/data_mapper/content_model/instance_hooks.rb +34 -0
- data/lib/spontaneous/data_mapper/content_model/serialization.rb +54 -0
- data/lib/spontaneous/data_mapper/content_model/timestamps.rb +39 -0
- data/lib/spontaneous/data_mapper/content_model.rb +343 -0
- data/lib/spontaneous/data_mapper/content_table.rb +103 -0
- data/lib/spontaneous/data_mapper/dataset.rb +194 -0
- data/lib/spontaneous/data_mapper/scope.rb +195 -0
- data/lib/spontaneous/data_mapper.rb +161 -0
- data/lib/spontaneous/facet.rb +2 -2
- data/lib/spontaneous/field/base.rb +418 -0
- data/lib/spontaneous/field/date.rb +54 -0
- data/lib/spontaneous/{field_version.rb → field/field_version.rb} +1 -1
- data/lib/spontaneous/field/file.rb +100 -0
- data/lib/spontaneous/{field_types/image_field.rb → field/image.rb} +33 -33
- data/lib/spontaneous/{field_types/location_field.rb → field/location.rb} +2 -2
- data/lib/spontaneous/{field_types/long_string_field.rb → field/long_string.rb} +3 -3
- data/lib/spontaneous/field/markdown.rb +36 -0
- data/lib/spontaneous/{field_types/select_field.rb → field/select.rb} +4 -5
- data/lib/spontaneous/field/string.rb +17 -0
- data/lib/spontaneous/field/update.rb +156 -0
- data/lib/spontaneous/field/webvideo.rb +310 -0
- data/lib/spontaneous/field.rb +80 -0
- data/lib/spontaneous/generators/site/Gemfile.tt +2 -2
- data/lib/spontaneous/generators/site/config/environments/development.rb.tt +1 -1
- data/lib/spontaneous/generators/site/config/environments/production.rb.tt +1 -1
- data/lib/spontaneous/generators/site/lib/content.rb.tt +6 -0
- data/lib/spontaneous/generators/site/schema/box.rb.tt +3 -2
- data/lib/spontaneous/generators/site/schema/page.rb.tt +3 -1
- data/lib/spontaneous/generators/site/schema/piece.rb.tt +3 -1
- data/lib/spontaneous/generators/site/templates/layouts/standard.html.cut.tt +3 -1
- data/lib/spontaneous/generators/site.rb +4 -3
- data/lib/spontaneous/image_size.rb +8 -1
- data/lib/spontaneous/layout.rb +5 -1
- data/lib/spontaneous/loader.rb +2 -5
- data/lib/spontaneous/media/file.rb +11 -2
- data/lib/spontaneous/media/temp_file.rb +23 -0
- data/lib/spontaneous/media.rb +20 -39
- data/lib/spontaneous/{plugins → model/box}/allowed_types.rb +38 -17
- data/lib/spontaneous/model/box.rb +18 -0
- data/lib/spontaneous/{plugins → model/core}/aliases.rb +10 -14
- data/lib/spontaneous/{plugins → model/core}/boxes.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/content_groups.rb +2 -2
- data/lib/spontaneous/model/core/editor_class.rb +4 -0
- data/lib/spontaneous/{plugins → model/core}/entries.rb +19 -7
- data/lib/spontaneous/{plugins → model/core}/entry.rb +3 -3
- data/lib/spontaneous/{plugins → model/core}/fields.rb +38 -5
- data/lib/spontaneous/{plugins → model/core}/instance_code.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/media.rb +2 -12
- data/lib/spontaneous/{plugins → model/core}/modifications.rb +7 -6
- data/lib/spontaneous/model/core/page_search.rb +36 -0
- data/lib/spontaneous/{plugins → model/core}/permissions.rb +4 -4
- data/lib/spontaneous/{plugins → model/core}/prototypes.rb +4 -4
- data/lib/spontaneous/{plugins → model/core}/publishing.rb +93 -115
- data/lib/spontaneous/{plugins → model/core}/render.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/schema_hierarchy.rb +7 -11
- data/lib/spontaneous/model/core/schema_id.rb +65 -0
- data/lib/spontaneous/{plugins → model/core}/schema_title.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/serialisation.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/styles.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/supertype.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/visibility.rb +7 -48
- data/lib/spontaneous/model/core.rb +143 -0
- data/lib/spontaneous/{plugins → model/page}/controllers.rb +3 -3
- data/lib/spontaneous/{plugins → model}/page/formats.rb +2 -2
- data/lib/spontaneous/{plugins → model/page}/layouts.rb +2 -2
- data/lib/spontaneous/model/page/locks.rb +14 -0
- data/lib/spontaneous/{plugins → model/page}/page_tree.rb +3 -3
- data/lib/spontaneous/{plugins → model/page}/paths.rb +30 -12
- data/lib/spontaneous/{plugins → model}/page/request.rb +2 -2
- data/lib/spontaneous/{plugins → model/page}/site_map.rb +2 -2
- data/lib/spontaneous/model/page/site_timestamps.rb +44 -0
- data/lib/spontaneous/{page.rb → model/page.rb} +49 -28
- data/lib/spontaneous/{piece.rb → model/piece.rb} +7 -6
- data/lib/spontaneous/model.rb +97 -0
- data/lib/spontaneous/output/context.rb +1 -1
- data/lib/spontaneous/output/format.rb +4 -0
- data/lib/spontaneous/output/template/renderer.rb +2 -2
- data/lib/spontaneous/output.rb +2 -2
- data/lib/spontaneous/page_lock.rb +62 -0
- data/lib/spontaneous/page_piece.rb +1 -1
- data/lib/spontaneous/permissions/access_key.rb +9 -4
- data/lib/spontaneous/permissions/user.rb +19 -9
- data/lib/spontaneous/permissions.rb +2 -5
- data/lib/spontaneous/plugins/application/facets.rb +1 -2
- data/lib/spontaneous/plugins/application/features.rb +1 -1
- data/lib/spontaneous/plugins/application/paths.rb +1 -1
- data/lib/spontaneous/plugins/application/render.rb +1 -1
- data/lib/spontaneous/plugins/application/serialisation.rb +1 -1
- data/lib/spontaneous/plugins/application/state.rb +30 -1
- data/lib/spontaneous/plugins/application/system.rb +12 -12
- data/lib/spontaneous/prototypes/box_prototype.rb +1 -1
- data/lib/spontaneous/prototypes/field_prototype.rb +3 -6
- data/lib/spontaneous/prototypes/style_prototype.rb +1 -1
- data/lib/spontaneous/publishing/immediate.rb +77 -49
- data/lib/spontaneous/publishing/revision.rb +355 -0
- data/lib/spontaneous/publishing/simultaneous.rb +10 -49
- data/lib/spontaneous/publishing.rb +1 -0
- data/lib/spontaneous/rack/around_back.rb +1 -1
- data/lib/spontaneous/rack/around_front.rb +2 -4
- data/lib/spontaneous/rack/around_preview.rb +1 -1
- data/lib/spontaneous/rack/back.rb +80 -63
- data/lib/spontaneous/rack/cacheable_file.rb +2 -2
- data/lib/spontaneous/rack/cookie_authentication.rb +1 -1
- data/lib/spontaneous/rack/front.rb +1 -1
- data/lib/spontaneous/rack/helpers.rb +8 -9
- data/lib/spontaneous/{page_controller.rb → rack/page_controller.rb} +1 -1
- data/lib/spontaneous/rack/public.rb +3 -3
- data/lib/spontaneous/rack.rb +15 -15
- data/lib/spontaneous/schema/uid.rb +4 -1
- data/lib/spontaneous/schema.rb +57 -24
- data/lib/spontaneous/search/database.rb +12 -1
- data/lib/spontaneous/search/index.rb +34 -6
- data/lib/spontaneous/search/results.rb +1 -1
- data/lib/spontaneous/server.rb +3 -3
- data/lib/spontaneous/simultaneous.rb +53 -0
- data/lib/spontaneous/{plugins/site → site}/features.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/helpers.rb +2 -3
- data/lib/spontaneous/{plugins/site → site}/hooks.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/instance.rb +4 -6
- data/lib/spontaneous/{plugins/site → site}/level.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/map.rb +4 -4
- data/lib/spontaneous/{plugins/site → site}/paths.rb +2 -2
- data/lib/spontaneous/site/publishing.rb +89 -0
- data/lib/spontaneous/{plugins/site → site}/schema.rb +4 -4
- data/lib/spontaneous/{plugins/site → site}/search.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/selectors.rb +15 -7
- data/lib/spontaneous/{plugins/site → site}/state.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/storage.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/url.rb +2 -2
- data/lib/spontaneous/site.rb +31 -14
- data/lib/spontaneous/state.rb +5 -6
- data/lib/spontaneous/style.rb +3 -2
- data/lib/spontaneous/utils/database/mysql_dumper.rb +13 -0
- data/lib/spontaneous/utils/database/postgres_dumper.rb +5 -0
- data/lib/spontaneous/version.rb +1 -1
- data/lib/spontaneous.rb +34 -89
- data/spontaneous.gemspec +112 -114
- data/test/experimental/test_crypt.rb +158 -0
- data/test/experimental/test_features.rb +3 -3
- data/test/fixtures/example_application/config/environments/development.rb +1 -1
- data/test/fixtures/example_application/lib/content.rb +5 -0
- data/test/fixtures/example_application/schema/page.rb +2 -1
- data/test/fixtures/example_application/schema/piece.rb +3 -2
- data/test/fixtures/serialisation/class_hash.yaml.erb +5 -5
- data/test/fixtures/serialisation/root_hash.yaml.erb +8 -0
- data/test/functional/test_application.rb +12 -1
- data/test/functional/test_back.rb +80 -48
- data/test/functional/test_front.rb +39 -46
- data/test/functional/test_user_manager.rb +3 -9
- data/test/javascript/test_markdown.rb +2 -2
- data/test/test_helper.rb +78 -23
- data/test/unit/test_alias.rb +21 -15
- data/test/unit/test_asset_bundler.rb +3 -3
- data/test/unit/test_assets.rb +2 -2
- data/test/unit/test_async.rb +7 -6
- data/test/unit/test_authentication.rb +43 -37
- data/test/unit/test_boxes.rb +46 -21
- data/test/unit/test_changesets.rb +65 -20
- data/test/unit/test_config.rb +9 -9
- data/test/unit/test_content.rb +50 -51
- data/test/unit/test_content_inheritance.rb +6 -20
- data/test/unit/test_datamapper.rb +1330 -0
- data/test/unit/test_datamapper_content.rb +214 -0
- data/test/unit/test_fields.rb +543 -54
- data/test/unit/test_formats.rb +2 -3
- data/test/unit/test_generators.rb +6 -6
- data/test/unit/test_helpers.rb +1 -1
- data/test/unit/test_image_size.rb +10 -5
- data/test/unit/test_images.rb +17 -18
- data/test/unit/test_layouts.rb +18 -3
- data/test/unit/test_media.rb +74 -49
- data/test/unit/test_modifications.rb +43 -43
- data/test/unit/test_page.rb +7 -10
- data/test/unit/test_permissions.rb +3 -10
- data/test/unit/test_piece.rb +5 -6
- data/test/unit/test_plugins.rb +7 -14
- data/test/unit/test_prototypes.rb +3 -3
- data/test/unit/test_publishing.rb +49 -27
- data/test/unit/test_render.rb +46 -15
- data/test/unit/test_revisions.rb +124 -127
- data/test/unit/test_schema.rb +53 -58
- data/test/unit/test_search.rb +64 -16
- data/test/unit/test_serialisation.rb +4 -11
- data/test/unit/test_site.rb +11 -12
- data/test/unit/test_structure.rb +2 -5
- data/test/unit/test_styles.rb +22 -24
- data/test/unit/test_type_hierarchy.rb +7 -5
- data/test/unit/test_visibility.rb +79 -55
- metadata +128 -102
- data/lib/sequel/plugins/content_table_inheritance.rb +0 -203
- data/lib/sequel/plugins/scoped_table_name.rb +0 -54
- data/lib/spontaneous/content.rb +0 -129
- data/lib/spontaneous/field_types/date_field.rb +0 -56
- data/lib/spontaneous/field_types/field.rb +0 -302
- data/lib/spontaneous/field_types/file_field.rb +0 -68
- data/lib/spontaneous/field_types/markdown_field.rb +0 -38
- data/lib/spontaneous/field_types/string_field.rb +0 -19
- data/lib/spontaneous/field_types/webvideo_field.rb +0 -313
- data/lib/spontaneous/field_types.rb +0 -38
- data/lib/spontaneous/generators/site/lib/site.rb.tt +0 -4
- data/lib/spontaneous/plugins/field/editor_class.rb +0 -13
- data/lib/spontaneous/plugins/page/site_timestamps.rb +0 -28
- data/lib/spontaneous/plugins/page_search.rb +0 -63
- data/lib/spontaneous/plugins/schema_id.rb +0 -68
- data/lib/spontaneous/plugins/site/publishing.rb +0 -75
- data/lib/spontaneous/rack/fiber_pool.rb +0 -26
- data/test/unit/test_table_scoping.rb +0 -80
@@ -1,313 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'open-uri'
|
4
|
-
require 'nokogiri'
|
5
|
-
|
6
|
-
module Spontaneous
|
7
|
-
module FieldTypes
|
8
|
-
class WebVideoField < Field
|
9
|
-
include Spontaneous::Plugins::Field::EditorClass
|
10
|
-
|
11
|
-
def outputs
|
12
|
-
[:type, :id]
|
13
|
-
end
|
14
|
-
|
15
|
-
def id
|
16
|
-
value(:id)
|
17
|
-
end
|
18
|
-
|
19
|
-
def video_type
|
20
|
-
value(:type)
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
def generate_outputs(input)
|
25
|
-
values = {}
|
26
|
-
values[:html] = escape_html(input)
|
27
|
-
case input
|
28
|
-
when "", nil
|
29
|
-
# ignore this
|
30
|
-
when /youtube\.com.*\?.*v=([^&]+)/, /youtu.be\/([^&]+)/
|
31
|
-
id = $1
|
32
|
-
values.update(retrieve_youtube_metadata(id))
|
33
|
-
values[:id] = id
|
34
|
-
values[:type] = "youtube"
|
35
|
-
when /vimeo\.com\/(\d+)/
|
36
|
-
id = $1
|
37
|
-
values[:type] = "vimeo"
|
38
|
-
values.update(retrieve_vimeo_metadata(id))
|
39
|
-
values[:id] = id.to_s
|
40
|
-
else
|
41
|
-
logger.warn "WebVideo field doesn't recognise the URL '#{input}'"
|
42
|
-
end
|
43
|
-
values
|
44
|
-
end
|
45
|
-
|
46
|
-
|
47
|
-
def render(format=:html, *args)
|
48
|
-
case format
|
49
|
-
when :html
|
50
|
-
to_html(*args)
|
51
|
-
when :json
|
52
|
-
to_json(*args)
|
53
|
-
else
|
54
|
-
value(format)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
def to_html(*args)
|
60
|
-
opts = args.extract_options!
|
61
|
-
case video_type
|
62
|
-
when "youtube"
|
63
|
-
to_youtube_html(opts)
|
64
|
-
when "vimeo"
|
65
|
-
to_vimeo_html(opts)
|
66
|
-
else
|
67
|
-
value(:html)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
def to_json(*args)
|
73
|
-
opts = args.extract_options!
|
74
|
-
params = \
|
75
|
-
case video_type
|
76
|
-
when "youtube"
|
77
|
-
youtube_attributes(opts)
|
78
|
-
when "vimeo"
|
79
|
-
vimeo_attributes(opts)
|
80
|
-
else
|
81
|
-
{:tagname => "iframe", :tag => "<iframe/>", :attr => {:src => value(:html)}}
|
82
|
-
end
|
83
|
-
Spontaneous.encode_json(params)
|
84
|
-
end
|
85
|
-
|
86
|
-
def src(opts = {})
|
87
|
-
case video_type
|
88
|
-
when "youtube"
|
89
|
-
youtube_src(opts)
|
90
|
-
when "vimeo"
|
91
|
-
vimeo_src(opts)
|
92
|
-
else
|
93
|
-
value(:html)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def ui_preview_value
|
98
|
-
# render(:html, :width => 480, :height => 270)
|
99
|
-
src
|
100
|
-
end
|
101
|
-
|
102
|
-
def retrieve_vimeo_metadata(id)
|
103
|
-
url = "http://vimeo.com/api/v2/video/%s.json" % id
|
104
|
-
response = \
|
105
|
-
begin
|
106
|
-
open(url).read
|
107
|
-
rescue => e
|
108
|
-
logger.error("Unable to retrieve metadata for video ##{id} from Vimeo: '#{e}'")
|
109
|
-
"[{}]"
|
110
|
-
end
|
111
|
-
metadata = Spontaneous.parse_json(response) rescue [{}]
|
112
|
-
metadata = metadata.first || {}
|
113
|
-
end
|
114
|
-
|
115
|
-
def retrieve_youtube_metadata(id)
|
116
|
-
url = "http://gdata.youtube.com/feeds/api/videos/%s?v=2" % id
|
117
|
-
begin
|
118
|
-
doc = Nokogiri::XML(open(url))
|
119
|
-
entry = doc.xpath("xmlns:entry")
|
120
|
-
|
121
|
-
{ "title" => entry.xpath("xmlns:title").text.strip,
|
122
|
-
"description" => entry.xpath("media:group/media:description").text.strip,
|
123
|
-
"thumbnail_large" => entry.xpath('media:group/media:thumbnail[@yt:name="hqdefault"]').first["url"].strip,
|
124
|
-
"thumbnail_small" => entry.xpath('media:group/media:thumbnail[@yt:name="default"]').first["url"].strip,
|
125
|
-
"user_name" => entry.xpath("xmlns:author/xmlns:name").text.strip,
|
126
|
-
"upload_date" => Time.parse(entry.xpath("xmlns:published").text.strip).strftime("%Y-%m-%d %H:%M:%S"),
|
127
|
-
"tags" => entry.xpath("media:group/media:keywords").text.strip,
|
128
|
-
"duration" => entry.xpath("media:group/yt:duration").first['seconds'].to_i,
|
129
|
-
"stats_number_of_likes" => entry.xpath("yt:rating").first['numLikes'].to_i,
|
130
|
-
"stats_number_of_plays" => entry.xpath("yt:statistics").first['viewCount'].to_i,
|
131
|
-
"stats_number_of_comments" => entry.xpath("gd:comments/gd:feedLink").first['countHint'].to_i }
|
132
|
-
rescue
|
133
|
-
{}
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def default_player_options
|
138
|
-
{
|
139
|
-
:width => 640,
|
140
|
-
:height => 360,
|
141
|
-
:fullscreen => true,
|
142
|
-
:api => false,
|
143
|
-
:autoplay => false,
|
144
|
-
:loop => false,
|
145
|
-
:showinfo => true
|
146
|
-
}.merge(prototype.options[:player] || {})
|
147
|
-
end
|
148
|
-
|
149
|
-
|
150
|
-
def to_vimeo_html(options = {})
|
151
|
-
params = vimeo_attributes(options)
|
152
|
-
|
153
|
-
attributes = make_html_attributes(params[:attr])
|
154
|
-
%(<iframe #{attributes}></iframe>)
|
155
|
-
end
|
156
|
-
|
157
|
-
def vimeo_attributes(options = {})
|
158
|
-
|
159
|
-
o = make_vimeo_options(options)
|
160
|
-
|
161
|
-
attributes = {
|
162
|
-
:type => "text/html",
|
163
|
-
:frameborder => "0",
|
164
|
-
:width => o.delete(:width),
|
165
|
-
:height => o.delete(:height)
|
166
|
-
}
|
167
|
-
attributes.update(:webkitAllowFullScreen => "yes", :allowFullScreen => "yes") if o[:fullscreen]
|
168
|
-
|
169
|
-
make_query_options!(o)
|
170
|
-
attributes[:src] = vimeo_src_with_options(o)
|
171
|
-
|
172
|
-
{:tagname => "iframe", :tag => "<iframe/>", :attr => attributes}
|
173
|
-
end
|
174
|
-
|
175
|
-
def make_vimeo_options(options = {})
|
176
|
-
o = default_player_options
|
177
|
-
vimeo_options = o.delete(:vimeo) || {}
|
178
|
-
|
179
|
-
o.merge!(vimeo_options)
|
180
|
-
|
181
|
-
if o.delete(:showinfo)
|
182
|
-
o[:portrait] = true
|
183
|
-
o[:title] = true
|
184
|
-
o[:byline] = true
|
185
|
-
else
|
186
|
-
o[:portrait] = false
|
187
|
-
o[:title] = false
|
188
|
-
o[:byline] = false
|
189
|
-
end
|
190
|
-
|
191
|
-
vimeo_options = options.delete(:vimeo) || {}
|
192
|
-
|
193
|
-
o = {
|
194
|
-
:portrait => true,
|
195
|
-
:title => true,
|
196
|
-
:byline => true,
|
197
|
-
:player_id => "vimeo#{owner.id}id#{value(:id)}"
|
198
|
-
}.merge(o).merge(vimeo_options).merge(options)
|
199
|
-
o
|
200
|
-
end
|
201
|
-
|
202
|
-
def vimeo_src(options = {})
|
203
|
-
o = make_vimeo_options(options)
|
204
|
-
make_query_options!(o)
|
205
|
-
vimeo_src_with_options(o)
|
206
|
-
end
|
207
|
-
|
208
|
-
def vimeo_src_with_options(o)
|
209
|
-
params = {
|
210
|
-
"title" => o[:title],
|
211
|
-
"byline" => o[:byline],
|
212
|
-
"portrait" => o[:portrait],
|
213
|
-
"autoplay" => o[:autoplay],
|
214
|
-
"loop" => o[:loop],
|
215
|
-
"api" => o[:api],
|
216
|
-
"player_id" => o[:player_id] }
|
217
|
-
params.update("color" => o[:color]) if o.key?(:color)
|
218
|
-
params = ::Rack::Utils.build_query(params)
|
219
|
-
"http://player.vimeo.com/video/#{value(:id)}?#{params}"
|
220
|
-
end
|
221
|
-
|
222
|
-
def to_youtube_html(options = {})
|
223
|
-
params = youtube_attributes(options)
|
224
|
-
attributes = make_html_attributes(params[:attr])
|
225
|
-
%(<iframe #{attributes}></iframe>)
|
226
|
-
end
|
227
|
-
|
228
|
-
|
229
|
-
def youtube_attributes(options = {})
|
230
|
-
o = make_youtube_options(options)
|
231
|
-
|
232
|
-
attributes = {
|
233
|
-
:type => "text/html",
|
234
|
-
:frameborder => "0",
|
235
|
-
:width => o.delete(:width),
|
236
|
-
:height => o.delete(:height)
|
237
|
-
}
|
238
|
-
|
239
|
-
make_query_options!(o)
|
240
|
-
|
241
|
-
attributes[:src] = youtube_src_with_options(o)
|
242
|
-
|
243
|
-
attributes.update(:webkitAllowFullScreen => "yes", :allowFullScreen => "yes") if o[:fullscreen]
|
244
|
-
|
245
|
-
{:tagname => "iframe", :tag => "<iframe/>", :attr => attributes}
|
246
|
-
end
|
247
|
-
|
248
|
-
def make_youtube_options(options = {})
|
249
|
-
o = default_player_options
|
250
|
-
youtube_options = o.delete(:youtube) || {}
|
251
|
-
|
252
|
-
o.merge!(youtube_options)
|
253
|
-
|
254
|
-
if o.delete(:showinfo)
|
255
|
-
o[:showinfo] = true
|
256
|
-
o[:showsearch] = true
|
257
|
-
else
|
258
|
-
o[:showinfo] = false
|
259
|
-
o[:showsearch] = false
|
260
|
-
end
|
261
|
-
|
262
|
-
youtube_options = options.delete(:youtube) || {}
|
263
|
-
o = {
|
264
|
-
:theme => "dark",
|
265
|
-
:hd => true,
|
266
|
-
:controls => true,
|
267
|
-
:showinfo => true,
|
268
|
-
:showsearch => true,
|
269
|
-
:autohide => 2,
|
270
|
-
:rel => true
|
271
|
-
}.merge(o).merge(youtube_options).merge(options)
|
272
|
-
end
|
273
|
-
|
274
|
-
def youtube_src(options = {})
|
275
|
-
o = make_youtube_options(options)
|
276
|
-
make_query_options!(o)
|
277
|
-
youtube_src_with_options(o)
|
278
|
-
end
|
279
|
-
|
280
|
-
def youtube_src_with_options(o)
|
281
|
-
params = ::Rack::Utils.build_query({
|
282
|
-
"modestbranding" => 1,
|
283
|
-
"theme" => o[:theme],
|
284
|
-
"hd" => o[:hd],
|
285
|
-
"fs" => o[:fullscreen],
|
286
|
-
"controls" => o[:controls],
|
287
|
-
"autoplay" => o[:autoplay],
|
288
|
-
"showinfo" => o[:showinfo],
|
289
|
-
"showsearch" => o[:showsearch],
|
290
|
-
"loop" => o[:loop],
|
291
|
-
"autohide" => o[:autohide],
|
292
|
-
"rel" => o[:rel],
|
293
|
-
"enablejsapi" => o[:api] })
|
294
|
-
"http://www.youtube.com/embed/#{value(:id)}?#{params}"
|
295
|
-
end
|
296
|
-
|
297
|
-
def make_html_attributes(attributes)
|
298
|
-
attributes.to_a.map { |name, value| "#{name}=\"#{escape_html(value)}\"" }.join(" ")
|
299
|
-
end
|
300
|
-
|
301
|
-
|
302
|
-
def make_query_options!(hash)
|
303
|
-
hash.each { |k, v|
|
304
|
-
hash[k] = 1 if v == true
|
305
|
-
hash[k] = 0 if v == false
|
306
|
-
}
|
307
|
-
end
|
308
|
-
|
309
|
-
self.register(:webvideo)
|
310
|
-
end
|
311
|
-
|
312
|
-
end
|
313
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module Spontaneous
|
4
|
-
module FieldTypes
|
5
|
-
|
6
|
-
autoload :Field, "spontaneous/field_types/field"
|
7
|
-
|
8
|
-
@@type_map = {}
|
9
|
-
|
10
|
-
def self.register(klass, *labels)
|
11
|
-
labels.each do |label|
|
12
|
-
@@type_map[label.to_sym] = klass
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.[](label)
|
17
|
-
@@type_map[label.to_sym] || StringField
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.serialize_field(field)
|
21
|
-
[field.schema_id.to_s, field.version, field.unprocessed_value, field.processed_values]
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.deserialize_field(serialized_field)
|
25
|
-
{
|
26
|
-
:id => serialized_field[0],
|
27
|
-
:version => serialized_field[1],
|
28
|
-
:unprocessed_value => serialized_field[2],
|
29
|
-
:processed_values => serialized_field[3]
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
[:string, :long_string, :file, :image, :date, :markdown, :location, :webvideo, :select].each do |type|
|
37
|
-
require "spontaneous/field_types/#{type}_field"
|
38
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'rack'
|
4
|
-
|
5
|
-
module Spontaneous::Plugins::Page
|
6
|
-
module SiteTimestamps
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
|
9
|
-
def after_update
|
10
|
-
::Spontaneous::State.site_modified! if field?(title_field) && fields[title_field].modified?
|
11
|
-
super
|
12
|
-
end
|
13
|
-
|
14
|
-
# Update the Site's modification time to force clients
|
15
|
-
# to reload their map data
|
16
|
-
def after_create
|
17
|
-
::Spontaneous::State.site_modified!
|
18
|
-
super
|
19
|
-
end
|
20
|
-
|
21
|
-
# Update the Site's modification time to force clients
|
22
|
-
# to reload their map data
|
23
|
-
def after_destroy
|
24
|
-
::Spontaneous::State.site_modified!
|
25
|
-
super
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module Spontaneous::Plugins
|
4
|
-
module PageSearch
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
module ClassMethods
|
8
|
-
def root
|
9
|
-
first_visible(:path => Spontaneous::SLASH)
|
10
|
-
end
|
11
|
-
|
12
|
-
def uid(uid)
|
13
|
-
first_visible(:uid => uid)
|
14
|
-
end
|
15
|
-
|
16
|
-
def path(path)
|
17
|
-
page = first_visible(:path => path)
|
18
|
-
# page = aliased_path(path) if page.nil?
|
19
|
-
page
|
20
|
-
end
|
21
|
-
|
22
|
-
def first_visible(params)
|
23
|
-
page = Spontaneous::Content.first(params)
|
24
|
-
# don't want to return nil if a page matching the params exists but is hidden
|
25
|
-
# if we return blank we force searches via other routes (such as aliased pages)
|
26
|
-
if page and Spontaneous::Content.visible_only? and page.hidden?
|
27
|
-
return false
|
28
|
-
end
|
29
|
-
page
|
30
|
-
end
|
31
|
-
|
32
|
-
# def aliased_path(path)
|
33
|
-
# puts "looking for aliased path #{path}"
|
34
|
-
# @_ps ||= Hash.new { |h, k| h[k] = prepare_aliased_path_query(k) }
|
35
|
-
# p = path.split(S::SLASH)
|
36
|
-
# root = p[0..-2].join(S::SLASH)
|
37
|
-
# visible = Spontaneous::Content.visible_only?
|
38
|
-
# @_ps[visible].call(:root => root, :slug => p.last)
|
39
|
-
# end
|
40
|
-
|
41
|
-
protected
|
42
|
-
|
43
|
-
# def prepare_aliased_path_query(visible_only=false)
|
44
|
-
# # select c2.*
|
45
|
-
# # from content as c1, content as c2, content as c3 \\
|
46
|
-
# # where c1.path = '/aliases'
|
47
|
-
# # and c2.parent_id = c1.id
|
48
|
-
# # and c2.target_id = c3.id
|
49
|
-
# # and c3.slug = 'b';
|
50
|
-
# params = {
|
51
|
-
# :c1__path => :$root,
|
52
|
-
# :c2__parent_id => :c1__id,
|
53
|
-
# :c2__target_id => :c3__id,
|
54
|
-
# :c3__slug => :$slug
|
55
|
-
# }
|
56
|
-
# params.merge!(:c3__hidden => false) if visible_only
|
57
|
-
|
58
|
-
# query = S::Content._unfiltered_dataset.select(Sequel::LiteralString.new("c2.*")).from(:content___c1, :content___c2, :content___c3).where(params)
|
59
|
-
# query.prepare(:first, :aliased_page)
|
60
|
-
# end
|
61
|
-
end # ClassMethods
|
62
|
-
end
|
63
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module Spontaneous::Plugins
|
4
|
-
module SchemaId
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
module ClassMethods
|
8
|
-
def schema_id
|
9
|
-
Spontaneous.instance.schema_id(self)
|
10
|
-
end
|
11
|
-
|
12
|
-
def schema_name
|
13
|
-
"type//#{self.name}"
|
14
|
-
end
|
15
|
-
|
16
|
-
def schema_owner
|
17
|
-
nil
|
18
|
-
end
|
19
|
-
|
20
|
-
def owner_sid
|
21
|
-
nil
|
22
|
-
end
|
23
|
-
|
24
|
-
# In the case where a new class has been added to the schema
|
25
|
-
# the STI values have been set up on a class whose schema id is undefined
|
26
|
-
# so we need to correct this once a new ID has been generated
|
27
|
-
# Bit dodgy, what I should do instead is rewrite the STI code to always defer
|
28
|
-
# to the schema for its values
|
29
|
-
def update_schema_id(new_id)
|
30
|
-
sti_key_array << new_id.to_s
|
31
|
-
superclass.sti_subclass_added(new_id.to_s, self) if superclass
|
32
|
-
end
|
33
|
-
end # ClassMethods
|
34
|
-
|
35
|
-
# InstanceMethods
|
36
|
-
|
37
|
-
[:type, :style, :box].each do |c|
|
38
|
-
column = "#{c}_sid"
|
39
|
-
self.class_eval(<<-RUBY)
|
40
|
-
def #{column}
|
41
|
-
@_#{column} ||= Spontaneous.schema.uids[@values[:#{column}]]
|
42
|
-
end
|
43
|
-
|
44
|
-
def #{column}=(sid)
|
45
|
-
@_#{column} = Spontaneous.schema.uids[sid]
|
46
|
-
@values[:#{column}] = @_#{column}.to_s
|
47
|
-
@_#{column}
|
48
|
-
end
|
49
|
-
RUBY
|
50
|
-
end
|
51
|
-
|
52
|
-
def schema_id
|
53
|
-
self.class.schema_id
|
54
|
-
end
|
55
|
-
|
56
|
-
def schema_name
|
57
|
-
self.class.schema_name
|
58
|
-
end
|
59
|
-
|
60
|
-
def schema_owner
|
61
|
-
self.class.schema_owner
|
62
|
-
end
|
63
|
-
|
64
|
-
def owner_sid
|
65
|
-
self.class.owner_sid
|
66
|
-
end
|
67
|
-
end # SchemaId
|
68
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module Spontaneous::Plugins::Site
|
4
|
-
module Publishing
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
module ClassMethods
|
8
|
-
def default_publishing_method
|
9
|
-
resolve_publishing_method(Spontaneous::Site.config.publishing_method || :immediate)
|
10
|
-
end
|
11
|
-
|
12
|
-
def publishing_method
|
13
|
-
@publishing_method ||= default_publishing_method
|
14
|
-
end
|
15
|
-
|
16
|
-
def publishing_method=(method)
|
17
|
-
@publishing_method = resolve_publishing_method(method)
|
18
|
-
end
|
19
|
-
|
20
|
-
def resolve_publishing_method(method)
|
21
|
-
klass_name = method.to_s.camelize
|
22
|
-
begin
|
23
|
-
S::Publishing.const_get(klass_name)
|
24
|
-
rescue NameError => e
|
25
|
-
puts "Unknown method #{method} (#{klass_name})"
|
26
|
-
S::Publishing::Immediate
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def publish_pages(page_list=nil)
|
31
|
-
publishing_method.new(self.revision).publish_pages(page_list)
|
32
|
-
end
|
33
|
-
|
34
|
-
def publish_all
|
35
|
-
publishing_method.new(self.revision).publish_all
|
36
|
-
end
|
37
|
-
|
38
|
-
def rerender
|
39
|
-
publishing_method.new(self.published_revision).rerender_revision
|
40
|
-
end
|
41
|
-
|
42
|
-
def publishing_status
|
43
|
-
status = rest = nil
|
44
|
-
# if r = S::Site.pending_revision
|
45
|
-
status, *rest = publishing_method.status.split(':')
|
46
|
-
rest = rest.join(':')
|
47
|
-
# end
|
48
|
-
Hash[[:status, :progress].zip([status, rest])] rescue ""
|
49
|
-
end
|
50
|
-
|
51
|
-
def publishing_status=(status)
|
52
|
-
publishing_method.status = status
|
53
|
-
end
|
54
|
-
|
55
|
-
def with_published(&block)
|
56
|
-
S::Content.with_published(&block)
|
57
|
-
end
|
58
|
-
|
59
|
-
protected
|
60
|
-
|
61
|
-
def set_published_revision(revision)
|
62
|
-
instance = S::State.instance
|
63
|
-
instance.published_revision = revision
|
64
|
-
instance.revision = revision + 1
|
65
|
-
instance.save
|
66
|
-
end
|
67
|
-
|
68
|
-
def pending_revision=(revision)
|
69
|
-
instance = S::State.instance
|
70
|
-
instance.pending_revision = revision
|
71
|
-
instance.save
|
72
|
-
end
|
73
|
-
end # ClassMethods
|
74
|
-
end # Publishing
|
75
|
-
end # Spontaneous::Plugins::Site
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'rack/fiber_pool'
|
2
|
-
|
3
|
-
module Spontaneous::Rack
|
4
|
-
class FiberPool
|
5
|
-
def initialize(app, options = {})
|
6
|
-
@target_app = app
|
7
|
-
@options = options
|
8
|
-
end
|
9
|
-
|
10
|
-
def call(env)
|
11
|
-
app.call(env)
|
12
|
-
end
|
13
|
-
|
14
|
-
def app
|
15
|
-
@app ||= wrap_target_app
|
16
|
-
end
|
17
|
-
|
18
|
-
def wrap_target_app
|
19
|
-
if Spontaneous.async?
|
20
|
-
::Rack::FiberPool.new(@target_app, @options)
|
21
|
-
else
|
22
|
-
@target_app
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|