fix various namespace errors issues and api changes for the models
This commit is contained in:
parent
6122983835
commit
bef9dd8e67
@ -157,7 +157,7 @@ div#flash-notice {
|
|||||||
|
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
|
||||||
input[type=submit] {
|
input[type=submit], a.button {
|
||||||
@include black-button;
|
@include black-button;
|
||||||
|
|
||||||
margin: 0 18px 0 0;
|
margin: 0 18px 0 0;
|
||||||
|
@ -17,7 +17,7 @@ module Locomotive
|
|||||||
|
|
||||||
before_filter :set_current_thread_variables
|
before_filter :set_current_thread_variables
|
||||||
|
|
||||||
helper_method :sections, :current_site_url, :site_url, :page_url, :current_ability
|
helper_method :sections, :current_site_url, :site_url, :public_page_url, :current_ability
|
||||||
|
|
||||||
# https://rails.lighthouseapp.com/projects/8994/tickets/1905-apphelpers-within-plugin-not-being-mixed-in
|
# https://rails.lighthouseapp.com/projects/8994/tickets/1905-apphelpers-within-plugin-not-being-mixed-in
|
||||||
helper Locomotive::BaseHelper, Locomotive::ContentTypesHelper #, Locomotive::BoxHelper
|
helper Locomotive::BaseHelper, Locomotive::ContentTypesHelper #, Locomotive::BoxHelper
|
||||||
|
@ -7,6 +7,8 @@ module Locomotive
|
|||||||
|
|
||||||
before_filter :allow_installation?
|
before_filter :allow_installation?
|
||||||
|
|
||||||
|
helper Locomotive::BaseHelper
|
||||||
|
|
||||||
def show
|
def show
|
||||||
request.get? ? self.handle_get : self.handle_post
|
request.get? ? self.handle_get : self.handle_post
|
||||||
end
|
end
|
||||||
@ -62,9 +64,9 @@ module Locomotive
|
|||||||
|
|
||||||
def last_url
|
def last_url
|
||||||
if Locomotive.config.manage_domains?
|
if Locomotive.config.manage_domains?
|
||||||
session_url(:host => Site.first.domains.first, :port => request.port)
|
locomotive_account_session_url(:host => Site.first.domains.first, :port => request.port)
|
||||||
else
|
else
|
||||||
session_url
|
locomotive_account_session_url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -16,15 +16,15 @@ module Locomotive
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@page = Page.create(params[:page])
|
@page = current_site.pages.create(params[:page])
|
||||||
respond_with @page
|
respond_with @page, :location => edit_page_url(@page._id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@page = Page.find(params[:id])
|
@page = current_site.pages.find(params[:id])
|
||||||
@page.update_attributes(params[:page])
|
@page.update_attributes(params[:page])
|
||||||
respond_with @page do |format|
|
respond_with @page do |format|
|
||||||
format.html { redirect_to edit_page_url(@page) }
|
format.html { redirect_to edit_page_url(@page._id) }
|
||||||
format.json do
|
format.json do
|
||||||
render :json => {
|
render :json => {
|
||||||
:notice => t('flash.locomotive.pages.update.notice'),
|
:notice => t('flash.locomotive.pages.update.notice'),
|
||||||
@ -35,17 +35,22 @@ module Locomotive
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@page = current_site.pages.find(params[:id])
|
||||||
|
@page.destroy
|
||||||
|
respond_with @page
|
||||||
|
end
|
||||||
|
|
||||||
def sort
|
def sort
|
||||||
@page = current_site.pages.find(params[:id])
|
@page = current_site.pages.find(params[:id])
|
||||||
@page.sort_children!(params[:children])
|
@page.sort_children!(params[:children])
|
||||||
|
|
||||||
respond_with @page
|
respond_with @page
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_path
|
def get_path
|
||||||
page = current_site.pages.build(:parent => current_site.pages.find(params[:parent_id]), :slug => params[:slug].permalink)
|
page = current_site.pages.build(:parent => current_site.pages.find(params[:parent_id]), :slug => params[:slug].permalink)
|
||||||
|
|
||||||
render :json => { :url => page_url(page), :slug => page.slug }
|
render :json => { :url => public_page_url(page), :slug => page.slug }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -83,4 +83,13 @@ module Locomotive::BaseHelper
|
|||||||
Locomotive.config.multi_sites?
|
Locomotive.config.multi_sites?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def public_page_url(page, options = {})
|
||||||
|
if content = options.delete(:content)
|
||||||
|
File.join(current_site_url, page.fullpath.gsub('content_type_template', ''), content._slug)
|
||||||
|
else
|
||||||
|
File.join(current_site_url, page.fullpath)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
7
app/helpers/locomotive/installation_helper.rb
Normal file
7
app/helpers/locomotive/installation_helper.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
module Locomotive::InstallationHelper
|
||||||
|
|
||||||
|
def next_installation_step_link(step = 1, label = nil)
|
||||||
|
link_to(content_tag(:span, label || t('admin.installation.common.next')), installation_step_url(step), :class => 'button')
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -1,8 +1,8 @@
|
|||||||
module Locomotive
|
module Locomotive
|
||||||
class Asset
|
class Asset
|
||||||
|
|
||||||
include Mongoid::Document
|
include ::Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include ::Mongoid::Timestamps
|
||||||
|
|
||||||
## extensions ##
|
## extensions ##
|
||||||
include Extensions::Asset::Types
|
include Extensions::Asset::Types
|
||||||
@ -14,7 +14,7 @@ module Locomotive
|
|||||||
field :height, :type => Integer
|
field :height, :type => Integer
|
||||||
field :size, :type => Integer
|
field :size, :type => Integer
|
||||||
field :position, :type => Integer, :default => 0
|
field :position, :type => Integer, :default => 0
|
||||||
mount_uploader :source, AssetUploader
|
mount_uploader :source, AssetUploader, :mount_on => :source_filename
|
||||||
|
|
||||||
## associations ##
|
## associations ##
|
||||||
referenced_in :site, :class_name => 'Locomotive::Site'
|
referenced_in :site, :class_name => 'Locomotive::Site'
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
module Locomotive
|
module Locomotive
|
||||||
class ContentInstance
|
class ContentInstance
|
||||||
|
|
||||||
include Mongoid::Document
|
include ::Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include ::Mongoid::Timestamps
|
||||||
|
|
||||||
## extensions ##
|
## extensions ##
|
||||||
include CustomFields::ProxyClassEnabler
|
include CustomFields::ProxyClassEnabler
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
module Locomotive
|
module Locomotive
|
||||||
class EditableElement
|
class EditableElement
|
||||||
|
|
||||||
include Mongoid::Document
|
include ::Mongoid::Document
|
||||||
|
|
||||||
## fields ##
|
## fields ##
|
||||||
field :slug
|
field :slug
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
module Locomotive
|
module Locomotive
|
||||||
class EditableFile < EditableElement
|
class EditableFile < EditableElement
|
||||||
|
|
||||||
mount_uploader :source, EditableFileUploader
|
mount_uploader :source, EditableFileUploader, :mount_on => :source_filename
|
||||||
|
|
||||||
def content
|
def content
|
||||||
self.source? ? self.source.url : self.default_content
|
self.source? ? self.source.url : self.default_content
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module
|
module Locomotive
|
||||||
class Snippet
|
class Snippet
|
||||||
|
|
||||||
include Locomotive::Mongoid::Document
|
include Locomotive::Mongoid::Document
|
||||||
|
@ -13,7 +13,7 @@ module Locomotive
|
|||||||
field :height, :type => Integer
|
field :height, :type => Integer
|
||||||
field :size, :type => Integer
|
field :size, :type => Integer
|
||||||
field :folder, :default => nil
|
field :folder, :default => nil
|
||||||
mount_uploader :source, ThemeAssetUploader
|
mount_uploader :source, ThemeAssetUploader, :mount_on => :source_filename
|
||||||
|
|
||||||
## associations ##
|
## associations ##
|
||||||
referenced_in :site, :class_name => 'Locomotive::Site'
|
referenced_in :site, :class_name => 'Locomotive::Site'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
module Locomotive
|
module Locomotive
|
||||||
class AssetUploader < CarrierWave::Uploader::Base
|
class AssetUploader < ::CarrierWave::Uploader::Base
|
||||||
|
|
||||||
include Locomotive::CarrierWave::Uploader::Asset
|
include Locomotive::CarrierWave::Uploader::Asset
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
module Locomotive
|
module Locomotive
|
||||||
class ThemeAssetUploader < CarrierWave::Uploader::Base
|
class ThemeAssetUploader < ::CarrierWave::Uploader::Base
|
||||||
|
|
||||||
include Locomotive::CarrierWave::Uploader::Asset
|
include Locomotive::CarrierWave::Uploader::Asset
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
= t('locomotive.installation.common.title')
|
= t('locomotive.installation.common.title')
|
||||||
|
|
||||||
- content_for :head do
|
- content_for :head do
|
||||||
= stylesheet_link_tag 'locomotive_installation', :media => 'screen'
|
= stylesheet_link_tag 'locomotive/installation', :media => 'screen'
|
||||||
|
|
||||||
- title t('.title')
|
- title t('.title')
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
- if not @page.index? and not @page.not_found?
|
- if not @page.index? and not @page.not_found?
|
||||||
= f.input :parent_id, :as => :select, :collection => parent_pages_options, :include_blank => false
|
= f.input :parent_id, :as => :select, :collection => parent_pages_options, :include_blank => false
|
||||||
|
|
||||||
= f.input :slug, :required => false, :hint => @page.slug.blank? ? t('.empty_slug') : page_url(@page), :input_html => { :'data-url' => get_path_pages_url, :disabled => @page.index? || @page.not_found? }, :wrapper_html => { :style => "#{'display: none' if @page.templatized?};" }
|
= f.input :slug, :required => false, :hint => @page.slug.blank? ? t('.empty_slug') : public_page_url(@page), :input_html => { :'data-url' => get_path_pages_url, :disabled => @page.index? || @page.not_found? }, :wrapper_html => { :style => "#{'display: none' if @page.templatized?};" }
|
||||||
|
|
||||||
= render 'editable_elements', :page => @page
|
= render 'editable_elements', :page => @page
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
## String
|
## String
|
||||||
class String
|
|
||||||
|
class String #:nodoc
|
||||||
|
|
||||||
def permalink
|
def permalink
|
||||||
self.parameterize('-')
|
self.parameterize('-')
|
||||||
@ -15,7 +18,7 @@ end
|
|||||||
|
|
||||||
## Hash
|
## Hash
|
||||||
|
|
||||||
class Hash
|
class Hash #:nodoc
|
||||||
|
|
||||||
def underscore_keys
|
def underscore_keys
|
||||||
new_hash = {}
|
new_hash = {}
|
||||||
@ -43,4 +46,19 @@ class Hash
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Boolean #:nodoc
|
||||||
|
BOOLEAN_MAP = {
|
||||||
|
true => true, "true" => true, "TRUE" => true, "1" => true, 1 => true, 1.0 => true,
|
||||||
|
false => false, "false" => false, "FALSE" => false, "0" => false, 0 => false, 0.0 => false
|
||||||
|
}
|
||||||
|
|
||||||
|
def self.set(value)
|
||||||
|
value = BOOLEAN_MAP[value]
|
||||||
|
value.nil? ? nil : value
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.get(value)
|
||||||
|
value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@ -8,6 +8,28 @@ module Locomotive
|
|||||||
super || has_errors?
|
super || has_errors?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def api_behavior(error)
|
||||||
|
puts "api_behavior here"
|
||||||
|
|
||||||
|
super
|
||||||
|
|
||||||
|
puts "api_behavior there"
|
||||||
|
end
|
||||||
|
|
||||||
|
# def api_behavior(error)
|
||||||
|
# raise error unless resourceful?
|
||||||
|
#
|
||||||
|
# if get?
|
||||||
|
# display resource
|
||||||
|
# elsif post?
|
||||||
|
# display resource, :status => :created, :location => api_location
|
||||||
|
# elsif has_empty_resource_definition?
|
||||||
|
# display empty_resource, :status => :ok
|
||||||
|
# else
|
||||||
|
# head :ok
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
def to_json
|
def to_json
|
||||||
if get?
|
if get?
|
||||||
display resource
|
display resource
|
||||||
|
Loading…
Reference in New Issue
Block a user