georgia 0.7.6 → 0.7.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/georgia/content-types/jpeg.jpg +0 -0
  3. data/app/assets/javascripts/georgia/components/portlets/slide.js.coffee +2 -0
  4. data/app/controllers/georgia/api/media_controller.rb +2 -7
  5. data/app/controllers/georgia/api/tags_controller.rb +3 -7
  6. data/app/controllers/georgia/application_controller.rb +1 -1
  7. data/app/controllers/georgia/concerns/frontendable.rb +16 -8
  8. data/app/controllers/georgia/media_controller.rb +1 -1
  9. data/app/controllers/georgia/revisions_controller.rb +6 -1
  10. data/app/controllers/georgia/slides_controller.rb +1 -1
  11. data/app/decorators/georgia/content_decorator.rb +9 -0
  12. data/app/helpers/georgia/internationalization_helper.rb +13 -0
  13. data/app/helpers/georgia/pages_helper.rb +8 -0
  14. data/app/helpers/georgia/ui_helper.rb +0 -8
  15. data/app/models/georgia/concerns/contentable.rb +2 -2
  16. data/app/models/georgia/concerns/slugable.rb +2 -0
  17. data/app/models/georgia/widget.rb +3 -3
  18. data/app/presenters/georgia/page_actions_presenter.rb +2 -4
  19. data/app/views/georgia/ckeditor/pictures/_picture.html.erb +1 -1
  20. data/app/views/georgia/revisions/edit.html.erb +2 -2
  21. data/app/views/georgia/revisions/fields/_content.html.erb +1 -14
  22. data/app/views/georgia/slides/new.html.erb +1 -1
  23. data/app/views/georgia/widgets/_widget.html.erb +4 -3
  24. data/app/views/georgia/widgets/index.html.erb +2 -0
  25. data/lib/georgia.rb +0 -1
  26. data/lib/georgia/engine.rb +2 -0
  27. data/lib/georgia/indexer.rb +6 -36
  28. data/lib/georgia/indexer/adapter.rb +44 -0
  29. data/lib/georgia/indexer/extensions/solr_adapter/acts_as_taggable_on/tag.rb +9 -0
  30. data/lib/georgia/indexer/extensions/tire_adapter/{acts_as_taggable_on_tag.rb → acts_as_taggable_on/tag.rb} +1 -1
  31. data/lib/georgia/indexer/extensions/tire_adapter/ckeditor/asset.rb +53 -0
  32. data/lib/georgia/indexer/extensions/tire_adapter/{georgia_page.rb → georgia/page.rb} +3 -3
  33. data/lib/georgia/indexer/solr_adapter.rb +9 -4
  34. data/lib/georgia/indexer/tire_adapter.rb +10 -9
  35. data/lib/georgia/version.rb +1 -1
  36. data/lib/tasks/assets.rake +0 -86
  37. data/lib/tasks/solr.rake +0 -9
  38. metadata +307 -307
  39. data/lib/georgia/assets.rb +0 -8
  40. data/lib/georgia/assets/cloud_files_connection.rb +0 -22
  41. data/lib/georgia/assets/transferable_picture.rb +0 -51
  42. data/lib/georgia/indexer/extensions/tire_adapter/ckeditor_asset.rb +0 -41
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e6ad208668a7070cb8265fbac2fd21e2216df43
4
- data.tar.gz: e003d41f4e19d141fcfcb5629335744a5b9eb205
3
+ metadata.gz: e2c023563b6dd7111d22f5caf701b495c27bbeaf
4
+ data.tar.gz: 2bebca43c34b00820ce9ec89ddcb25bc088c9aff
5
5
  SHA512:
6
- metadata.gz: 4c54848250467dc0896fe3be6077a8082e586c4f69bd262f40891d3eb08a811674fff7bb879407895f4baddb0999ae9e63215c0b99977429ca574030b6d03ab3
7
- data.tar.gz: 15734547e9bfa5631ef996570349ce563b2fe70c36ff6ad31fc1770403c614a0b7cb7532649905e977ca52809a5659c13d11d686194b52c32c846554f1f95234
6
+ metadata.gz: 14d7799b3912e204652a67a1f53b9c75ad63c3d8303927d0a0d272ba8abd858d2c82649beb6e3ac44023a07bc71ef8077bce9a7ac320fea651c637191d10e8c8
7
+ data.tar.gz: 64a18a2521039fb0ee834dc89781f8d104a92833c0322f7baeb96b0d7d3e7011478f7613edd4911fc3fecfd8eef8ce440e379b9440d1c046127be4d25a39d9c9
@@ -18,6 +18,8 @@ class @SlidePortlet
18
18
  event.preventDefault()
