pageflow 0.7.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of pageflow might be problematic. Click here for more details.

Files changed (40) hide show
  1. checksums.yaml +8 -8
  2. data/Rakefile +3 -1
  3. data/admins/pageflow/entry.rb +1 -0
  4. data/app/assets/javascripts/pageflow/audio_player.js +1 -1
  5. data/app/assets/javascripts/pageflow/audio_player/media_events.js +2 -1
  6. data/app/assets/javascripts/pageflow/page_types/audio.js +6 -2
  7. data/app/assets/javascripts/pageflow/page_types/video.js +6 -1
  8. data/app/assets/javascripts/pageflow/settings.js +12 -10
  9. data/app/assets/javascripts/pageflow/video_player.js +1 -1
  10. data/app/assets/javascripts/pageflow/video_player/media_events.js +2 -1
  11. data/app/assets/javascripts/pageflow/widgets/multimedia_alert.js +3 -0
  12. data/app/assets/stylesheets/pageflow/page_types/audio.css.scss +0 -4
  13. data/app/assets/stylesheets/pageflow/page_types/audio_loop.css.scss +18 -0
  14. data/app/controllers/pageflow/application_controller.rb +5 -1
  15. data/app/controllers/pageflow/revisions_controller.rb +1 -0
  16. data/app/helpers/pageflow/social_share_helper.rb +28 -12
  17. data/app/models/concerns/pageflow/hosted_file.rb +3 -0
  18. data/app/models/pageflow/image_file.rb +3 -0
  19. data/app/models/pageflow/video_file.rb +4 -0
  20. data/app/models/pageflow/widget.rb +7 -1
  21. data/app/views/components/pageflow/admin/tabs_view.rb +9 -1
  22. data/app/views/pageflow/entries/_entry.html.erb +1 -1
  23. data/app/views/pageflow/entries/partials.html.erb +1 -1
  24. data/app/views/pageflow/entries/show.html.erb +2 -2
  25. data/app/views/pageflow/entries/show.json.jbuilder +7 -5
  26. data/app/views/pageflow/pages/templates/_audio_loop.html.erb +2 -2
  27. data/app/views/pageflow/social_share/_entry_meta_tags.html.erb +2 -2
  28. data/app/views/pageflow/social_share/_page_meta_tags.html.erb +2 -2
  29. data/config/initializers/paperclip.rb +6 -6
  30. data/config/locales/en.yml +2 -4
  31. data/lib/pageflow.rb +5 -1
  32. data/lib/pageflow/ability_mixin.rb +2 -0
  33. data/lib/pageflow/admin/tabs.rb +5 -2
  34. data/lib/pageflow/configuration.rb +2 -2
  35. data/lib/pageflow/engine.rb +4 -2
  36. data/lib/pageflow/version.rb +1 -1
  37. data/lib/pageflow/widget_type.rb +5 -0
  38. data/lib/tasks/pageflow_tasks.rake +7 -4
  39. data/spec/factories/image_files.rb +4 -0
  40. metadata +20 -6
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWMxMTdkMTM4ODAyOTZhM2VlYzMyZDM5MDU2Y2FiNGZhMWY3MjUwNg==
4
+ YjJkZGQ5MGI0MTRlZmYxZjM5ZTRmMGM0ZDc1MTNiMzRhMDIwZTc5Yg==
5
5
  data.tar.gz: !binary |-
6
- NTY3MTBlMTY2YWYwY2NmZTg5MTZiYjc3M2FkZDI0ZWI1ODRkNTlkNQ==
6
+ MGRmMDdhMDFmYzAyNDI1Y2IwMGZlMmI2MWU4ODNkNmI2NjE1MzRjMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGE4MTg4MWRlNDBhOGM4NjBkYTcyMjc2Y2U2NjIxNmYxMTFjOGQyNTZlMWRh
10
- ZWUyMWE4ZmE0OTRkM2RjM2UxNjFhZDE4MjkxNmY3NjAzMTE1ZmM5ZjcwY2Ux
11
- ZWI4ZDNjMjkzNjY4ZjlkMWExNTJlNWNiNzIyZGM3YjYzNGJhMGY=
9
+ MzU1OGUzMWQyMGNjNzkxODgwNWFjYTc1N2ZiNmQyODRjZDJmNWNiMDlkMDVm
10
+ ZDc1YWQ0NWEyNzliNDVlMzljNjYzY2VkOTdiNDA1NGZlNDVmYjg1MTZlNjkw
11
+ OTQ3NTNlNmVlNGNlODg3MjliNWM2Njk3ZGY5MWVhMWE1ZGYzMjQ=
12
12
  data.tar.gz: !binary |-
