fix various namespace errors issues and api changes for the models

This commit is contained in:
did 2011-11-10 13:41:20 -08:00
parent 6122983835
commit bef9dd8e67
19 changed files with 88 additions and 25 deletions

View File

@ -157,7 +157,7 @@ div#flash-notice {
text-align: right;
input[type=submit] {
input[type=submit], a.button {
@include black-button;
margin: 0 18px 0 0;

View File

@ -17,7 +17,7 @@ module Locomotive
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
helper Locomotive::BaseHelper, Locomotive::ContentTypesHelper #, Locomotive::BoxHelper

View File

@ -7,6 +7,8 @@ module Locomotive
before_filter :allow_installation?
helper Locomotive::BaseHelper
def show
request.get? ? self.handle_get : self.handle_post
end
@ -62,9 +64,9 @@ module Locomotive
def last_url
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
session_url
locomotive_account_session_url
end
end

View File

@ -16,15 +16,15 @@ module Locomotive
end
def create
@page = Page.create(params[:page])
respond_with @page
@page = current_site.pages.create(params[:page])
respond_with @page, :location => edit_page_url(@page._id)
end
def update
@page = Page.find(params[:id])
@page = current_site.pages.find(params[:id])
@page.update_attributes(params[:page])
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
render :json => {
:notice => t('flash.locomotive.pages.update.notice'),
@ -35,17 +35,22 @@ module Locomotive
end
end
def destroy
@page = current_site.pages.find(params[:id])
@page.destroy
respond_with @page
end
def sort
@page = current_site.pages.find(params[:id])
@page.sort_children!(params[:children])
respond_with @page
end
def get_path
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

View File

@ -83,4 +83,13 @@ module Locomotive::BaseHelper
Locomotive.config.multi_sites?
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

View 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

View File

@ -1,8 +1,8 @@
module Locomotive
class Asset
include Mongoid::Document
include Mongoid::Timestamps
include ::Mongoid::Document
include ::Mongoid::Timestamps
## extensions ##
include Extensions::Asset::Types
@ -14,7 +14,7 @@ module Locomotive
field :height, :type => Integer
field :size, :type => Integer
field :position, :type => Integer, :default => 0
mount_uploader :source, AssetUploader
mount_uploader :source, AssetUploader, :mount_on => :source_filename
## associations ##
referenced_in :site, :class_name => 'Locomotive::Site'

View File

@ -1,8 +1,8 @@
module Locomotive
class ContentInstance
include Mongoid::Document
include Mongoid::Timestamps
include ::Mongoid::Document
include ::Mongoid::Timestamps
## extensions ##
include CustomFields::ProxyClassEnabler

View File

@ -1,7 +1,7 @@
module Locomotive
class EditableElement
include Mongoid::Document
include ::Mongoid::Document
## fields ##
field :slug

View File

@ -1,7 +1,7 @@
module Locomotive
class EditableFile < EditableElement
mount_uploader :source, EditableFileUploader
mount_uploader :source, EditableFileUploader, :mount_on => :source_filename
def content
self.source? ? self.source.url : self.default_content

View File

@ -1,4 +1,4 @@
module
module Locomotive
class Snippet
include Locomotive::Mongoid::Document

View File

@ -13,7 +13,7 @@ module Locomotive
field :height, :type => Integer
field :size, :type => Integer
field :folder, :default => nil
mount_uploader :source, ThemeAssetUploader
mount_uploader :source, ThemeAssetUploader, :mount_on => :source_filename
## associations ##
referenced_in :site, :class_name => 'Locomotive::Site'

View File

@ -1,7 +1,7 @@
# encoding: utf-8
module Locomotive
class AssetUploader < CarrierWave::Uploader::Base
class AssetUploader < ::CarrierWave::Uploader::Base
include Locomotive::CarrierWave::Uploader::Asset

View File

@ -1,7 +1,7 @@
# encoding: utf-8
module Locomotive
class ThemeAssetUploader < CarrierWave::Uploader::Base
class ThemeAssetUploader < ::CarrierWave::Uploader::Base
include Locomotive::CarrierWave::Uploader::Asset

View File

@ -2,7 +2,7 @@
= t('locomotive.installation.common.title')
- content_for :head do
= stylesheet_link_tag 'locomotive_installation', :media => 'screen'
= stylesheet_link_tag 'locomotive/installation', :media => 'screen'
- title t('.title')

View File

@ -7,7 +7,7 @@
- if not @page.index? and not @page.not_found?
= 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

View File

@ -1,5 +1,8 @@
# encoding: utf-8
## String
class String
class String #:nodoc
def permalink
self.parameterize('-')
@ -15,7 +18,7 @@ end
## Hash
class Hash
class Hash #:nodoc
def underscore_keys
new_hash = {}
@ -43,4 +46,19 @@ class Hash
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

View File

@ -8,6 +8,28 @@ module Locomotive
super || has_errors?
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
if get?
display resource