fullstack-cms 0.1.17 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -15,6 +15,7 @@ gem "whenever"
15
15
  gem 'rinku', '~> 1.2.2', :require => 'rails_rinku'
16
16
 
17
17
  gem 'bluecloth'
18
+ # gem 'i18n_fields'
18
19
 
19
20
  group :development do
20
21
  gem "jeweler"
data/TODO.tasks ADDED
@@ -0,0 +1,14 @@
1
+ # Fullstack CMS roadmap
2
+
3
+ - integrate with globalize
4
+ ✓ release ARS with right migration file names
5
+ ✓ fix long index names issue
6
+ ✓ pack into a gem and release
7
+ - require the packed gem
8
+ - use :translatable for `page_parts`
9
+ - available languages with switch into UI
10
+
11
+ - Linkables/Related
12
+
13
+ - statistics
14
+ - RSS
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.17
1
+ 0.2.1
@@ -0,0 +1,35 @@
1
+ class Admin::LinkablesController < Admin::BaseController
2
+ layout false
3
+
4
+ def index
5
+ term = params[:term]
6
+ type = params[:type]
7
+
8
+ resp = {}
9
+ if term && term.size > 3 && (linkable = Linkable.get(type))
10
+
11
+ column = :"#{title_column(linkable)}"
12
+
13
+ linkable.where(
14
+
15
+ linkable.arel_table[column].matches("%#{term}%")
16
+
17
+ ).select([:id, column]).each do |l|
18
+ resp[l.id] = l.send(column)
19
+
20
+ end
21
+ end
22
+ render :json => resp
23
+
24
+ end
25
+
26
+ def fields
27
+ @linkable = Linkable.get(params[:type])
28
+ @target = params[:target]
29
+ @field_name = params[:field_name]
30
+ if params[:current_type].present? && params[:current_id].present?
31
+ @currently_linked = Linkable.get(params[:current_type]).find(params[:current_id])
32
+ end
33
+ end
34
+
35
+ end
@@ -4,12 +4,7 @@ class Attachment < ActiveRecord::Base
4
4
 
5
5
  field :description, :text
6
6
  has_attached :file
7
-
8
- # validates_attachment :file, :presence => true,
9
- # :size => { :in => 0..1000.megabytes }
10
-
11
7
  belongs_to :attachable, :polymorphic => true
12
- attr_accessible :name, :description, :file, :attachable, :attachable_id, :attachable_type, :title
13
8
  end
14
9
 
15
10
 
data/app/models/link.rb CHANGED
@@ -1,19 +1,18 @@
1
1
  class Link < ActiveRecord::Base
2
2
  validates_presence_of :label
3
3
 
4
- field :label, :string
5
- field :description, :text
4
+ field :label, :string, :translatable => true
5
+ field :description, :text, :translatable => true
6
6
  field :position, :integer
7
7
 
8
8
  has_attached :image
9
9
  has_attached :icon
10
10
 
11
11
  belongs_to :link_owner, :polymorphic => true
12
+ belongs_to :linked, :polymorphic => true
12
13
 
13
14
  timestamps
14
- field :external, :boolean
15
15
  field :nofollow, :boolean
16
16
  field :url, :string
17
- field :alignment_right, :boolean, :default => :false
18
- alias_attribute :right_alignment, :alignment_right
17
+
19
18
  end
@@ -0,0 +1,31 @@
1
+ class Linkable
2
+
3
+ AJAX_COMBOBOX_MIN = 5
4
+
5
+ class << self
6
+
7
+ def linkables
8
+ @linkables ||= Fullstack::Cms.config.linkables.map {|class_name|
9
+ class_name.is_a?(Class) ? class_name.name.underscore : class_name.to_s.underscore.singularize
10
+ }
11
+ end
12
+
13
+ def linkable_class_names
14
+ @linkable_class_names ||= linkables.map {|l|
15
+ l.is_a?(Class) ? l.name : l.to_s.camelize
16
+ }
17
+ end
18
+
19
+ def get(class_name)
20
+ @_linkables_flyweight ||= {}
21
+ underscored_name = class_name.is_a?(Class) ? class_name.name.underscore : class_name.to_s.underscore.singularize
22
+ if linkables.include?(underscored_name)
23
+ @_linkables_flyweight[underscored_name] || (@_linkables_flyweight[underscored_name] = class_name.is_a?(Class) ? class_name : "#{class_name}".camelize.constantize)
24
+ end
25
+ end
26
+
27
+ end
28
+ end
29
+
30
+
31
+
data/app/models/photo.rb CHANGED
@@ -14,7 +14,7 @@ class Photo < ActiveRecord::Base
14
14
  belongs_to :photographable, :polymorphic => :true