19
19
  $.ajax(
20
20
  url: "/admin/slides/new"
21
+ data:
22
+ locale: $('[data-locale]').data('locale')
21
23
  ).done( (data) => @slideList.append(data) )
22
24
 
23
25
  removeSlide: (event) =>
@@ -3,13 +3,8 @@ module Georgia
3
3
  class MediaController < Georgia::ApplicationController
4
4
 
5
5
  def pictures
6
- @search = Ckeditor::Picture.search do
7
- fulltext params[:query] do
8
- fields(:filename, :tags)
9
- end
10
- paginate(page: params[:page], per_page: (params[:per] || 12))
11
- end
12
- @pictures = @search.results
6
+ @pictures = Georgia::Indexer.search(Ckeditor::Picture, params.merge(per: 12))
7
+ @pictures = Ckeditor::PictureDecorator.decorate_collection(@pictures)
13
8
  render layout: false
14
9
  end
15
10
 
@@ -6,14 +6,10 @@ module Georgia
6
6
  respond_to :json
7
7
 
8
8
  def search
9
- @search = ActsAsTaggableOn::Tag.search do
10
- fulltext params[:q] do
11
- fields(:name)
12
- end
13
- paginate(page: 1, per_page: 10)
14
- end
9
+ @tags = Georgia::Indexer.search(ActsAsTaggableOn::Tag, params)
10
+
15
11
  # Format for select2
16
- @tags = @search.results.map{|t| {id: t.id, text: t.name}}
12
+ @tags = @tags.map{|t| {id: t.id, text: t.name}}
17
13
 
18
14
  respond_with(results: @tags)
19
15
  end
@@ -11,7 +11,7 @@ module Georgia
11
11
  end
12
12
 
13
13
  def current_locale
14
- I18n.locale
14
+ @current_locale ||= params.fetch(:locale, I18n.locale.to_s)
15
15
  end
16
16
  helper_method :current_locale
17
17
 
@@ -13,21 +13,29 @@ module Georgia
13
13
  # Loads the page according to request url
14
14
  # Restore the latest published revision of the given page
15
15
  def show
16
- @page = Georgia::Page.where(url: "/#{params[:request_path]}").includes(current_revision: :contents).published.first || not_found
17
- @page = Georgia::PageDecorator.decorate(@page)
16
+ if preview?
17
+ prepare_preview
18
+ else
19
+ @page = Georgia::Page.from_url(params[:request_path]).published.first || not_found
20
+ @page = Georgia::PageDecorator.decorate(@page)
21
+ end
22
+ end
23
+
24
+ protected
25
+
26
+ def preview?
27
+ params[:r].present?
18
28
  end
19
29
 
20
30
  # Loads the page according to given id
21
31
  # Temporarily set the given revision to preview as the 'current_revision'
22
- def preview
23
- @page = Georgia::Page.find(params[:id]).decorate
24
- @page.current_revision = Georgia::Revision.find(params[:revision_id])
32
+ def prepare_preview
33
+ @page = Georgia::Page.from_url(params[:request_path]).first || not_found
34
+ @page = Georgia::PageDecorator.decorate(@page)
35
+ @page.current_revision = Georgia::Revision.find(params[:r])
25
36
  authorize! :preview, @page
26
- render :show
27
37
  end
28
38
 
29
- protected
30
-
31
39
  # Triggers a 404 page not found
32
40
  # Use when provided url doesn't match any the Georgia::Pages
33
41
  def not_found
@@ -11,7 +11,7 @@ module Georgia
11
11
 
12
12
  def search
13
13
  @asset = Ckeditor::Asset.new
14
- @results = Georgia::Indexer.adapter.search(Ckeditor::Asset, params)
14
+ @results = Georgia::Indexer.search(Ckeditor::Asset, params)
15
15
  @assets = Ckeditor::AssetDecorator.decorate_collection(@results)
16
16
  end
17
17
 
@@ -38,7 +38,7 @@ module Georgia
38
38
  # Sends revision to main_app router
39
39
  # FIXME: bypass this once Georgia will be loaded on root
40
40
  def preview
41
- redirect_to main_app.preview_page_path(id: @page.id, revision_id: @revision.id)
41
+ redirect_to preview_url
42
42
  end
43
43
 
44
44
  def review
@@ -81,11 +81,16 @@ module Georgia
81
81
  else
82
82
  @content = @revision.content
83
83
  end
84
+ @content = Georgia::ContentDecorator.decorate(@content)
84
85
  end
85
86
 
86
87
  def notify(message, url)
87
88
  Notifier.notify_admins(message, url).deliver
88
89
  end