13
- Mjk2NGUxNTgxZjgyNTVlZTdlNjc2NjA1YzUxNzdmZjFiZTE5MGEyOTMzNGJj
14
- YzY1NWZiMjkzMTA3M2M1ZGFhZTE0YTFhMjE0YTQ0NWU4N2Q0YTQ0ZThiYjU0
15
- YzQ3YTgxNDJkN2I2ZjZiMzVlNWY4NWQ5MGY4MGY0OGZlZGY2Nzg=
13
+ MzgyNmIxY2I1MmI4NTMxMjJjYzVmYmY4ODZjMGU0MDlmNzJkYTFkNDAxZWEw
14
+ Njg5OGUxODQwZWU3NjdiYmIwYjhmMDMyMjQyYWNkM2NmNjUyY2UyYjUwNDll
15
+ ZDY1NzY0ZDgyMzU3MWI5NDEzMjZmOWU1NWRjMWJmNzAxMGI0ZmQ=
data/Rakefile CHANGED
@@ -16,6 +16,8 @@ end
16
16
 
17
17
  require File.expand_path('spec/support/pageflow/rails_version', File.dirname(__FILE__))
18
18
  APP_RAKEFILE = File.expand_path("../spec/dummy/rails-#{Pageflow::RailsVersion.detect}/Rakefile", __FILE__)
19
- load 'rails/tasks/engine.rake'
19
+
20
+ load 'rails/tasks/engine.rake' if File.exists?(APP_RAKEFILE)
21
+ load File.expand_path('lib/tasks/pageflow_tasks.rake', File.dirname(__FILE__))
20
22
 
21
23
  Bundler::GemHelper.install_tasks
@@ -83,6 +83,7 @@ module Pageflow
83
83
 
84
84
  tabs_view(Pageflow.config.admin_resource_tabs.find_by_resource(:entry),
85
85
  :i18n => 'pageflow.admin.resource_tabs',
86
+ :authorize => true,
86
87
  :build_args => [entry])
87
88
  end
88
89
 