15
15
  delegate :url, :file_name, :to => :image
16
16
 
17
- field :caption, :text
17
+ field :caption, :text, :translatable => true
18
18
 
19
19
  def owner
20
20
  photographable.owner if photographable && photographable.respond_to?(:owner)
@@ -10,12 +10,12 @@ class Setting < ActiveRecord::Base
10
10
  field :kind
11
11
  field :group
12
12
 
13
- field :integer_value, :integer
14
- field :float_value, :float
15
- field :text_value, :text
16
- field :string_value, :string
17
- field :datetime_value, :datetime
18
- field :date_value, :date
13
+ field :integer_value, :integer, :translatable => true
14
+ field :float_value, :float, :translatable => true
15
+ field :text_value, :text, :translatable => true
16
+ field :string_value, :string, :translatable => true
17
+ field :datetime_value, :datetime, :translatable => true
18
+ field :date_value, :date, :translatable => true
19
19
  has_attached :file_value
20
20
 
21
21
 
data/app/models/text.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  class Text < ActiveRecord::Base
2
2
  include Content
3
- field :text, :text, :markup => true
3
+ field :text, :text, :markup => true, :translatable => true
4
4
  has_many :attachments, :as => :attachable
5
5
  accepts_nested_attributes_for :attachments
6
6
  end
@@ -1,3 +1,3 @@
1
1
  class TextPagePart < PagePart
2
- field :text, :text, :markup => true
2
+ field :text, :text, :markup => true, :translatable => true
3
3
  end
@@ -1,4 +1,4 @@
1
1
  class TextWithTitlePagePart < PagePart
2
- field :title, :string
3
- field :text, :text, :markup => true
2
+ field :title, :string, :translatable => true
3
+ field :text, :text, :markup => true, :translatable => true
4
4
  end