89
90
 
91
+ def preview_url
92
+ "#{@page.decorate.url}?r=#{@revision.id}"
93
+ end
94
+
90
95
  end
91
96
  end
@@ -4,7 +4,7 @@ module Georgia
4
4
  # Renders new portlet for revisions#edit
5
5
  def new
6
6
  @slide = Slide.new()
7
- @slide.contents.build(locale: current_locale)
7
+ @content = @slide.contents.build(locale: current_locale)
8
8
  render layout: false
9
9
  end
10
10
 
@@ -0,0 +1,9 @@
1
+ module Georgia
2
+ class ContentDecorator < Georgia::ApplicationDecorator
3
+
4
+ def title_or_none
5
+ title.present? ? title : h.content_tag(:span, 'No title', class: 'muted')
6
+ end
7
+
8
+ end
9
+ end
@@ -13,6 +13,19 @@ module Georgia
13
13
  end
14
14
  end
15
15
 
16
+ def link_to_available_locales
17
+ return unless I18n.available_locales.any?
18
+ links = I18n.available_locales.map do |locale|
19
+ content_tag(:li, link_to(t("georgia.#{locale}"), locale: locale ))
20
+ end
21
+ content_tag(:p, class: 'hint') do
22
+ content_tag(:div, class: 'dropdown') do
23
+ link_to("Change language <span class='caret'></span>".html_safe, '#', class: 'btn btn-warning', data: {toggle: 'dropdown'}, role: :button) +
24
+ content_tag(:ul, links.join('').html_safe, class: 'dropdown-menu', role: 'menu')
25
+ end
26
+ end
27
+ end
28
+
16
29
  protected
17
30
 
18
31
  def link_to_locale_list html_options
@@ -18,5 +18,13 @@ module Georgia
18
18
  Georgia::WarningMessage.new(self, page, revision, options)
19
19
  end
20
20
 
21
+ def picture_tag picture, options={}
22
+ return unless picture and picture.url.present?
23
+ format = options.fetch(:format, :tiny)
24
+ link_to picture.url_content, class: 'media-link bg-transparent', rel: 'shadowbox[gallery]' do
25
+ image_tag(picture.url(format), title: picture.data_file_name, class: 'media-image')
26
+ end
27
+ end
28
+
21
29
  end
22
30
  end
@@ -22,14 +22,6 @@ module Georgia
22
22
  content_tag :div, icon_tag('spinner fa-spin fa-4x'), options
23
23
  end
24
24
 
25
- def picture_tag picture, options={}
26
- return unless picture and picture.url.present?
27
- format = options.fetch(:format, :tiny)
28
- link_to picture.url_content, class: 'media-link bg-transparent', rel: 'shadowbox[gallery]' do
29
- image_tag(picture.url(format), title: picture.data_file_name, class: 'media-image')
30
- end
31
- end
32
-
33
25
  def link_to_back url=:back
34
26
  link_to icon_tag('level-up fa-rotate-270'), url, class: 'btn btn-back'
35
27
  end
@@ -10,11 +10,11 @@ module Georgia
10
10
  accepts_nested_attributes_for :contents
11
11
  attr_accessible :contents_attributes
12
12
 
13
- scope :with_locale, lambda {|locale| joins(:contents).where(georgia_contents: {locale: locale})}
13
+ scope :with_locale, lambda {|locale| joins(:contents).where(georgia_contents: {locale: locale}).uniq}
14
14
 
15
15
  def content(locale=nil)
16
16
  locale ||= I18n.locale.to_s
17
- @content ||= contents.select{|c| c.locale == locale}.first || Georgia::Content.new
17
+ @content ||= contents.select{|c| c.locale == locale}.first || Georgia::Content.new(locale: locale)
18
18
  end
19
19
 
20
20
  delegate :title, :text, :excerpt, :keywords, :keyword_list, :image, :locale, to: :content
@@ -14,6 +14,8 @@ module Georgia
14
14
  before_validation :sanitize_slug
15
15
  after_save :update_url
16
16
 
17
+ scope :from_url, -> (path) { where(url: "/#{path}").includes(current_revision: :contents) }
18
+
17
19
  # Must stay public for #update_url on descendants
18
20
  def set_url
19
21
  self.update_column(:url, '/' + self.ancestry_url)
@@ -8,9 +8,9 @@ module Georgia
8
8
  has_many :revisions, through: :ui_associations
9
9
  has_many :pages, through: :revisions
10
10
 
