From a8d616ba6bc513e5eda9fc578b70e752e65c4be2 Mon Sep 17 00:00:00 2001 From: did Date: Mon, 28 Nov 2011 06:40:25 -0800 Subject: [PATCH] remove references to foldable_inputs and custom_input --- .../locomotive/accounts_controller.rb | 2 +- .../locomotive/memberships_controller.rb | 17 ++++---- .../locomotive/my_account_controller.rb | 14 +++---- .../locomotive/passwords_controller.rb | 5 --- .../locomotive/sitemaps_controller.rb | 1 + .../locomotive/sites_controller.rb | 13 +++--- .../locomotive/snippets_controller.rb | 27 ++++++++++-- app/helpers/locomotive/assets_helper.rb | 31 -------------- app/helpers/locomotive/theme_assets_helper.rb | 24 +++++++++++ app/views/locomotive/accounts/new.html.haml | 4 +- .../locomotive/current_site/_form.html.haml | 4 +- .../locomotive/memberships/new.html.haml | 4 +- .../locomotive/my_account/edit.html.haml | 41 +++++++++---------- app/views/locomotive/snippets/_form.html.haml | 10 ++--- .../locomotive/theme_assets/_form.html.haml | 15 +++---- 15 files changed, 107 insertions(+), 105 deletions(-) delete mode 100644 app/helpers/locomotive/assets_helper.rb create mode 100644 app/helpers/locomotive/theme_assets_helper.rb diff --git a/app/controllers/locomotive/accounts_controller.rb b/app/controllers/locomotive/accounts_controller.rb index cf741bd8..25128d6a 100644 --- a/app/controllers/locomotive/accounts_controller.rb +++ b/app/controllers/locomotive/accounts_controller.rb @@ -5,12 +5,12 @@ module Locomotive def new @account = Account.new(:email => params[:email]) + respond_with @account end def create @account = Account.create(params[:account]) current_site.memberships.create(:account => @account) if @account.errors.empty? - respond_with @account, :location => edit_current_site_url end diff --git a/app/controllers/locomotive/memberships_controller.rb b/app/controllers/locomotive/memberships_controller.rb index 817a20da..3af2c6d6 100644 --- a/app/controllers/locomotive/memberships_controller.rb +++ b/app/controllers/locomotive/memberships_controller.rb @@ -4,22 +4,25 @@ module Locomotive sections 'settings' def create - resource.role = 'author' # force author by default + @membership = current_site.memberships.build(params[:membership]) + @membership.role = 'author' # force author by default - case resource.process! + case @membership.process! when :create_account - redirect_to new_account_url(:email => resource.email) + redirect_to new_account_url(:email => @membership.email) when :save_it - respond_with resource, :location => edit_current_site_url + respond_with @membership, :location => edit_current_site_url when :error - respond_with resource, :flash => true + respond_with @membership, :flash => true when :already_created - respond_with resource, :alert => t('flash.locomotive.memberships.create.already_created'), :location => edit_current_site_url + respond_with @membership, :alert => t('flash.locomotive.memberships.create.already_created'), :location => edit_current_site_url end end def destroy - destroy! { edit_current_site_url } + @membership = current_site.memberships.find(params[:id]) + @membership.destroy + respond_with @membership, :location => edit_current_site_url end end diff --git a/app/controllers/locomotive/my_account_controller.rb b/app/controllers/locomotive/my_account_controller.rb index 95f33986..328fb4b7 100644 --- a/app/controllers/locomotive/my_account_controller.rb +++ b/app/controllers/locomotive/my_account_controller.rb @@ -5,22 +5,20 @@ module Locomotive respond_to :json, :only => :update + helper 'Locomotive::Accounts' + skip_load_and_authorize_resource def edit + @account = current_locomotive_account + respond_with @account end def update - update! { edit_my_account_url } - end - - protected - - def resource @account = current_locomotive_account + @account.update_attributes(params[:account]) + respond_with @account, edit_my_account_url end - def begin_of_association_chain; nil; end # not related directly to current_site - end end diff --git a/app/controllers/locomotive/passwords_controller.rb b/app/controllers/locomotive/passwords_controller.rb index 72ab8a32..ee13de52 100644 --- a/app/controllers/locomotive/passwords_controller.rb +++ b/app/controllers/locomotive/passwords_controller.rb @@ -9,10 +9,5 @@ module Locomotive helper 'locomotive/base' - def edit - logger.debug 'I am here' - super - end - end end diff --git a/app/controllers/locomotive/sitemaps_controller.rb b/app/controllers/locomotive/sitemaps_controller.rb index f840aa90..79ffc48f 100644 --- a/app/controllers/locomotive/sitemaps_controller.rb +++ b/app/controllers/locomotive/sitemaps_controller.rb @@ -11,6 +11,7 @@ module Locomotive def show @pages = current_site.pages.published + respond_with @pages end end diff --git a/app/controllers/locomotive/sites_controller.rb b/app/controllers/locomotive/sites_controller.rb index 5f031e0e..9839540e 100644 --- a/app/controllers/locomotive/sites_controller.rb +++ b/app/controllers/locomotive/sites_controller.rb @@ -3,11 +3,16 @@ module Locomotive sections 'settings' + def new + @site = Site.new + respond_with @site + end + def create @site = Site.new(params[:site]) @site.memberships.build :account => @current_locomotive_account, :role => 'admin' - - create! { edit_my_account_url } + @site.save + respond_with @site, :location => edit_my_account_url end def destroy @@ -22,9 +27,5 @@ module Locomotive respond_with @site, :location => edit_my_account_url end - protected - - def begin_of_association_chain; nil; end # not related directly to current_site - end end diff --git a/app/controllers/locomotive/snippets_controller.rb b/app/controllers/locomotive/snippets_controller.rb index e4515b86..03a8a227 100644 --- a/app/controllers/locomotive/snippets_controller.rb +++ b/app/controllers/locomotive/snippets_controller.rb @@ -5,10 +5,31 @@ module Locomotive respond_to :json, :only => :update + def new + @snippet = current_site.snippets.new + respond_with @snippet + end + + def create + @snippet = current_site.snippets.create(params[:snippet]) + respond_with @snippet, :location => edit_snippet_url(@snippet) + end + + def edit + @snippet = current_site.snippets.find(params[:id]) + respond_with @snippet + end + + def update + @snippet = current_site.snippets.find(params[:id]) + @snippet.update_attributes(params[:id]) + respond_with @snippet, :location => edit_snippet_url(@snippet) + end + def destroy - destroy! do |format| - format.html { redirect_to theme_assets_url } - end + @snippet = current_site.snippets.find(params[:id]) + @snippet.destroy + respond_with @snippet, :location => theme_assets_url end end diff --git a/app/helpers/locomotive/assets_helper.rb b/app/helpers/locomotive/assets_helper.rb deleted file mode 100644 index 42e1b557..00000000 --- a/app/helpers/locomotive/assets_helper.rb +++ /dev/null @@ -1,31 +0,0 @@ -module Locomotive::AssetsHelper - - # def vignette_tag(asset) - # if asset.image? - # html, css = image_tag(asset.vignette_url), 'image' - # else - # css = "icon #{asset.content_type}" - # html = asset.content_type.to_s == 'other' ? truncate(asset.extname, :length => 3) : asset.content_type - # html = '?' if html.blank? - # end - # - # content_tag(:div, content_tag(:div, html, :class => 'inside'), :class => css) - # end - - def image_dimensions_and_size(asset) - content_tag(:small, "#{asset.width}px x #{asset.height}px | #{number_to_human_size(asset.size)}") - end - - def allow_plain_text_editing?(asset) - asset.new_record? || asset.stylesheet_or_javascript? - end - - def display_plain_text?(asset) - if asset.new_record? - asset.performing_plain_text? - else - asset.stylesheet_or_javascript? - end - end - -end diff --git a/app/helpers/locomotive/theme_assets_helper.rb b/app/helpers/locomotive/theme_assets_helper.rb new file mode 100644 index 00000000..696238a3 --- /dev/null +++ b/app/helpers/locomotive/theme_assets_helper.rb @@ -0,0 +1,24 @@ +module Locomotive::ThemeAssetsHelper + + def image_dimensions_and_size(asset) + content_tag(:small, "#{asset.width}px x #{asset.height}px | #{number_to_human_size(asset.size)}") + end + + def plain_text_type(asset) + asset.size && asset.size > 40000 ? 'nude' : (asset.content_type || 'stylesheet') + end + + def allow_plain_text_editing?(asset) + asset.new_record? || asset.stylesheet_or_javascript? + end + + def display_plain_text?(asset) + if asset.new_record? + asset.performing_plain_text? + else + asset.stylesheet_or_javascript? + end + end + + +end \ No newline at end of file diff --git a/app/views/locomotive/accounts/new.html.haml b/app/views/locomotive/accounts/new.html.haml index 25e93a16..3994e24a 100644 --- a/app/views/locomotive/accounts/new.html.haml +++ b/app/views/locomotive/accounts/new.html.haml @@ -7,13 +7,13 @@ = semantic_form_for @account, :url => accounts_url do |f| - = f.foldable_inputs :name => :information do + = f.inputs :name => :information do = f.input :name - unless f.object.respond_to?(:password) = f.input :email - if f.object.respond_to?(:password) - = f.foldable_inputs :name => :credentials do + = f.inputs :name => :credentials do = f.input :email = f.input :password, :input_html => { :autocomplete => "off" } = f.input :password_confirmation, :input_html => { :autocomplete => "off" } diff --git a/app/views/locomotive/current_site/_form.html.haml b/app/views/locomotive/current_site/_form.html.haml index d3b12b5b..0d67467c 100644 --- a/app/views/locomotive/current_site/_form.html.haml +++ b/app/views/locomotive/current_site/_form.html.haml @@ -38,9 +38,9 @@ %em.editable= t("locomotive.memberships.roles.#{membership.role}") - if can?(:grant_admin, membership) - = fm.select :role, Ability::ROLES.map { |r| [t("locomotive.memberships.roles.#{r}"), r] }, :include_blank => false + = fm.select :role, Locomotive::Ability::ROLES.map { |r| [t("locomotive.memberships.roles.#{r}"), r] }, :include_blank => false - else - = fm.select :role, (Ability::ROLES - ['admin']).map { |r| [t("locomotive.memberships.roles.#{r}"), r] }, :include_blank => false + = fm.select :role, (Locomotive::Ability::ROLES - ['admin']).map { |r| [t("locomotive.memberships.roles.#{r}"), r] }, :include_blank => false %span.actions = link_to image_tag('admin/form/icons/trash.png'), membership_url(membership), :class => 'remove first', :confirm =>t('locomotive.messages.confirm'), :method => :delete diff --git a/app/views/locomotive/memberships/new.html.haml b/app/views/locomotive/memberships/new.html.haml index f6315757..b0042d96 100644 --- a/app/views/locomotive/memberships/new.html.haml +++ b/app/views/locomotive/memberships/new.html.haml @@ -9,7 +9,7 @@ = f.inputs :name => :membership_email, :class => 'inputs email' do - = f.custom_input :email, { :css => 'string full', :with_label => false } do - = f.text_field :email + / = f.input :email, :css => 'string full', :with_label => false } do + = f.input :email, :label => false = render 'locomotive/shared/form_actions', :back_url => edit_current_site_url, :button_label => :create \ No newline at end of file diff --git a/app/views/locomotive/my_account/edit.html.haml b/app/views/locomotive/my_account/edit.html.haml index 326ea620..fb2e6df3 100644 --- a/app/views/locomotive/my_account/edit.html.haml +++ b/app/views/locomotive/my_account/edit.html.haml @@ -1,7 +1,7 @@ - title link_to(@account.name.blank? ? @account.name_was : @account.name, '#', :rel => 'my_account_name', :title => t('.ask_for_name'), :class => 'editable') - content_for :head do - = include_javascripts :account + / = include_javascripts :account - content_for :submenu do = render_cell 'locomotive/settings_menu', :show @@ -14,34 +14,33 @@ = semantic_form_for @account, :as => :my_account, :url => my_account_url, :html => { :class => 'save-with-shortcut' } do |f| - = f.foldable_inputs :name => :information, :style => 'display: none' do + = f.inputs :name => :information do = f.input :name - = f.foldable_inputs :name => :credentials do + = f.inputs :name => :credentials do = f.input :email = f.input :password, :input_html => { :autocomplete => "off" } = f.input :password_confirmation, :input_html => { :autocomplete => "off" } - if multi_sites? - = f.foldable_inputs :name => :sites, :class => 'sites off' do - - @account.sites.each do |site| - %li{ :class => 'item' } - %strong= link_to site.name, site_url(site) - %em= site.domains.join(', ') + = f.inputs :name => :sites, :class => 'sites' do + %ul.list + - @account.sites.each do |site| + %li + %strong= link_to site.name, site_url(site) + %em= site.domains.join(', ') - - if admin_on?(site) && site != current_site - %span{ :class => 'actions' } - = link_to image_tag('admin/form/icons/trash.png'), site_url(site), :class => 'remove first', :confirm => t('locomotive.messages.confirm'), :method => :delete - - = f.foldable_inputs :name => :language, :class => 'language' do - = f.custom_input :language, { :css => 'full', :with_label => false } do - - Locomotive.config.locales.each do |locale| - %span - = f.radio_button :locale, locale - %label{ :for => "my_account_locale_#{locale.downcase}" } - = image_tag "admin/icons/flags/#{locale}.png" - = t(".#{locale}") - /   + - if admin_on?(site) && site != current_site + %span{ :class => 'actions' } + = link_to 'x', site_url(site), :class => 'remove first', :confirm => t('locomotive.messages.confirm'), :method => :delete + = f.inputs :name => :language, :class => 'language' do + - Locomotive.config.locales.each do |locale| + %span + = f.radio_button :locale, locale + %label{ :for => "my_account_locale_#{locale.downcase}" } + = image_tag "admin/icons/flags/#{locale}.png" + = t(".#{locale}") + /   = render 'locomotive/shared/form_actions', :button_label => :update diff --git a/app/views/locomotive/snippets/_form.html.haml b/app/views/locomotive/snippets/_form.html.haml index d8f305c0..91c44004 100644 --- a/app/views/locomotive/snippets/_form.html.haml +++ b/app/views/locomotive/snippets/_form.html.haml @@ -1,14 +1,10 @@ - content_for :head do - = include_javascripts :image_picker, :snippets - = include_stylesheets :fancybox + / = include_javascripts :image_picker, :snippets + / = include_stylesheets :fancybox = f.inputs :name => :information do = f.input :name, :wrapper_html => { :class => 'highlighted' } = f.input :slug, :required => false = f.inputs :name => :code do - = f.custom_input :template, :css => 'full', :with_label => false do - %code{ :class => 'html' } - = f.text_area :template - .more - = link_to t('locomotive.image_picker.link'), admin_theme_assets_path, :id => 'image-picker-link', :class => 'picture' \ No newline at end of file + = f.input :template, :as => :'Locomotive::Code' diff --git a/app/views/locomotive/theme_assets/_form.html.haml b/app/views/locomotive/theme_assets/_form.html.haml index 5b284a61..f8bcbbd2 100644 --- a/app/views/locomotive/theme_assets/_form.html.haml +++ b/app/views/locomotive/theme_assets/_form.html.haml @@ -1,6 +1,6 @@ - content_for :head do - = include_javascripts :image_picker, :theme_assets - = include_stylesheets :fancybox + / = include_javascripts :image_picker, :theme_assets + / = include_stylesheets :fancybox = f.hidden_field :performing_plain_text @@ -19,17 +19,12 @@ - if @theme_asset.new_record? = f.input :plain_text_name - = f.custom_input :plain_text_type do - = f.select :plain_text_type, %w(stylesheet javascript) + = f.input :plain_text_type, :as => 'select', :collection => %w(stylesheet javascript) - = f.custom_input :plain_text, :css => 'full', :with_label => false do - %code{ :class => (@theme_asset.size && @theme_asset.size > 40000 ? 'nude' : (@theme_asset.content_type || 'stylesheet')) } - = f.text_area :plain_text - .more - = link_to t('locomotive.image_picker.link'), admin_theme_assets_path, :id => 'image-picker-link', :class => 'picture' + = f.input :plain_text, :as => :'Locomotive::Code', :type => plain_text_type(@theme_asset) %span.alt != t('locomotive.theme_assets.form.choose_file') -= f.foldable_inputs :name => :options do += f.inputs :name => :options, :class => "inputs foldable #{'folded' if inputs_folded?(@asset)}" do = f.input :folder \ No newline at end of file