@@ -0,0 +1,26 @@
1
+ <% if linkable.count >= Linkable::AJAX_COMBOBOX_MIN %>
2
+ <div class="clearfix" style="margin-bottom: 200px;">
3
+
4
+ <select style="width: 440px;" data-remote="<%= admin_linkables_path(:type => linkable.name) %>" class="select-resource-url" name="<%= field_name %>"
5
+ placeholder="<%= t('fullstack.cms.type_the_title_name_of_the_resource_to_link', :default => 'Type the title/name of the resource to link') %>">
6
+ <option value=""></option>
7
+ <% if currently_linked %>
8
+ <option value="<%= currently_linked.id %>" selected><%= title_for(currently_linked) %></option>
9
+ <% end %>
10
+ </select>
11
+
12
+ </div>
13
+ <% else %>
14
+ <select style="width: 440px;" name="<%= field_name %>"
15
+ placeholder="<%= t('fullstack.cms.type_the_title_name_of_the_resource_to_link', :default => 'Type the title/name of the resource to link') %>">
16
+
17
+ <option value=""></option>
18
+ <% linkable.order(title_column(linkable)).each do |item| %>
19
+ <% if currently_linked == item %>
20
+ <option value="<%= item.id %>" selected><%= title_for(item) %></option>
21
+ <% else %>
22
+ <option value="<%= item.id %>"><%= title_for(item) %></option>
23
+ <% end %>
24
+ <% end %>
25
+ </select>
26
+ <% end %>
@@ -0,0 +1,13 @@
1
+ $("#<%= @target %>").empty().append("<%=j render(:partial => 'fields', :locals => {:linkable => @linkable, :field_name => @field_name, :currently_linked => @currently_linked}) %>")
2
+
3
+ <% if @linkable.count >= Linkable::AJAX_COMBOBOX_MIN %>
4
+ $("#<%= @target %>").find("select[data-remote]").each ->
5
+ $(this).ajaxChosen {method: "GET", url:$(this).data('remote'), dataType: 'json'}, (data) ->
6
+ data
7
+ <% else %>
8
+ $("select:not([data-remote]):not(.datetime-selector)").chosen()
9
+ <% end %>
10
+
11
+ # localize messages and labels
12
+ # get rid of the black screen after window closing
13
+ # double add problem
@@ -0,0 +1,78 @@
1
+ <%= f.inputs do %>
2
+ <%= f.input :label %>
3
+ <%= f.input :description %>
4
+ <%= f.input :nofollow %>
5
+ <% end %>
6
+ <%= f.inputs do %>
7
+ <%= f.input :image %>
8
+ <%= f.input :icon %>
9
+ <% end %>
10
+
11
+ <hr/>
12
+
13
+ <%= f.inputs :class => "linked-fields" do %>
14
+ <%
15
+ linkables_collection = [[t('fullstack.cms.url', :default => "Url"), ""]] + Linkable.linkable_class_names.map do |klass_name|
16
+ [t("fullstack.admin.resources.#{klass_name.underscore}", :default => klass_name), klass_name]
17
+ end
18
+ %>
19
+ <%= f.input :linked_type, :as => :radio, :collection => linkables_collection, :input_html => {:class => "linked-type-field"},
20
+ :label => t('fullstack.cms.link_resource_or_url', :default => "Link resource or url")
21
+ %>
22
+ <div class="linked-id-field-placeholder" id="linked_id_field_placeholder_<%= @linked_id_field_placeholder_uid = 1 + (@linked_id_field_placeholder_uid || 0)
23
+ %>" data-current-id="<%= f.object.linked_id %>" data-current-type="<%= f.object.linked_type %>">
24
+ </div>
25
+ <%= f.input :url, :label => false, :input_html => {:style => "display: none", :class => "linked-url-field"} %>
26
+ <% end %>
27
+
28
+
29
+ <% unless @link_associated_fields_js_included %>
30
+ <% @link_associated_fields_js_included = true %>
31
+
32
+ <% content_for :javascripts do -%>
33
+
34
+
35
+ <%= javascript_tag do %>
36
+ <%= coffee_script do %>
37
+
38
+ $(document).ready ->
39
+
40
+ update_linked_fields = (linked_fields) ->
41
+ linked_type_field = linked_fields.find(".linked-type-field")
42
+ checked_linked_type_field = linked_fields.find(".linked-type-field:checked")
43
+ linked_id_field_placeholder = linked_fields.find(".linked-id-field-placeholder")
44
+ linked_url_field = linked_fields.find(".linked-url-field")
45
+
46
+ linked_type = checked_linked_type_field.val()
47
+
48
+ target_id = linked_id_field_placeholder.attr("id")
49
+ linked_id_field_name = linked_type_field.attr("name").replace(/linked_type\]$/, "linked_id]")
50
+
51
+
52
+ if linked_type
53
+ $.get '<%= fields_admin_linkables_path %>',
54
+ type: linked_type
55
+ target: target_id
56
+ field_name: linked_id_field_name
57
+ current_type: linked_id_field_placeholder.data("current-type")
58
+ current_id: linked_id_field_placeholder.data("current-id")
59
+ linked_url_field.hide()
60
+
61
+ else
62
+ linked_id_field_placeholder.empty()
63
+ linked_url_field.show()
64
+
65
+ $(".linked-fields").each ->
66
+ linked_fields = $(@)
67
+ update_linked_fields(linked_fields)
68
+ linked_fields.find(".linked-type-field").live "change", ->
69
+ update_linked_fields(linked_fields)
70
+
71
+ <% end %>
72
+ <% end %>
73
+ <% end -%>
74
+
75
+ <% end %>
76
+
77
+
78
+
@@ -8,7 +8,7 @@
8
8
  <% if @photo.respond_to?(:tags) %>
9
9
  <%= f.input :tag_list, :as => :tags, :autocomplete => admin_tags_path, :input_html => {:id => "edit_tags_for_photo"} %>
10
10
 
11
- <script type="text/javascript" charset="utf-8">
11
+ <script type="text/javascript">
12
12
 
