Compare commits
4 Commits
master
...
subdirecto
Author | SHA1 | Date | |
---|---|---|---|
|
33b3e5a600 | ||
|
60cb10c4ca | ||
|
07e37d0521 | ||
|
07f868594a |
@ -22,26 +22,31 @@ module Locomotive
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
@content_entry = @content_type.entries.find(params[:id])
|
@content_entry = @content_type.entries.find(params[:id])
|
||||||
|
authorize! params[:action].to_sym, @content_entry
|
||||||
respond_with @content_entry
|
respond_with @content_entry
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@content_entry = @content_type.entries.build
|
@content_entry = @content_type.entries.build
|
||||||
|
authorize! params[:action].to_sym, @content_entry
|
||||||
respond_with @content_entry
|
respond_with @content_entry
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@content_entry = @content_type.entries.create(params[:content_entry])
|
@content_entry = @content_type.entries.create(params[:content_entry])
|
||||||
|
authorize! params[:action].to_sym, @content_entry
|
||||||
respond_with @content_entry, :location => edit_content_entry_url(@content_type.slug, @content_entry._id)
|
respond_with @content_entry, :location => edit_content_entry_url(@content_type.slug, @content_entry._id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@content_entry = @content_type.entries.find(params[:id])
|
@content_entry = @content_type.entries.find(params[:id])
|
||||||
|
authorize! params[:action].to_sym, @content_entry
|
||||||
respond_with @content_entry
|
respond_with @content_entry
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@content_entry = @content_type.entries.find(params[:id])
|
@content_entry = @content_type.entries.find(params[:id])
|
||||||
|
authorize! params[:action].to_sym, @content_entry
|
||||||
@content_entry.update_attributes(params[:content_entry])
|
@content_entry.update_attributes(params[:content_entry])
|
||||||
respond_with @content_entry, :location => edit_content_entry_url(@content_type.slug, @content_entry._id)
|
respond_with @content_entry, :location => edit_content_entry_url(@content_type.slug, @content_entry._id)
|
||||||
end
|
end
|
||||||
@ -51,8 +56,10 @@ module Locomotive
|
|||||||
respond_with @content_type
|
respond_with @content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@content_entry = @content_type.entries.find(params[:id])
|
@content_entry = @content_type.entries.find(params[:id])
|
||||||
|
authorize! params[:action].to_sym, @content_entry
|
||||||
@content_entry.destroy
|
@content_entry.destroy
|
||||||
respond_with @content_entry, :location => content_entries_url(@content_type.slug)
|
respond_with @content_entry, :location => content_entries_url(@content_type.slug)
|
||||||
end
|
end
|
||||||
|
@ -32,7 +32,19 @@ module Locomotive
|
|||||||
can :touch, [Page, ThemeAsset]
|
can :touch, [Page, ThemeAsset]
|
||||||
can :sort, Page
|
can :sort, Page
|
||||||
|
|
||||||
can :manage, [ContentEntry, ContentAsset]
|
can :manage, [ContentEntry, ContentAsset] do |entry|
|
||||||
|
result = true
|
||||||
|
|
||||||
|
if perm_defs = ContentType.where(:slug => 'permissions').first
|
||||||
|
perms = perm_defs.entries.where(:user_email => @account.email).collect(&:types).collect { |types| types.split(',') }.flatten
|
||||||
|
|
||||||
|
if !perms.empty?
|
||||||
|
result = perms.any? { |perm| perm == entry.content_type.slug }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
can :touch, Site do |site|
|
can :touch, Site do |site|
|
||||||
site == @site
|
site == @site
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
= render 'locomotive/shared/actions/contents'
|
= render 'locomotive/shared/actions/contents'
|
||||||
|
|
||||||
- content_for :buttons do
|
- content_for :buttons do
|
||||||
= local_action_button :show, "/#{@page.fullpath}", :class => 'show'
|
= local_action_button :show, current_site_public_url + '/' + @page.fullpath, :class => 'show'
|
||||||
|
|
||||||
%p!= t('.help')
|
%p!= t('.help')
|
||||||
|
|
||||||
@ -15,4 +15,4 @@
|
|||||||
|
|
||||||
= render 'form', :f => form
|
= render 'form', :f => form
|
||||||
|
|
||||||
= render 'locomotive/shared/form_actions', :back_url => pages_url, :button_label => :update
|
= render 'locomotive/shared/form_actions', :back_url => pages_url, :button_label => :update
|
||||||
|
@ -123,7 +123,16 @@ module Locomotive
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.mounted_on
|
def self.mounted_on
|
||||||
Rails.application.routes.named_routes[:locomotive].path.spec.to_s
|
url_for(Rails.application.routes.named_routes[:locomotive].path.spec.to_s)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.url_for(path)
|
||||||
|
result = path
|
||||||
|
if config.base_uri && !path[%r{^#{config.base_uri}}]
|
||||||
|
result = "#{config.base_uri}/#{path.gsub(%r{^/}, '')}"
|
||||||
|
end
|
||||||
|
result = "/#{result}" if result[0..0] != '/'
|
||||||
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
@ -9,7 +9,7 @@ module Locomotive
|
|||||||
end
|
end
|
||||||
|
|
||||||
def current_site_public_url
|
def current_site_public_url
|
||||||
request.protocol + request.host_with_port
|
request.protocol + request.host_with_port + (Locomotive.config.base_uri || '')
|
||||||
end
|
end
|
||||||
|
|
||||||
def switch_to_site_url(site, options = {})
|
def switch_to_site_url(site, options = {})
|
||||||
@ -34,4 +34,4 @@ module Locomotive
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -13,6 +13,7 @@ module Locomotive
|
|||||||
:enable_logs => false,
|
:enable_logs => false,
|
||||||
:delayed_job => false,
|
:delayed_job => false,
|
||||||
:default_locale => :en,
|
:default_locale => :en,
|
||||||
|
:base_uri => nil,
|
||||||
:mailer_sender => 'support@example.com',
|
:mailer_sender => 'support@example.com',
|
||||||
:manage_subdomain => false,
|
:manage_subdomain => false,
|
||||||
:manage_manage_domains => false,
|
:manage_manage_domains => false,
|
||||||
|
Loading…
Reference in New Issue
Block a user