@@ -29,7 +29,7 @@ pageflow.AudioPlayer = function(sources, options) {
29
29
  audio.on('load', loaded.resolve);
30
30
 
31
31
  if (options.mediaEvents) {
32
- pageflow.AudioPlayer.mediaEvents(audio);
32
+ pageflow.AudioPlayer.mediaEvents(audio, options.context);
33
33
  }
34
34
 
35
35
  audio.src = function(sources) {
@@ -1,7 +1,8 @@
1
- pageflow.AudioPlayer.mediaEvents = function(player) {
1
+ pageflow.AudioPlayer.mediaEvents = function(player, context) {
2
2
  function triggerMediaEvent(name) {
3
3
  pageflow.events.trigger('media:' + name, {
4
4
  fileName: player.currentSrc,
5
+ context: context,
5
6
  currentTime: player.position,
6
7
  duration: player.duration,
7
8
  volume: player.volume(),
@@ -112,8 +112,12 @@ pageflow.pageType.register('audio', _.extend({
112
112
 
113
113
  _ensureAudioPlayer: function(pageElement) {
114
114
  this.audioPlayer = this.audioPlayer ||
115
- pageflow.AudioPlayer.fromScriptTag(pageElement.find('script[data-audio]'),
116
- {mediaEvents: true});
115
+ pageflow.AudioPlayer.fromScriptTag(pageElement.find('script[data-audio]'), {
116
+ mediaEvents: true,
117
+ context: {
118
+ page: pageElement.page('instance')
119
+ }
120
+ });
117
121
 
118
122
  pageElement.find('.vjs-controls').playerControls({
119
123
  player: this.audioPlayer
@@ -116,9 +116,14 @@ pageflow.pageType.register('video', _.extend({
116
116
  _initVideoPlayer: function(pageElement) {
117
117
  var videoPlayer = new pageflow.VideoPlayer.Lazy(pageElement.find('[data-template=video]'), {
118
118
  bufferUnderrunWaiting: true,
119
- mediaEvents: true,
120
119
  controls: true,
121
120
  customControlsOnMobile: true,
121
+
122
+ mediaEvents: true,
123
+ context: {
124
+ page: pageElement.page('instance')
125
+ },
126
+
122
127
  width: '100%',
123
128
  height: '100%'
124
129
  });
@@ -4,18 +4,20 @@ pageflow.Settings = Backbone.Model.extend({
4
4
  },
5
5
 
6
6
  initialize: function() {
7
- if (localStorage['pageflow.settings']) {
8
- try {
9
- this.set(JSON.parse(localStorage['pageflow.settings']));
7
+ if (window.localStorage) {
8
+ if (localStorage['pageflow.settings']) {
9
+ try {
10
+ this.set(JSON.parse(localStorage['pageflow.settings']));
11
+ }
12
+ catch(e) {
13
+ pageflow.log(e);
14
+ }
10
15
  }
11
- catch(e) {
12
- pageflow.log(e);
13
- }
14
- }
15
16
 
16
- this.on('change', function() {
17
- localStorage['pageflow.settings'] = JSON.stringify(this);
18
- });
17
+ this.on('change', function() {
18
+ localStorage['pageflow.settings'] = JSON.stringify(this);
19
+ });
20
+ }
19
21
  }
20
22
  });
21
23
 
@@ -18,7 +18,7 @@ pageflow.VideoPlayer = function(element, options) {
18
18
  pageflow.VideoPlayer.srcFromOptionsMethod(player);
19
19
 
20
20
  if (options.mediaEvents) {
21
- pageflow.VideoPlayer.mediaEvents(player);
21
+ pageflow.VideoPlayer.mediaEvents(player, options.context);
22
22
  }
23
23
 
24
24
  if (options.bufferUnderrunWaiting) {
@@ -1,7 +1,8 @@
1
- pageflow.VideoPlayer.mediaEvents = function(player) {
1
+ pageflow.VideoPlayer.mediaEvents = function(player, context) {
2
2
  function triggerMediaEvent(name) {
3
3
  pageflow.events.trigger('media:' + name, {
4
4
  fileName: player.currentSrc(),
5
+ context: context,
5
6
  currentTime: player.currentTime(),
6
7
  duration: player.duration(),
7
8
  volume: player.volume(),
@@ -15,7 +15,10 @@
15
15
  widget.element.find('.close').on('click', function() {
16
16
  widget.element.hide();
17
17
  toggleContent(true);
18
+
19
+ pageflow.events.trigger('button:close_multimedia_alert');
18
20
  start();
21
+
19
22
  return false;
20
23
  });
21
24
  });
@@ -21,10 +21,6 @@
21
21
  .js .audioPage {
22
22
  .contentText {
23
23
  margin-bottom: 200px;
24
-
25
- @include phone {
26
- margin-bottom: 100px;
27
- }
28
24
  }
29
25
 
30
26
  .non_js_audio {
@@ -0,0 +1,18 @@
1
+ .js .audioLoopPage {
2
+ .non_js_audio {
3
+ display: none;
4
+ }
5
+ }
6
+
7
+ .non_js .text_position_right .audioLoopPage {
8
+ .page_header {
9
+ margin-left: 0;
10
+ max-width: initial;
11
+
12
+ > * {
13
+ max-width: 500px;
14
+ width: 60%;
15
+ margin-left: auto;
16
+ }
17
+ }
18
+ }
@@ -6,7 +6,7 @@ module Pageflow
6
6
  layout 'pageflow/application'
7
7
 
8
8
  before_filter do
9
- I18n.locale = current_user.try(:locale) || I18n.default_locale
9
+ I18n.locale = current_user.try(:locale) || locale_from_accept_language_header || I18n.default_locale
10
10
  end
11
11
 
12
12
  # Prevent CSRF attacks by raising an exception.
@@ -59,5 +59,9 @@ module Pageflow
59
59
  redirect_to("http://#{request.host}#{request.fullpath}", :status => :moved_permanently)
60
60
  end
61
61
  end
62
+
63
+ def locale_from_accept_language_header
64
+ http_accept_language.compatible_language_from(I18n.available_locales)
65
+ end
62
66
  end
63
67
  end
@@ -13,6 +13,7 @@ module Pageflow
13
13
  @entry = PublishedEntry.new(revision.entry, revision)
14
14
  I18n.locale = @entry.locale
15
15
 
16
+ @widget_scope = :preview
16
17
  render :template => 'pageflow/entries/show'
17
18
  end
18
19
 
@@ -23,23 +23,34 @@ module Pageflow
23
23
  title.join(' ')
24
24
  end
25
25
 
26
- def social_share_page_description(page)
27
- return page.configuration['text'] if page.configuration['text'].present?
28
- return page.configuration['description'] if page.configuration['description'].present?
26
+ def social_share_page_description(page, entry)
27
+ return social_share_sanitize(page.configuration['text']) if page.configuration['text'].present?
28
+ return social_share_sanitize(page.configuration['description']) if page.configuration['description'].present?
29
+ social_share_entry_description(entry)
30
+ end
31
+
32
+ def social_share_entry_description(entry)
33
+ return social_share_sanitize(entry.summary) if entry.summary.present?
34
+
35
+ entry.pages.each do |page|
36
+ return social_share_sanitize(page.configuration['text']) if page.configuration['text'].present?
37
+ end
29
38
  ''
30
39
  end
31
40
 
32
41
  def social_share_entry_image_tags(entry)
33
42
  image_urls = []
34
43
 
35
- image_urls << ImageFile.find(entry.share_image_id).thumbnail_url(:medium) if entry.share_image_id.present?
36
-
37
- entry.pages.each do |page|
38
- if image_urls.size >= 4
39
- break
40
- else
41
- image_urls << page.thumbnail_url(:medium)
42
- image_urls.uniq!
44
+ if entry.share_image_id.present?
45
+ image_urls << ImageFile.find(entry.share_image_id).thumbnail_url(:medium)
46
+ else
47
+ entry.pages.each do |page|
48
+ if image_urls.size >= 4
49
+ break
50
+ else
51
+ image_urls << page.thumbnail_url(:medium)
52
+ image_urls.uniq!
53
+ end
43
54
  end
44
55
  end
45
56
 
@@ -50,5 +61,10 @@ module Pageflow
50
61
  url.gsub(/^(\/\/|https:\/\/)/, 'http://')
51
62
  end
52
63
 
64
+ private
65
+
66
+ def social_share_sanitize(text)
67
+ strip_tags(text.gsub(/<br ?\/?>/, ' ').squish)
68
+ end
53
69
  end
54
- end
70
+ end
@@ -7,6 +7,9 @@ module Pageflow
7
7
  has_attached_file(:attachment_on_filesystem, Pageflow.config.paperclip_filesystem_default_options)
8
8
  has_attached_file(:attachment_on_s3, Pageflow.config.paperclip_s3_default_options)
9
9
 
10
+ do_not_validate_attachment_file_type(:attachment_on_filesystem)
11
+ do_not_validate_attachment_file_type(:attachment_on_s3)
12
+
10
13
  state_machine initial: 'not_uploaded_to_s3' do
11
14
  extend StateMachineJob::Macro
12
15
 
@@ -17,6 +17,9 @@ module Pageflow
17
17
  :large => "-quality 70 -interlace Plane"
18
18
  }))
19
19
 
20
+ do_not_validate_attachment_file_type(:unprocessed_attachment)
21
+ do_not_validate_attachment_file_type(:processed_attachment)
22
+
20
23
  after_unprocessed_attachment_post_process :save_image_dimensions
21
24
 
22
25
  def attachment
@@ -28,6 +28,10 @@ module Pageflow
28
28
  :large => "-quality 60 -interlace Plane"
29
29
  }))
30
30
 
31
+
32
+ do_not_validate_attachment_file_type(:poster)
33
+ do_not_validate_attachment_file_type(:thumbnail)
34
+
31
35
  def thumbnail_url(*args)
32
36
  poster.url(*args)
33
37
  end
@@ -11,7 +11,13 @@ module Pageflow
11
11
  end
12
12
 
13
13
  def enabled?(options)
14
- options[:only] != :editor || widget_type.enabled_in_editor?
14
+ if options[:scope] == :editor
15
+ widget_type.enabled_in_editor?
16
+ elsif options[:scope] == :preview
17
+ widget_type.enabled_in_preview?
18
+ else
19
+ true
20
+ end
15
21
  end
16
22
 
17
23
  def widget_type
@@ -8,8 +8,8 @@ module Pageflow
8
8
  def build(tabs, options = {})
9
9
  super(class: 'admin_tabs_view')
10
10
 
11
- @tabs = tabs
12
11
  @options = options
12
+ @tabs = filter_tabs(tabs)
13
13
 
14
14
  build_tab_list
15
15
  build_tab_containers
@@ -17,6 +17,14 @@ module Pageflow
17
17
 
18
18
  private
19
19
 
20
+ def filter_tabs(tabs)
21
+ return tabs unless options[:authorize]
22
+
23
+ tabs.select do |tab_options|
24
+ authorized?(:view, tab_options[:component])
25
+ end
26
+ end
27
+
20
28
  def build_tab_list
21
29
  ul(class: 'tabs') do
22
30
  tabs.each do |tab_options|
@@ -16,5 +16,5 @@
16
16
 
17
17
  <%= render 'pageflow/entries/header', :entry => entry %>
18
18
  <%= render 'pageflow/entries/overview', :entry => entry %>
19
- <%= render_widgets(entry) %>
19
+ <%= render_widgets(entry, :scope => widget_scope) %>
20
20
  <% end %>
@@ -1,3 +1,3 @@
1
1
  <%= render 'pageflow/entries/header', :entry => @entry %>
2
2
  <%= render 'pageflow/entries/overview', :entry => @entry %>
3
- <%= render_widgets(@entry, only: :editor) %>
3
+ <%= render_widgets(@entry, scope: :editor) %>
@@ -13,12 +13,12 @@
13
13
  <% end %>
14
14
  <% end %>
15
15
 
16
- <%= cache @entry do %>
16
+ <%= cache [@entry, :body, @widget_scope] do %>
17
17
 
18
18
  <%= render 'pageflow/entries/ie8_hint' %>
19
19
  <%= render 'pageflow/entries/loading_spinner' %>
20
20
  <%= render 'pageflow/entries/multimedia_alert' %>
21
- <%= render @entry %>
21
+ <%= render @entry, :widget_scope => @widget_scope %>
22
22
 
23
23
  <script>
24
24
  pageflow.manualStart.enabled = <%= @entry.manual_start ? 'true' : 'false' %>;
@@ -1,8 +1,10 @@
1
1
  Pageflow.config.file_types.each do |file_type|
2
- json.set!(file_type.collection_name) do
3
- json.partial!(collection: @entry.files(file_type.model),
4
- partial: 'pageflow/editor/files/file',
5
- locals: {file_type: file_type},
6
- as: :file)
2
+ json.set!(file_type.collection_name, @entry.files(file_type.model)) do |file|
3
+ json.cache!(file) do
4
+ json.partial!(object: file,
5
+ partial: 'pageflow/editor/files/file',
6
+ locals: {file_type: file_type},
7
+ as: :file)
8
+ end
7
9
  end
8
10
  end
@@ -1,5 +1,5 @@
1
1
  <div class="blackLayer"></div>
2
- <div class="content_and_background audioPage">
2
+ <div class="content_and_background audioLoopPage">
3
3
 
4
4
  <div class="backgroundArea">
5
5
  <%= background_image_div(configuration, 'background_image') %>
@@ -19,7 +19,7 @@
19
19
  <div class="scroller">
20
20
  <div>
21
21
  <div class="contentWrapper">
22
- <div class="contentText audioPage">
22
+ <div class="contentText audioLoopPage">
23
23
  <p class="non_js_audio">
24
24
  <%= audio_file_non_js_link(configuration['audio_file_id']) %>
25
25
  </p>
@@ -3,10 +3,10 @@
3
3
  <%= social_share_entry_image_tags(entry) %>
4
4
 
5
5
  <%= tag :meta, :property => "og:title", :content => "#{entry.title} - #{entry.theming.cname_domain}" %>
6
- <%= tag :meta, :property => "og:description", :name => "description", :content => entry_summary(entry) %>
6
+ <%= tag :meta, :property => "og:description", :name => "description", :content => social_share_entry_description(entry) %>
7
7
  <%= tag :meta, :property => "og:url", :content => pretty_entry_url(entry) %>
8
8
  <%= tag :meta, :property => "og:site_name", :content => entry.theming.cname_domain %>
9
9
  <%= tag :meta, :property => "og:type", :content => "website" %>
10
10
 
11
11
  <%= tag :meta, :name => "twitter:card", :content => "summary_large_image" %>
12
- <%= tag :meta, :name => "twitter:description", :content => entry_summary(entry) %>
12
+ <%= tag :meta, :name => "twitter:description", :content => social_share_entry_description(entry) %>
@@ -3,10 +3,10 @@
3
3
  <%= tag :meta, :property => "og:image", :content => social_share_normalize_protocol(page.thumbnail_url(:medium)) %>
4
4
 
5
5
  <%= tag :meta, :property => "og:title", :content => social_share_page_title(page) %>
6
- <%= tag :meta, :property => "og:description", :name => "description", :content => social_share_page_description(page) %>
6
+ <%= tag :meta, :property => "og:description", :name => "description", :content => social_share_page_description(page, entry) %>
7
7
  <%= tag :meta, :property => "og:url", :content => social_share_page_url(page) %>
8
8
  <%= tag :meta, :property => "og:site_name", :content => entry.theming.cname_domain %>
9
9
  <%= tag :meta, :property => "og:type", :content => "website" %>
10
10
 
11
11
  <%= tag :meta, :name => "twitter:card", :content => "summary_large_image" %>
12
- <%= tag :meta, :name => "twitter:description", :content => social_share_page_description(page) %>
12
+ <%= tag :meta, :name => "twitter:description", :content => social_share_page_description(page, entry) %>
@@ -5,12 +5,12 @@ Pageflow.configure do |config|
5
5
  config.paperclip_filesystem_root = Rails.root.join('tmp/attachments/production/')
6
6
 
7
7
  if Rails.env.test?
8
- config.paperclip_s3_default_options = {
8
+ config.paperclip_s3_default_options.merge!({
9
9
  :storage => :filesystem,
10
10
  :path => ':rails_root/tmp/attachments/test/s3/:class/:attachment/:id_partition/:style/:filename'
11
- }
11
+ })
12
12
  else
13
- config.paperclip_s3_default_options = {
13
+ config.paperclip_s3_default_options.merge!({
14
14
  :storage => :s3,
15
15
  :s3_headers => {'Expires' => 1.year.from_now.httpdate},
16
16
  :s3_options => {:max_retries => 10},
@@ -24,14 +24,14 @@ Pageflow.configure do |config|
24
24
  # master, but for us not deleting old files is good enough. They
25
25
  # might be in the CDN anyway.
26
26
  :keep_old_files => true
27
- }
27
+ })
28
28
  end
29
29
 
30
- config.paperclip_filesystem_default_options = {
30
+ config.paperclip_filesystem_default_options.merge!({
31
31
  :storage => :filesystem,
32
32
  :path => ':pageflow_filesystem_root/:class/:attachment/:id_partition/:style/:filename',
33
33
  :url => 'not_uploaded_yet'
34
- }
34
+ })
35
35
 
36
36
  config.thumbnail_styles = {
37
37
  thumbnail: {
@@ -1443,7 +1443,7 @@ en:
1443
1443
 
1444
1444
  Under „Title and Options“ you can set up basic appearance
1445
1445
 
1446
- parameters as well as the title, language and lega
1446
+ parameters as well as the title, language and legal
1447
1447
 
1448
1448
  notice. You can also decide which content should be
1449
1449
 
@@ -1478,9 +1478,7 @@ en:
1478
1478
  and chapters any time.
1479
1479
 
1480
1480
 
1481
- For more details see: [Chapter and Pages](#pageflow.help_entries.outline)
1482
-
1483
- '
1481
+ For more details see: [Chapter and Pages](#pageflow.help_entries.outline)'
1484
1482
  page_options:
1485
1483
  menu_item: General Page Options
1486
1484
  text: ! '# General Page Options
@@ -17,6 +17,10 @@ module Pageflow
17
17
  @configure_blocks << block
18
18
  end
19
19
 
20
+ def self.configured?
21
+ !!@config
22
+ end
23
+
20
24
  def self.configure!
21
25
  return unless @finalized
22
26
 
@@ -62,7 +66,7 @@ module Pageflow
62
66
 
63
67
  def self.active_admin_settings(config)
64
68
  config.before_filter do
65
- I18n.locale = current_user.try(:locale) || I18n.default_locale
69
+ I18n.locale = current_user.try(:locale) || http_accept_language.compatible_language_from(I18n.available_locales) || I18n.default_locale
66
70
  end
67
71
  end
68
72
  end
@@ -29,6 +29,8 @@ module Pageflow
29
29
  can_edit_entry?(user, revision.entry)
30
30
  end
31
31
 
32
+ can :view, [Admin::MembersTab, Admin::RevisionsTab]
33
+
32
34
  if user.admin?
33
35
  can [:read, :create, :update], Account
34
36
  can :destroy, Account do |account|
@@ -5,11 +5,14 @@ module Pageflow
5
5
  @tabs = {}
6
6
  end
7
7
 
8
- def register(resource_name, view_component)
8
+ # @param [Symbol] resource_name A resource name like `:entry` or `:account`
9
+ # @param [Hash] tab_options
10
+ def register(resource_name, tab_options)
9
11
  @tabs[resource_name] ||= []
10
- @tabs[resource_name] << view_component
12
+ @tabs[resource_name] << tab_options
11
13
  end
12
14
 
15
+ # @api private
13
16
  def find_by_resource(name)
14
17
  @tabs.fetch(name, [])
15
18
  end
@@ -168,8 +168,8 @@ module Pageflow
168
168
  attr_accessor :available_locales
169
169
 
170
170
  def initialize
171
- @paperclip_filesystem_default_options = {}
172
- @paperclip_s3_default_options = {}
171
+ @paperclip_filesystem_default_options = {validate_media_type: false}
172
+ @paperclip_s3_default_options = {validate_media_type: false}
173
173
 
174
174
  @zencoder_options = {}
175
175
 
@@ -23,6 +23,7 @@ require 'marionette-rails'
23
23
  require 'jquery-fileupload-rails'
24
24
  require 'wysihtml5x/rails'
25
25
  require 'i18n-js'
26
+ require 'http_accept_language'
26
27
 
27
28
  module Pageflow
28
29
  # Rails integration
@@ -72,9 +73,10 @@ module Pageflow
72
73
  Pageflow.configure!
73
74
  end
74
75
 
75
- # Make pageflow factories available to main app specs
76
76
  initializer "pageflow.factories", :after => "factory_girl.set_factory_paths" do
77
- FactoryGirl.definition_file_paths.unshift(Engine.root.join('spec', 'factories')) if defined?(FactoryGirl)
77
+ if Pageflow.configured? && defined?(FactoryGirl)
78
+ FactoryGirl.definition_file_paths.unshift(Engine.root.join('spec', 'factories'))
79
+ end
78
80
  end
79
81
  end
80
82
  end
@@ -1,3 +1,3 @@
1
1
  module Pageflow
2
- VERSION = "0.7.2"
2
+ VERSION = '0.8.0'
3
3
  end
@@ -20,6 +20,11 @@ module Pageflow
20
20
  true
21
21
  end
22
22
 
23
+ # Override to return false to hide widget in entry preview.
24
+ def enabled_in_preview?
25
+ true
26
+ end
27
+
23
28
  # Override to return html as string.
24
29
  def render(template, entry)
25
30
  template.render(File.join('pageflow', name, 'widget'), entry: entry)
@@ -1,4 +1,7 @@
1
- # desc "Explaining what the task does"
2
- # task :pageflow do
3
- # # Task goes here
4
- # end
1
+ namespace :pageflow do
2
+ desc 'Generate dummy app for current Rails version.'
3
+ task :dummy do
4
+ require 'pageflow/support'
5
+ Pageflow::Dummy.setup
6
+ end
7
+ end
@@ -19,6 +19,10 @@ module Pageflow
19
19
  create(:file_usage, :file => file, :revision => evaluator.used_in) if evaluator.used_in
20
20
  end
21
21
 
22
+ trait :processed do
23
+ processed_attachment File.open(Engine.root.join('spec', 'fixtures', 'image.jpg'))
24
+ end
25
+
22
26
  trait :unprocessed do
23
27
  unprocessed_attachment File.open(Engine.root.join('spec', 'fixtures', 'image.jpg'))
24
28
  processed_attachment nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pageflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Codevise Solutions Ltd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-25 00:00:00.000000000 Z
11
+ date: 2015-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -232,14 +232,14 @@ dependencies:
232
232
  requirements:
233
233
  - - ~>
234
234
  - !ruby/object:Gem::Version
235
- version: '3.5'
235
+ version: '4.2'
236
236
  type: :runtime
237
237
  prerelease: false
238
238
  version_requirements: !ruby/object:Gem::Requirement
239
239
  requirements:
240
240
  - - ~>
241
241
  - !ruby/object:Gem::Version
242
- version: '3.5'
242
+ version: '4.2'
243
243
  - !ruby/object:Gem::Dependency
244
244
  name: zencoder
245
245
  requirement: !ruby/object:Gem::Requirement
@@ -484,6 +484,20 @@ dependencies:
484
484
  - - <
485
485
  - !ruby/object:Gem::Version
486
486
  version: '3.0'
487
+ - !ruby/object:Gem::Dependency
488
+ name: http_accept_language
489
+ requirement: !ruby/object:Gem::Requirement
490
+ requirements:
491
+ - - ~>
492
+ - !ruby/object:Gem::Version
493
+ version: '2.0'
494
+ type: :runtime
495
+ prerelease: false
496
+ version_requirements: !ruby/object:Gem::Requirement
497
+ requirements:
498
+ - - ~>
499
+ - !ruby/object:Gem::Version
500
+ version: '2.0'
487
501
  - !ruby/object:Gem::Dependency
488
502
  name: mysql2
489
503
  requirement: !ruby/object:Gem::Requirement
@@ -630,14 +644,14 @@ dependencies:
630
644
  requirements:
631
645
  - - ~>
632
646
  - !ruby/object:Gem::Version
633
- version: 0.8.0
647
+ version: 0.9.0
634
648
  type: :development
635
649
  prerelease: false
636
650
  version_requirements: !ruby/object:Gem::Requirement
637
651
  requirements:
638
652
  - - ~>
639
653
  - !ruby/object:Gem::Version
640
- version: 0.8.0
654
+ version: 0.9.0
641
655
  - !ruby/object:Gem::Dependency
642
656
  name: webmock
643
657
  requirement: !ruby/object:Gem::Requirement