13
13
  $("#edit_tags_for_photo").each(function() {
14
14
  var autocomplete_url, defaultText, taglist;
@@ -2,6 +2,9 @@ it:
2
2
  fullstack:
3
3
  cms:
4
4
  advanced_settings: "Impostazioni avanzate"
5
+ link_resource_or_url: "Collega una risorsa o un indirizzo"
6
+ type_the_title_name_of_the_resource_to_link: "Digita il titolo/nome della risorsa da collegare"
7
+ url: "Indirizzo"
5
8
  admin:
6
9
  groups:
7
10
  global: "Generale"
data/config/routes.rb CHANGED
@@ -5,6 +5,9 @@ Rails.application.routes.draw do
5
5
 
6
6
  resources :tags, :only => :index, :format => :json
7
7
  resources :users, :except => [:show]
8
+ resources :linkables, :only => :index, :format => :json do
9
+ get "fields", :format => :js, :on => :collection
10
+ end
8
11
 
9
12
  resources :photos, :except => [:new, :index, :show, :create] do
10
13
  get "search", :on => :collection
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "fullstack-cms"
8
- s.version = "0.1.17"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["mcasimir"]
12
- s.date = "2012-08-23"
12
+ s.date = "2012-08-30"
13
13
  s.description = "CMS system built on fullstack"
14
14
  s.email = "maurizio.cas@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -20,8 +20,9 @@ Gem::Specification.new do |s|
20
20
  "Gemfile.lock",
21
21
  "README.md",
22
22
  "Rakefile",
23
- "TODO.md",
23
+ "TODO.tasks",
24
24
  "VERSION",
25
+ "app/controllers/admin/linkables_controller.rb",
25
26
  "app/controllers/admin/menus_controller.rb",
26
27
  "app/controllers/admin/pages_controller.rb",
27
28
  "app/controllers/admin/photos_controller.rb",
@@ -37,6 +38,7 @@ Gem::Specification.new do |s|
37
38
  "app/models/.gitkeep",
38
39
  "app/models/attachment.rb",
39
40
  "app/models/link.rb",
41
+ "app/models/linkable.rb",
40
42
  "app/models/menu.rb",
41
43
  "app/models/nestable.rb",
42
44
  "app/models/page.rb",
@@ -51,6 +53,9 @@ Gem::Specification.new do |s|
51
53
  "app/views/admin/base/_fields.html.erb",
52
54
  "app/views/admin/base/_form.html.erb",
53
55
  "app/views/admin/base/_simple_form.html.erb",
56
+ "app/views/admin/linkables/_fields.html.erb",
57
+ "app/views/admin/linkables/fields.js.coffee",
58
+ "app/views/admin/links/_associated_fields.html.erb",
54
59
  "app/views/admin/pages/_collection.html.erb",
55
60
  "app/views/admin/pages/_form.html.erb",
56
61
  "app/views/admin/photos/_photo.html.erb",
data/lib/fullstack/cms.rb CHANGED
@@ -37,7 +37,7 @@ require "whenever"
37
37
  require 'fullstack/cms/engine'
38
38
  require 'fullstack/cms/configuration'
39
39
  require 'bluecloth'
40
-
40
+ # require 'i18n_fields'
41
41
 
42
42
  module Fullstack
43
43
  module Cms
@@ -52,7 +52,7 @@ eos
52
52
  '''
53
53
 
54
54
  route '''
55
- constraints(:host => /#{Regexp.escape(Settings.app.domain)}/) do
55
+ constraints(:host => /^#{Regexp.escape(Settings.app.domain)}/) do
56
56
  root :to => redirect("http://www.#{Settings.app.domain}")
57
57
  match \'/*path\', :to => redirect {|params| "http://www.#{Settings.app.domain}/#{params[:path]}"}
58
58
  end
@@ -8,8 +8,8 @@ module Content
8
8
  alias :keywords :tags
9
9
  permalink :title, :history => true
10
10
 
11
- field :title
12
- field :excerpt, :as => :text
11
+ field :title, :translatable => true
12
+ field :excerpt, :as => :text, :translatable => true
13
13
  alias_attribute :description, :excerpt
14
14
  end
15
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fullstack-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.17
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-23 00:00:00.000000000 Z
12
+ date: 2012-08-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fullstack
@@ -230,8 +230,9 @@ files:
230
230
  - Gemfile.lock
231
231
  - README.md
232
232
  - Rakefile
233
- - TODO.md
233
+ - TODO.tasks
234
234
  - VERSION
235
+ - app/controllers/admin/linkables_controller.rb
235
236
  - app/controllers/admin/menus_controller.rb
236
237
  - app/controllers/admin/pages_controller.rb
237
238
  - app/controllers/admin/photos_controller.rb
@@ -247,6 +248,7 @@ files:
247
248
  - app/models/.gitkeep
248
249
  - app/models/attachment.rb
249
250
  - app/models/link.rb
251
+ - app/models/linkable.rb
250
252
  - app/models/menu.rb
251
253
  - app/models/nestable.rb
252
254
  - app/models/page.rb
@@ -261,6 +263,9 @@ files:
261
263
  - app/views/admin/base/_fields.html.erb
262
264
  - app/views/admin/base/_form.html.erb
263
265
  - app/views/admin/base/_simple_form.html.erb
266
+ - app/views/admin/linkables/_fields.html.erb
267
+ - app/views/admin/linkables/fields.js.coffee
268
+ - app/views/admin/links/_associated_fields.html.erb
264
269
  - app/views/admin/pages/_collection.html.erb
265
270
  - app/views/admin/pages/_form.html.erb
266
271
  - app/views/admin/photos/_photo.html.erb
@@ -339,7 +344,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
339
344
  version: '0'
340
345
  segments:
341
346
  - 0
342
- hash: -2096079904173300091
347
+ hash: 1880743011061210640
343
348
  required_rubygems_version: !ruby/object:Gem::Requirement
344
349
  none: false
345
350
  requirements:
data/TODO.md DELETED
@@ -1,4 +0,0 @@
1
- # Fullstack CMS roadmap
2
-
3
- - fix photo delete not removing thumbnail on success
4
-