11
- scope :footer, joins(:ui_sections).where(georgia_ui_sections: {name: 'Footer'})
12
- scope :submenu, joins(:ui_sections).where(georgia_ui_sections: {name: 'Submenu'})
13
- scope :sidebar, joins(:ui_sections).where(georgia_ui_sections: {name: 'Sidebar'})
11
+ scope :footer, joins(:ui_sections).where(georgia_ui_sections: {name: 'Footer'}).uniq
12
+ scope :submenu, joins(:ui_sections).where(georgia_ui_sections: {name: 'Submenu'}).uniq
13
+ scope :sidebar, joins(:ui_sections).where(georgia_ui_sections: {name: 'Sidebar'}).uniq
14
14
 
15
15
  validate :content_presence
16
16
 
@@ -23,10 +23,8 @@ module Georgia
23
23
  # html << content_tag(:li, link_to_settings) if can?(:settings, page)
24
24
  html << content_tag(:li, link_to_preview) if can?(:preview, page)
25
25
  html << content_tag(:li, link_to_copy) if can?(:copy, page)
26
- if page.current_revision and page.current_revision.published?
27
- html << content_tag(:li, link_to_publish) if can?(:publish, page) and !page.published?
28
- html << content_tag(:li, link_to_unpublish) if can?(:unpublish, page) and page.published?
29
- end
26
+ html << content_tag(:li, link_to_publish) if can?(:publish, page) and !page.published?
27
+ html << content_tag(:li, link_to_unpublish) if can?(:unpublish, page) and page.published?
30
28
  html << content_tag(:li, link_to_flush_cache) if can?(:flush_cache, page)
31
29
  html << content_tag(:li, link_to_revisions) if can?(:index, Revision)
32
30
  html
@@ -21,6 +21,6 @@
21
21
  <span class="badge" title="Featured in <%= pluralize(picture.pages.length, 'page') %>"><%= picture.pages.length %></span>
22
22
  </td>
23
23
  <td class='timestamp'>
24
- <em><%= picture.updated_at.strftime('%F') %></em>
24
+ <em><%= picture.pretty_updated_at %></em>
25
25
  </td>
26
26
  </tr>
@@ -1,13 +1,13 @@
1
1
  <%= simple_form_for @revision, as: :revision, url: [@page.becomes(Georgia::Page), @revision], html: {class: 'form-with-helpers js-spin-and-roll js-revision-form'}, defaults: { input_html: { class: "form-control" } } do |f| %>
2
2
  <%= f.simple_fields_for :contents, @content do |c| %>
3
- <%= c.hidden_field :locale %>
3
+ <%= c.hidden_field :locale, data: {locale: current_locale} %>
4
4
  <header class='header-main'>
5
5
  <div class="header-gutter">
6
6
  <%= link_to_back search_pages_path %>
7
7
  </div>
8
8
  <div class="header-title">
9
9
  <h1>
10
- <%= link_to (@content.title || content_tag(:span, 'No title', class: 'muted')), '#', class: 'title-truncated' %>
10
+ <%= link_to @content.title_or_none, '#', class: 'title-truncated' %>
11
11
  <%= icon_tag 'pencil' %>
12
12
  </h1>
13
13
  <%= c.input_field :title, class: 'input-lg form-control', placeholder: 'Title' %>
@@ -1,20 +1,7 @@
1
1
  <fieldset>
2
2
  <div class="fieldset-help">
3
3
  <legend>Content</legend>
4
- <% if I18n.available_locales.any? %>
5
- <p class="hint">
6
- <div class='dropdown'>
7
- <%= link_to '#', class: 'btn btn-warning', data: {toggle: 'dropdown'}, role: :button do %>
8
- Change language <span class="caret"></span>
9
- <% end -%>
10
- <ul class="dropdown-menu" role="menu">
11
- <% I18n.available_locales.each do |locale| %>
12
- <li><%= link_to t("georgia.#{locale}"), edit_page_revision_path(@page, @revision, locale: locale) %></li>
13
- <% end -%>
14
- </ul>
15
- </div>
16
- </p>
17
- <% end -%>
4
+ <%= link_to_available_locales %>
18
5
  </div>
19
6
  <div class="fieldset-fields">
20
7
  <%= warning_message(@page, @revision) %>
@@ -1 +1 @@
1
- <%= slide_portlet_tag(@slide, content: @slide.content(params[:locale])) %>
1
+ <%= slide_portlet_tag(@slide, content: @content) %>
@@ -1,8 +1,8 @@
1
1
  <div class="col-md-3 js-widget">
2
2
  <div class="widget">
3
3
  <div class="widget-show">
