diff --git a/app/assets/javascripts/locomotive/models/domain.js.coffee b/app/assets/javascripts/locomotive/models/domain.js.coffee new file mode 100644 index 00000000..d4f215f7 --- /dev/null +++ b/app/assets/javascripts/locomotive/models/domain.js.coffee @@ -0,0 +1,3 @@ +class Locomotive.Models.Domain extends Backbone.Model + + diff --git a/app/assets/javascripts/locomotive/models/site.js.coffee b/app/assets/javascripts/locomotive/models/site.js.coffee index 7348fe5c..3895e310 100644 --- a/app/assets/javascripts/locomotive/models/site.js.coffee +++ b/app/assets/javascripts/locomotive/models/site.js.coffee @@ -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" + + diff --git a/app/assets/javascripts/locomotive/views/current_site/edit_view.js.coffee b/app/assets/javascripts/locomotive/views/current_site/edit_view.js.coffee index eda16107..cbc90e2e 100644 --- a/app/assets/javascripts/locomotive/views/current_site/edit_view.js.coffee +++ b/app/assets/javascripts/locomotive/views/current_site/edit_view.js.coffee @@ -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 \ No newline at end of file +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()) + + + diff --git a/app/assets/stylesheets/locomotive/formtastic_changes.scss b/app/assets/stylesheets/locomotive/formtastic_changes.scss index bd3f68fe..e83bc044 100644 --- a/app/assets/stylesheets/locomotive/formtastic_changes.scss +++ b/app/assets/stylesheets/locomotive/formtastic_changes.scss @@ -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 { diff --git a/app/controllers/locomotive/current_site_controller.rb b/app/controllers/locomotive/current_site_controller.rb index 5c8def41..19493099 100644 --- a/app/controllers/locomotive/current_site_controller.rb +++ b/app/controllers/locomotive/current_site_controller.rb @@ -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 diff --git a/app/inputs/locomotive/code_input.rb b/app/inputs/locomotive/code_input.rb index 7dd2e143..7d5c970a 100644 --- a/app/inputs/locomotive/code_input.rb +++ b/app/inputs/locomotive/code_input.rb @@ -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') diff --git a/app/models/locomotive/site.rb b/app/models/locomotive/site.rb index d451a868..e37bcff2 100644 --- a/app/models/locomotive/site.rb +++ b/app/models/locomotive/site.rb @@ -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 diff --git a/app/views/locomotive/current_site/_domain.html.haml b/app/views/locomotive/current_site/_domain.html.haml deleted file mode 100644 index cac97445..00000000 --- a/app/views/locomotive/current_site/_domain.html.haml +++ /dev/null @@ -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' \ No newline at end of file diff --git a/app/views/locomotive/current_site/_form.html.haml b/app/views/locomotive/current_site/_form.html.haml index 06be2f45..d3b12b5b 100644 --- a/app/views/locomotive/current_site/_form.html.haml +++ b/app/views/locomotive/current_site/_form.html.haml @@ -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' } diff --git a/config/initializers/formtastic.rb b/config/initializers/formtastic.rb index 0d55e881..561625f5 100644 --- a/config/initializers/formtastic.rb +++ b/config/initializers/formtastic.rb @@ -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 diff --git a/doc/TODO b/doc/TODO index 58557a05..00f42ca7 100644 --- a/doc/TODO +++ b/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 + diff --git a/spec/dummy/config/initializers/locomotive.rb b/spec/dummy/config/initializers/locomotive.rb index 7711d220..750e89b4 100644 --- a/spec/dummy/config/initializers/locomotive.rb +++ b/spec/dummy/config/initializers/locomotive.rb @@ -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: