refactor the current site editing screen (screen)
This commit is contained in:
parent
cffe64f6be
commit
71d48fe726
@ -0,0 +1,3 @@
|
||||
class Locomotive.Models.Domain extends Backbone.Model
|
||||
|
||||
|
@ -1 +1,18 @@
|
||||
class Locomotive.Models.Site extends Backbone.Model
|
||||
|
||||
paramRoot: 'page'
|
||||
|
||||
urlRoot: "#{Locomotive.mount_on}/sites"
|
||||
|
||||
initialize: ->
|
||||
# Be careful, domains_without_subdomain becomes domains
|
||||
domains = _.map @get('domains_without_subdomain'), (name) =>
|
||||
new Locomotive.Models.Domain(name: name)
|
||||
|
||||
@set domains: domains
|
||||
|
||||
class Locomotive.Models.CurrentSite extends Locomotive.Models.Site
|
||||
|
||||
urlRoot: "#{Locomotive.mount_on}/current_site"
|
||||
|
||||
|
||||
|
@ -1,5 +1,39 @@
|
||||
#= require ../shared/form_view
|
||||
#= require ../sites/domains_view
|
||||
|
||||
Locomotive.Views.CurrentSite ||= {}
|
||||
|
||||
class Locomotive.Views.CurrentSite.EditView extends Locomotive.Views.Shared.FormView
|
||||
class Locomotive.Views.CurrentSite.EditView extends Locomotive.Views.Shared.FormView
|
||||
|
||||
el: '#content'
|
||||
|
||||
initialize: ->
|
||||
@model = new Locomotive.Models.CurrentSite(@options.site)
|
||||
|
||||
window.foo = @model
|
||||
|
||||
render: ->
|
||||
super()
|
||||
|
||||
@render_domain_entries()
|
||||
|
||||
@enable_liquid_editing()
|
||||
|
||||
render_domain_entries: ->
|
||||
@domains_view = new Locomotive.Views.Site.DomainsView model: @model, errors: @options.errors
|
||||
|
||||
@$('#site_domains_input label').after(@domains_view.render().el)
|
||||
|
||||
enable_liquid_editing: ->
|
||||
input = @$('#site_robots_txt')
|
||||
@editor = CodeMirror.fromTextArea input.get()[0],
|
||||
mode: 'liquid'
|
||||
autoMatchParens: false
|
||||
lineNumbers: false
|
||||
passDelay: 50
|
||||
tabMode: 'shift'
|
||||
theme: 'default'
|
||||
onChange: (editor) => @model.set(robots_txt: editor.getValue())
|
||||
|
||||
|
||||
|
||||
|
@ -155,11 +155,19 @@ form.formtastic {
|
||||
|
||||
&.code {
|
||||
|
||||
textarea, .CodeMirror-scroll {
|
||||
height: 400px;
|
||||
}
|
||||
|
||||
textarea {
|
||||
@include default-input-style;
|
||||
|
||||
width: 868px;
|
||||
height: 400px;
|
||||
}
|
||||
|
||||
&.small {
|
||||
textarea, .CodeMirror-scroll {
|
||||
height: 60px;
|
||||
}
|
||||
}
|
||||
|
||||
div.inline-errors, p.inline-hints {
|
||||
|
@ -17,9 +17,10 @@ module Locomotive
|
||||
def update
|
||||
@site = current_site
|
||||
@site.update_attributes(params[:site])
|
||||
respond_with @site do |format|
|
||||
format.html { redirect_to edit_current_site_url(new_host_if_subdomain_changed) }
|
||||
end
|
||||
respond_with @site, :location => edit_current_site_url(new_host_if_subdomain_changed)
|
||||
# respond_with @site do |format|
|
||||
# format.html { redirect_to edit_current_site_url(new_host_if_subdomain_changed) }
|
||||
# end
|
||||
end
|
||||
|
||||
protected
|
||||
|
@ -2,12 +2,19 @@ module Locomotive
|
||||
class CodeInput < Formtastic::Inputs::TextInput
|
||||
|
||||
def input_wrapping(&block)
|
||||
Rails.logger.debug hint_html.inspect
|
||||
template.content_tag(:li,
|
||||
[template.capture(&block), error_html, image_picker_html, hint_html].join("\n").html_safe,
|
||||
wrapper_html_options
|
||||
)
|
||||
end
|
||||
|
||||
def hint_text
|
||||
localized_string(method, options[:hint], :hint).tap do |foo|
|
||||
Rails.logger.debug foo.inspect
|
||||
end
|
||||
end
|
||||
|
||||
def to_html
|
||||
input_wrapping do
|
||||
builder.text_area(method, input_html_options)
|
||||
@ -15,6 +22,7 @@ module Locomotive
|
||||
end
|
||||
|
||||
def image_picker_html
|
||||
return '' if options.delete(:picker) == false
|
||||
template.content_tag(:div,
|
||||
template.link_to(template.t('locomotive.image_picker.link'), template.theme_assets_path, :id => 'image-picker-link', :class => 'picture'),
|
||||
:class => 'more')
|
||||
|
@ -49,7 +49,7 @@ module Locomotive
|
||||
Locomotive::Liquid::Drops::Site.new(self)
|
||||
end
|
||||
|
||||
def to_json
|
||||
def as_json(options = {})
|
||||
Locomotive::SitePresenter.new(self).as_json
|
||||
end
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
%script{ :type => 'text/html', :id => 'domain_entry' }
|
||||
|
||||
%em
|
||||
http://
|
||||
= text_field_tag 'site[domains][]', '{{name}}', :class => 'string label void domain'
|
||||
|
||||
{{#if error}}
|
||||
%span.inline-errors {{error}}
|
||||
{{/if}}
|
||||
%span.actions
|
||||
= link_to 'x', '#', :class => 'remove'
|
@ -1,5 +1,5 @@
|
||||
- content_for :head do
|
||||
= render 'domain'
|
||||
= render 'locomotive/sites/domains'
|
||||
|
||||
- content_for :backbone_view_data do
|
||||
:plain
|
||||
@ -21,35 +21,6 @@
|
||||
- if manage_domains?
|
||||
= f.input :domains, :as => :'Locomotive::Empty'
|
||||
|
||||
/ = f.custom_input :subdomain, :css => 'path' do
|
||||
/ %em
|
||||
/ http://
|
||||
/ = f.text_field :subdomain, :readonly =>
|
||||
/ \.
|
||||
/ %em
|
||||
/ = application_domain
|
||||
|
||||
/ - if manage_domains?
|
||||
/ - @site.domains_without_subdomain.each_with_index do |name, index|
|
||||
/ %li{ :class => "item added #{'last' if index == @site.domains.size - 1}"}
|
||||
/ %em
|
||||
/ http://
|
||||
/ = text_field_tag 'site[domains][]', name, :class => 'string label void domain'
|
||||
/
|
||||
/ = error_on_domain(@site, name)
|
||||
/ %span.actions
|
||||
/ = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove first', :confirm => t('locomotive.messages.confirm')
|
||||
/
|
||||
/ %li.item.template
|
||||
/ %em
|
||||
/ http://
|
||||
/ = text_field_tag 'label', t('formtastic.hints.site.domain_name'), :class => 'string label void domain'
|
||||
/
|
||||
/ %span.actions
|
||||
/ = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove first', :confirm => t('locomotive.messages.confirm')
|
||||
/ %button{ :class => 'button light add', :type => 'button' }
|
||||
/ %span!= t('locomotive.buttons.new_item')
|
||||
|
||||
- if can?(:index, Locomotive::Membership)
|
||||
|
||||
= f.inputs :name => :memberships do
|
||||
@ -81,7 +52,4 @@
|
||||
- if can?(:manage, current_site)
|
||||
|
||||
= f.inputs :name => :robots_txt, :class => "inputs foldable #{'folded' if inputs_folded?(@site)}" do
|
||||
/ = f.custom_input :robots_txt, :css => 'code full', :with_label => false do
|
||||
/ = f.label :robots_txt
|
||||
/ %code{ :class => 'html' }
|
||||
/ = f.text_area :robots_txt, :class => 'small'
|
||||
= f.input :robots_txt, :as => :'Locomotive::Code', :picker => false, :wrapper_html => { :class => 'small' }
|
||||
|
@ -3,3 +3,6 @@
|
||||
# Formtastic::SemanticFormHelper.builder = Locomotive::MiscFormBuilder
|
||||
# Formtastic::SemanticFormBuilder.i18n_lookups_by_default = true
|
||||
#
|
||||
require 'formtastic'
|
||||
|
||||
Formtastic::FormBuilder.configure :escape_html_entities_in_hints_and_labels, false
|
||||
|
12
doc/TODO
12
doc/TODO
@ -15,11 +15,17 @@ x menu / submenu in full css3 (no images)
|
||||
x fix css in firefox
|
||||
x update page in ajax
|
||||
- fix other sections
|
||||
- content types
|
||||
- edit my account
|
||||
- create a new site
|
||||
- edit my site
|
||||
- domains
|
||||
- robots.txt
|
||||
- roles
|
||||
- save
|
||||
- css
|
||||
- create a new site
|
||||
- edit my account
|
||||
- theme assets
|
||||
- content types
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -8,7 +8,8 @@ Locomotive.configure do |config|
|
||||
config.multi_sites do |multi_sites|
|
||||
# each new website you add will have a default entry based on a subdomain
|
||||
# and the multi_site_domain value (ex: website_1.locomotivehosting.com).
|
||||
multi_sites.domain = 'engine.dev' #'myhostingplatform.com'
|
||||
# multi_sites.domain = 'engine.dev' #'myhostingplatform.com'
|
||||
multi_sites.domain = 'example.com'
|
||||
|
||||
# define the reserved subdomains
|
||||
# Ex:
|
||||
|
Loading…
Reference in New Issue
Block a user