4
- <div class="widget-header"><h4 class='widget-title--ellipsed'><%= widget.title %></h4></div>
5
- <div class="widget-content"><%= widget.text %></div>
4
+ <div class="widget-header"><h4 class='widget-title--ellipsed'><%= widget.content(current_locale).title %></h4></div>
5
+ <div class="widget-content"><%= widget.content(current_locale).text %></div>
6
6
  <div class="widget-footer">
7
7
  <% if widget.featured? %>
8
8
  <div class="widget-featured">
@@ -15,7 +15,8 @@
15
15
  </div>
16
16
  <div class="widget-form hide">
17
17
  <%= simple_form_for widget, remote: true, html: {class: 'js-spin-and-roll'} do |f| %>
18
- <%= f.simple_fields_for :contents, widget.content do |c| %>
18
+ <%= f.simple_fields_for :contents, widget.content(current_locale) do |c| %>
19
+ <%= c.input :locale, as: :hidden %>
19
20
  <div class="widget-header">
20
21
  <div class="widget-title">
21
22
  <%= c.input_field :title, class: 'form-control' %>
@@ -13,6 +13,8 @@
13
13
 
14
14
  <section class="body-main">
15
15
 
16
+ <%= link_to_available_locales %>
17
+
16
18
  <% if @widgets and @widgets.any? %>
17
19
  <% @widgets.each do |widget_row| %>
18
20
  <div class="row">
@@ -1,7 +1,6 @@
1
1
  require "georgia/version"
2
2
  require "georgia/paths"
3
3
  require "georgia/engine"
4
- require "georgia/assets"
5
4
  require "georgia/indexer"
6
5
 
7
6
  module Georgia
@@ -35,6 +35,8 @@ module Georgia
35
35
  helper Georgia::MetaTagsHelper
36
36
  helper Georgia::InternationalizationHelper
37
37
  helper Georgia::MenusHelper
38
+ helper Georgia::UiHelper
39
+ helper Georgia::PagesHelper
38
40
  end
39
41
  end
40
42
 
@@ -1,4 +1,5 @@
1
1
  require 'active_support/concern'
2
+ require 'georgia/indexer/adapter'
2
3
 
3
4
  module Georgia
4
5
  module Indexer
@@ -14,50 +15,19 @@ module Georgia
14
15
  adapter.search model, params
15
16
  end
16
17
 
18
+ def self.register_extension indexer, klass
19
+ return unless indexer == Georgia.indexer
20
+ Adapter.load_extension(klass)
21
+ end
22
+
17
23
  private
18
24
 
19
25
  def self.adapter_lookup
20
26
  @adapter_lookup ||= (case Georgia.indexer
21
27
  when :solr then SolrAdapter
22
28
  when :tire then TireAdapter
23
- else
24
- TireAdapter
25
29
  end)
26
30
  end
27
31
 
28
- module Adapter
29
-
30
- class << self
31
- def included(klass)
32
- extension = Extension.new(klass)
33
- begin
34
- require extension.path
35
- klass.send(:include, extension.name)
36
- rescue => ex
37
- raise "No extension for the #{Georgia.indexer} indexer: #{ex.message}"
38
- end
39
- end
40
-
41
- class Extension
42
- def initialize klass
43
- @klass = klass
44
- end
45
-
46
- def name
47
- name = @klass.to_s.gsub('::', '') + 'Extension'
48
- "#{Georgia::Indexer.adapter}::#{name}".constantize
49
- end
50
-
51
- def path
52
- "georgia/indexer/extensions/#{Georgia.indexer}_adapter/#{filename}"
53
- end
54
-
55
- def filename
56
- @klass.to_s.underscore
57
- end
58
- end
59
- end
60
- end
61
-
62
32
  end
63
33
  end
@@ -0,0 +1,44 @@
1
+ module Georgia
2
+ module Indexer
3
+ module Adapter
4
+
5
+ class << self
6
+
7
+ def included(klass)
8
+ load_extension(klass)
9
+ end
10
+
11
+ def load_extension(klass)
12
+ extension = Extension.new(klass)
13
+ begin
14
+ require extension.path
15
+ klass.send(:include, extension.name)
16
+ rescue => ex
17
+ raise "No extension for the #{Georgia.indexer} indexer: #{ex.message}"
18
+ end
19
+ end
20
+
21
+ class Extension
22
+
23
+ def initialize klass
24
+ @klass = klass
25
+ end
26
+
27
+ def name
28
+ name = @klass.to_s.gsub('::', '') + 'Extension'
29
+ "#{Georgia::Indexer.adapter}::#{name}".constantize
30
+ end
31
+
32
+ def path
33
+ "georgia/indexer/extensions/#{Georgia.indexer}_adapter/#{filename}"
34
+ end
35
+
36
+ def filename
37
+ @klass.to_s.underscore
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end