From 68a19f7f9914412276d56bd272d6540f788be39e Mon Sep 17 00:00:00 2001 From: adutka Date: Sun, 15 Feb 2015 11:04:27 +0200 Subject: [PATCH 1/5] adutka_simple_form --- Gemfile~ | 59 ++++++++ app/views/folders/show.html.slim | 3 + config/initializers/simple_form.rb | 166 ++++++++++++++++++++++ config/locales/simple_form.en.yml | 31 ++++ lib/templates/erb/scaffold/_form.html.erb | 13 ++ 5 files changed, 272 insertions(+) create mode 100644 Gemfile~ create mode 100644 app/views/folders/show.html.slim create mode 100644 config/initializers/simple_form.rb create mode 100644 config/locales/simple_form.en.yml create mode 100644 lib/templates/erb/scaffold/_form.html.erb diff --git a/Gemfile~ b/Gemfile~ new file mode 100644 index 0000000..11e9d38 --- /dev/null +++ b/Gemfile~ @@ -0,0 +1,59 @@ +source 'https://rubygems.org' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '4.2.0' + +# Use mysql as the database for Active Record +gem 'mysql2' +gem 'pg' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.1.0' +# See https://github.com/sstephenson/execjs#readme for more supported runtimes +# gem 'therubyracer', platforms: :ruby + +# Use jquery as the JavaScript library +gem 'jquery-rails' +# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks +gem 'turbolinks' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.0' +# bundle exec rake doc:rails generates the API under doc/api. +gem 'sdoc', '~> 0.4.0', group: :doc + +gem 'slim' + +gem 'pry-rails' + +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use Unicorn as the app server +# gem 'unicorn' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +gem 'devise', '~> 3.4.1' +gem 'bootstrap-sass', '~> 3.3.1.0' +gem 'devise-bootstrap-views', '~> 0.0.3' +gem 'execjs' +gem 'therubyracer' +gem 'omniauth-facebook' +gem 'ancestry' + + +group :development, :test do + # Call 'byebug' anywhere in the code to stop execution and get a debugger console + gem 'byebug' + + # Access an IRB console on exception pages or by using <%= console %> in views + gem 'web-console', '~> 2.0' + + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'rspec-rails' +end diff --git a/app/views/folders/show.html.slim b/app/views/folders/show.html.slim new file mode 100644 index 0000000..135223e --- /dev/null +++ b/app/views/folders/show.html.slim @@ -0,0 +1,3 @@ +- content_for :menu do += render 'shared/menu' += render 'table', {:folders => @folders, :items => @items} \ No newline at end of file diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb new file mode 100644 index 0000000..d5492e5 --- /dev/null +++ b/config/initializers/simple_form.rb @@ -0,0 +1,166 @@ +# Use this setup block to configure all options available in SimpleForm. +SimpleForm.setup do |config| + # Wrappers are used by the form builder to generate a + # complete input. You can remove any component from the + # wrapper, change the order or even add your own to the + # stack. The options given below are used to wrap the + # whole input. + config.wrappers :default, class: :input, + hint_class: :field_with_hint, error_class: :field_with_errors do |b| + ## Extensions enabled by default + # Any of these extensions can be disabled for a + # given input by passing: `f.input EXTENSION_NAME => false`. + # You can make any of these extensions optional by + # renaming `b.use` to `b.optional`. + + # Determines whether to use HTML5 (:email, :url, ...) + # and required attributes + b.use :html5 + + # Calculates placeholders automatically from I18n + # You can also pass a string as f.input placeholder: "Placeholder" + b.use :placeholder + + ## Optional extensions + # They are disabled unless you pass `f.input EXTENSION_NAME => true` + # to the input. If so, they will retrieve the values from the model + # if any exists. If you want to enable any of those + # extensions by default, you can change `b.optional` to `b.use`. + + # Calculates maxlength from length validations for string inputs + b.optional :maxlength + + # Calculates pattern from format validations for string inputs + b.optional :pattern + + # Calculates min and max from length validations for numeric inputs + b.optional :min_max + + # Calculates readonly automatically from readonly attributes + b.optional :readonly + + ## Inputs + b.use :label_input + b.use :hint, wrap_with: { tag: :span, class: :hint } + b.use :error, wrap_with: { tag: :span, class: :error } + + ## full_messages_for + # If you want to display the full error message for the attribute, you can + # use the component :full_error, like: + # + # b.use :full_error, wrap_with: { tag: :span, class: :error } + end + + # The default wrapper to be used by the FormBuilder. + config.default_wrapper = :default + + # Define the way to render check boxes / radio buttons with labels. + # Defaults to :nested for bootstrap config. + # inline: input + label + # nested: label > input + config.boolean_style = :nested + + # Default class for buttons + config.button_class = 'btn' + + # Method used to tidy up errors. Specify any Rails Array method. + # :first lists the first message for each field. + # Use :to_sentence to list all errors for each field. + # config.error_method = :first + + # Default tag used for error notification helper. + config.error_notification_tag = :div + + # CSS class to add for error notification helper. + config.error_notification_class = 'error_notification' + + # ID to add for error notification helper. + # config.error_notification_id = nil + + # Series of attempts to detect a default label method for collection. + # config.collection_label_methods = [ :to_label, :name, :title, :to_s ] + + # Series of attempts to detect a default value method for collection. + # config.collection_value_methods = [ :id, :to_s ] + + # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none. + # config.collection_wrapper_tag = nil + + # You can define the class to use on all collection wrappers. Defaulting to none. + # config.collection_wrapper_class = nil + + # You can wrap each item in a collection of radio/check boxes with a tag, + # defaulting to :span. Please note that when using :boolean_style = :nested, + # SimpleForm will force this option to be a label. + # config.item_wrapper_tag = :span + + # You can define a class to use in all item wrappers. Defaulting to none. + # config.item_wrapper_class = nil + + # How the label text should be generated altogether with the required text. + # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" } + + # You can define the class to use on all labels. Default is nil. + # config.label_class = nil + + # You can define the default class to be used on forms. Can be overriden + # with `html: { :class }`. Defaulting to none. + # config.default_form_class = nil + + # You can define which elements should obtain additional classes + # config.generate_additional_classes_for = [:wrapper, :label, :input] + + # Whether attributes are required by default (or not). Default is true. + # config.required_by_default = true + + # Tell browsers whether to use the native HTML5 validations (novalidate form option). + # These validations are enabled in SimpleForm's internal config but disabled by default + # in this configuration, which is recommended due to some quirks from different browsers. + # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations, + # change this configuration to true. + config.browser_validations = false + + # Collection of methods to detect if a file type was given. + # config.file_methods = [ :mounted_as, :file?, :public_filename ] + + # Custom mappings for input types. This should be a hash containing a regexp + # to match as key, and the input type that will be used when the field name + # matches the regexp as value. + # config.input_mappings = { /count/ => :integer } + + # Custom wrappers for input types. This should be a hash containing an input + # type as key and the wrapper that will be used for all inputs with specified type. + # config.wrapper_mappings = { string: :prepend } + + # Namespaces where SimpleForm should look for custom input classes that + # override default inputs. + # config.custom_inputs_namespaces << "CustomInputs" + + # Default priority for time_zone inputs. + # config.time_zone_priority = nil + + # Default priority for country inputs. + # config.country_priority = nil + + # When false, do not use translations for labels. + # config.translate_labels = true + + # Automatically discover new inputs in Rails' autoload path. + # config.inputs_discovery = true + + # Cache SimpleForm inputs discovery + # config.cache_discovery = !Rails.env.development? + + # Default class for inputs + # config.input_class = nil + + # Define the default class of the input wrapper of the boolean input. + config.boolean_label_class = 'checkbox' + + # Defines if the default input wrapper class should be included in radio + # collection wrappers. + # config.include_default_input_wrapper_class = true + + # Defines which i18n scope will be used in Simple Form. + # config.i18n_scope = 'simple_form' +end diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml new file mode 100644 index 0000000..2374383 --- /dev/null +++ b/config/locales/simple_form.en.yml @@ -0,0 +1,31 @@ +en: + simple_form: + "yes": 'Yes' + "no": 'No' + required: + text: 'required' + mark: '*' + # You can uncomment the line below if you need to overwrite the whole required html. + # When using html, text and mark won't be used. + # html: '*' + error_notification: + default_message: "Please review the problems below:" + # Examples + # labels: + # defaults: + # password: 'Password' + # user: + # new: + # email: 'E-mail to sign in.' + # edit: + # email: 'E-mail.' + # hints: + # defaults: + # username: 'User name to sign in.' + # password: 'No special characters, please.' + # include_blanks: + # defaults: + # age: 'Rather not say' + # prompts: + # defaults: + # age: 'Select your age' diff --git a/lib/templates/erb/scaffold/_form.html.erb b/lib/templates/erb/scaffold/_form.html.erb new file mode 100644 index 0000000..201a069 --- /dev/null +++ b/lib/templates/erb/scaffold/_form.html.erb @@ -0,0 +1,13 @@ +<%%= simple_form_for(@<%= singular_table_name %>) do |f| %> + <%%= f.error_notification %> + +
+ <%- attributes.each do |attribute| -%> + <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %> + <%- end -%> +
+ +
+ <%%= f.button :submit %> +
+<%% end %> From 5b0f8b6b1635933875e5b1e600a9557b913fcb04 Mon Sep 17 00:00:00 2001 From: adutka Date: Thu, 19 Feb 2015 18:25:40 +0200 Subject: [PATCH 2/5] adutka_folders_show --- app/controllers/folders_controller.rb | 8 ++++++++ app/views/folders/show.html.slim | 4 +--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/folders_controller.rb b/app/controllers/folders_controller.rb index 57695f5..bb4a39d 100644 --- a/app/controllers/folders_controller.rb +++ b/app/controllers/folders_controller.rb @@ -1,7 +1,12 @@ class FoldersController < ApplicationController + before_action :authenticate_user! + def show + @folder = Folder.find(params[:id]) + end + def new @folder = Folder.new(parent_id: params[:parent_id], user_id: current_user.id) end @@ -29,3 +34,6 @@ def folder_params end end + + + diff --git a/app/views/folders/show.html.slim b/app/views/folders/show.html.slim index 135223e..9ed2c61 100644 --- a/app/views/folders/show.html.slim +++ b/app/views/folders/show.html.slim @@ -1,3 +1 @@ -- content_for :menu do -= render 'shared/menu' -= render 'table', {:folders => @folders, :items => @items} \ No newline at end of file += @folder.name From cbb8e5a229f41903523b3ccd216b12438dce7c19 Mon Sep 17 00:00:00 2001 From: adutka Date: Sun, 22 Feb 2015 13:54:20 +0200 Subject: [PATCH 3/5] adutka create separate routes for old views --- Gemfile | 2 +- Gemfile.lock | 4 + app/controllers/folders_controller.rb | 9 ++ app/helpers/folders_helper.rb | 8 ++ app/views/folders/_folder.html.slim | 35 ++++- app/views/folders/_folder_item.html.slim | 9 ++ app/views/folders/folders_form.html.slim | 8 ++ app/views/folders/folders_tree.html.slim | 5 + app/views/folders/show.html.slim | 2 +- config/initializers/simple_form.rb | 166 ----------------------- config/routes.rb | 7 +- 11 files changed, 80 insertions(+), 175 deletions(-) create mode 100644 app/views/folders/_folder_item.html.slim create mode 100644 app/views/folders/folders_form.html.slim create mode 100644 app/views/folders/folders_tree.html.slim delete mode 100644 config/initializers/simple_form.rb diff --git a/Gemfile b/Gemfile index 11e9d38..cadb82d 100644 --- a/Gemfile +++ b/Gemfile @@ -44,7 +44,7 @@ gem 'execjs' gem 'therubyracer' gem 'omniauth-facebook' gem 'ancestry' - +gem 'simple_form' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console diff --git a/Gemfile.lock b/Gemfile.lock index 65fc7a4..0e00c51 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -185,6 +185,9 @@ GEM sdoc (0.4.1) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) + simple_form (3.1.0) + actionpack (~> 4.0) + activemodel (~> 4.0) slim (3.0.1) temple (~> 0.7.3) tilt (>= 1.3.3, < 2.1) @@ -242,6 +245,7 @@ DEPENDENCIES rspec-rails sass-rails (~> 5.0) sdoc (~> 0.4.0) + simple_form slim spring therubyracer diff --git a/app/controllers/folders_controller.rb b/app/controllers/folders_controller.rb index bb4a39d..6951e45 100644 --- a/app/controllers/folders_controller.rb +++ b/app/controllers/folders_controller.rb @@ -27,6 +27,15 @@ def destroy redirect_to folders_path end + def folders_tree + @folder = Folder.new + @folders = Folder.all + end + + def folders_form + @folder = Folder.new(parent_id: params[:parent_id], user_id: current_user.id) + end + private def folder_params diff --git a/app/helpers/folders_helper.rb b/app/helpers/folders_helper.rb index 5100e28..0774e69 100644 --- a/app/helpers/folders_helper.rb +++ b/app/helpers/folders_helper.rb @@ -4,4 +4,12 @@ def nested_folders(folders) render(folder) + content_tag(:div, nested_folders(sub_folders), :class => "nested_folders") end.join.html_safe end + + def nested_folders_tree(folders) + folders.map do |folder, sub_folders| + render("folder_item", folder: folder) + content_tag(:div, nested_folders_tree(sub_folders), :class => "nested_folders") + end.join.html_safe + end + end + diff --git a/app/views/folders/_folder.html.slim b/app/views/folders/_folder.html.slim index 0a71b25..0deb464 100644 --- a/app/views/folders/_folder.html.slim +++ b/app/views/folders/_folder.html.slim @@ -1,9 +1,32 @@ .folder - .created_at - = folder.created_at.strftime("%B %d, %Y") + /.created_at + / = folder.created_at.strftime("%B %d, %Y") + ul + .name + li = folder.name - .actions - = link_to "Create subfolder", new_folder_path(parent_id: folder) - = "|" - = link_to "Destroy", folder, method: :delete, data: {confirm: "Are you sure?"} + li + + /.actions + / = link_to "Create subfolder", new_folder_path(parent_id: folder) + /= "|" + /= link_to "Destroy", folder, method: :delete, data: {confirm: "Are you sure?"} + +thead + +tbody +tr +td +td +td +td +td +td +- if @folder +tr +td.up colspan="5" += link_to @folder.parent || root_path + +span +| .. \ No newline at end of file diff --git a/app/views/folders/_folder_item.html.slim b/app/views/folders/_folder_item.html.slim new file mode 100644 index 0000000..08cf964 --- /dev/null +++ b/app/views/folders/_folder_item.html.slim @@ -0,0 +1,9 @@ +.folder + .created_at + = folder.created_at.strftime("%B %d, %Y") + .name + = folder.name + .actions + = link_to "Create subfolder", folders_form_folders_path(parent_id: folder) + = "|" + = link_to "Destroy", folder, method: :delete, data: {confirm: "Are you sure?"} \ No newline at end of file diff --git a/app/views/folders/folders_form.html.slim b/app/views/folders/folders_form.html.slim new file mode 100644 index 0000000..a1ba2b8 --- /dev/null +++ b/app/views/folders/folders_form.html.slim @@ -0,0 +1,8 @@ +h1 Create subfolder + += render "folder_item", folder: @folder.parent if @folder.parent + += render "form" + +p + = link_to "Back to Folders", folders_path diff --git a/app/views/folders/folders_tree.html.slim b/app/views/folders/folders_tree.html.slim new file mode 100644 index 0000000..6dc4d0b --- /dev/null +++ b/app/views/folders/folders_tree.html.slim @@ -0,0 +1,5 @@ +h1 Folders + += nested_folders_tree @folders.arrange(:order => :created_at) + += render "form" \ No newline at end of file diff --git a/app/views/folders/show.html.slim b/app/views/folders/show.html.slim index 9ed2c61..d8cdb1d 100644 --- a/app/views/folders/show.html.slim +++ b/app/views/folders/show.html.slim @@ -1 +1 @@ -= @folder.name += @folder.name \ No newline at end of file diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb deleted file mode 100644 index d5492e5..0000000 --- a/config/initializers/simple_form.rb +++ /dev/null @@ -1,166 +0,0 @@ -# Use this setup block to configure all options available in SimpleForm. -SimpleForm.setup do |config| - # Wrappers are used by the form builder to generate a - # complete input. You can remove any component from the - # wrapper, change the order or even add your own to the - # stack. The options given below are used to wrap the - # whole input. - config.wrappers :default, class: :input, - hint_class: :field_with_hint, error_class: :field_with_errors do |b| - ## Extensions enabled by default - # Any of these extensions can be disabled for a - # given input by passing: `f.input EXTENSION_NAME => false`. - # You can make any of these extensions optional by - # renaming `b.use` to `b.optional`. - - # Determines whether to use HTML5 (:email, :url, ...) - # and required attributes - b.use :html5 - - # Calculates placeholders automatically from I18n - # You can also pass a string as f.input placeholder: "Placeholder" - b.use :placeholder - - ## Optional extensions - # They are disabled unless you pass `f.input EXTENSION_NAME => true` - # to the input. If so, they will retrieve the values from the model - # if any exists. If you want to enable any of those - # extensions by default, you can change `b.optional` to `b.use`. - - # Calculates maxlength from length validations for string inputs - b.optional :maxlength - - # Calculates pattern from format validations for string inputs - b.optional :pattern - - # Calculates min and max from length validations for numeric inputs - b.optional :min_max - - # Calculates readonly automatically from readonly attributes - b.optional :readonly - - ## Inputs - b.use :label_input - b.use :hint, wrap_with: { tag: :span, class: :hint } - b.use :error, wrap_with: { tag: :span, class: :error } - - ## full_messages_for - # If you want to display the full error message for the attribute, you can - # use the component :full_error, like: - # - # b.use :full_error, wrap_with: { tag: :span, class: :error } - end - - # The default wrapper to be used by the FormBuilder. - config.default_wrapper = :default - - # Define the way to render check boxes / radio buttons with labels. - # Defaults to :nested for bootstrap config. - # inline: input + label - # nested: label > input - config.boolean_style = :nested - - # Default class for buttons - config.button_class = 'btn' - - # Method used to tidy up errors. Specify any Rails Array method. - # :first lists the first message for each field. - # Use :to_sentence to list all errors for each field. - # config.error_method = :first - - # Default tag used for error notification helper. - config.error_notification_tag = :div - - # CSS class to add for error notification helper. - config.error_notification_class = 'error_notification' - - # ID to add for error notification helper. - # config.error_notification_id = nil - - # Series of attempts to detect a default label method for collection. - # config.collection_label_methods = [ :to_label, :name, :title, :to_s ] - - # Series of attempts to detect a default value method for collection. - # config.collection_value_methods = [ :id, :to_s ] - - # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none. - # config.collection_wrapper_tag = nil - - # You can define the class to use on all collection wrappers. Defaulting to none. - # config.collection_wrapper_class = nil - - # You can wrap each item in a collection of radio/check boxes with a tag, - # defaulting to :span. Please note that when using :boolean_style = :nested, - # SimpleForm will force this option to be a label. - # config.item_wrapper_tag = :span - - # You can define a class to use in all item wrappers. Defaulting to none. - # config.item_wrapper_class = nil - - # How the label text should be generated altogether with the required text. - # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" } - - # You can define the class to use on all labels. Default is nil. - # config.label_class = nil - - # You can define the default class to be used on forms. Can be overriden - # with `html: { :class }`. Defaulting to none. - # config.default_form_class = nil - - # You can define which elements should obtain additional classes - # config.generate_additional_classes_for = [:wrapper, :label, :input] - - # Whether attributes are required by default (or not). Default is true. - # config.required_by_default = true - - # Tell browsers whether to use the native HTML5 validations (novalidate form option). - # These validations are enabled in SimpleForm's internal config but disabled by default - # in this configuration, which is recommended due to some quirks from different browsers. - # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations, - # change this configuration to true. - config.browser_validations = false - - # Collection of methods to detect if a file type was given. - # config.file_methods = [ :mounted_as, :file?, :public_filename ] - - # Custom mappings for input types. This should be a hash containing a regexp - # to match as key, and the input type that will be used when the field name - # matches the regexp as value. - # config.input_mappings = { /count/ => :integer } - - # Custom wrappers for input types. This should be a hash containing an input - # type as key and the wrapper that will be used for all inputs with specified type. - # config.wrapper_mappings = { string: :prepend } - - # Namespaces where SimpleForm should look for custom input classes that - # override default inputs. - # config.custom_inputs_namespaces << "CustomInputs" - - # Default priority for time_zone inputs. - # config.time_zone_priority = nil - - # Default priority for country inputs. - # config.country_priority = nil - - # When false, do not use translations for labels. - # config.translate_labels = true - - # Automatically discover new inputs in Rails' autoload path. - # config.inputs_discovery = true - - # Cache SimpleForm inputs discovery - # config.cache_discovery = !Rails.env.development? - - # Default class for inputs - # config.input_class = nil - - # Define the default class of the input wrapper of the boolean input. - config.boolean_label_class = 'checkbox' - - # Defines if the default input wrapper class should be included in radio - # collection wrappers. - # config.include_default_input_wrapper_class = true - - # Defines which i18n scope will be used in Simple Form. - # config.i18n_scope = 'simple_form' -end diff --git a/config/routes.rb b/config/routes.rb index ed4b186..112dfc9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,7 +7,12 @@ get 'contacts' => 'static_pages#contacts' get 'about_us' => 'static_pages#about_us' - resources :folders + resources :folders do + collection do + get :folders_tree + get :folders_form + end + end resources :users root 'static_pages#landing' From 7fb011d91c61c4f09419f0ff6ee69670bbde8044 Mon Sep 17 00:00:00 2001 From: Petro Koriakin Date: Sun, 22 Feb 2015 14:17:00 +0200 Subject: [PATCH 4/5] add link to parent --- app/controllers/folders_controller.rb | 3 +-- app/views/folders/_folder.html.slim | 34 ++------------------------- app/views/folders/index.html.slim | 6 ++--- app/views/folders/show.html.slim | 9 ++++++- 4 files changed, 14 insertions(+), 38 deletions(-) diff --git a/app/controllers/folders_controller.rb b/app/controllers/folders_controller.rb index 6951e45..9e63587 100644 --- a/app/controllers/folders_controller.rb +++ b/app/controllers/folders_controller.rb @@ -12,8 +12,7 @@ def new end def index - @folder = Folder.new - @folders = Folder.all + @folders = Folder.roots end def create diff --git a/app/views/folders/_folder.html.slim b/app/views/folders/_folder.html.slim index 0deb464..4f56bb4 100644 --- a/app/views/folders/_folder.html.slim +++ b/app/views/folders/_folder.html.slim @@ -1,32 +1,2 @@ -.folder - /.created_at - / = folder.created_at.strftime("%B %d, %Y") - ul - - .name - li - = folder.name - li - - /.actions - / = link_to "Create subfolder", new_folder_path(parent_id: folder) - /= "|" - /= link_to "Destroy", folder, method: :delete, data: {confirm: "Are you sure?"} - -thead - -tbody -tr -td -td -td -td -td -td -- if @folder -tr -td.up colspan="5" -= link_to @folder.parent || root_path - -span -| .. \ No newline at end of file +li + = link_to folder.name, folder_path(folder) diff --git a/app/views/folders/index.html.slim b/app/views/folders/index.html.slim index 433ca6a..625434b 100644 --- a/app/views/folders/index.html.slim +++ b/app/views/folders/index.html.slim @@ -1,5 +1,5 @@ h1 Folders -= nested_folders @folders.arrange(:order => :created_at) - -= render "form" +ul + - @folders.each do |folder| + = render folder diff --git a/app/views/folders/show.html.slim b/app/views/folders/show.html.slim index d8cdb1d..6b98e1f 100644 --- a/app/views/folders/show.html.slim +++ b/app/views/folders/show.html.slim @@ -1 +1,8 @@ -= @folder.name \ No newline at end of file +h1 + = @folder.name + +ul + li + = link_to '/..', @folder.parent ? folder_path(@folder.parent) : folders_path + - @folder.children.each do |child| + = render child \ No newline at end of file From b0a749567ee6e5c7fa5ed1be58a7484f153da8c2 Mon Sep 17 00:00:00 2001 From: Petro Koriakin Date: Sun, 22 Feb 2015 14:23:23 +0200 Subject: [PATCH 5/5] fix navigation --- Gemfile~ | 59 -------------------- app/controllers/folders_controller.rb | 3 +- app/views/layouts/_navigation.html.slim | 2 +- app/views/layouts/_navigation_links.html.erb | 2 +- 4 files changed, 3 insertions(+), 63 deletions(-) delete mode 100644 Gemfile~ diff --git a/Gemfile~ b/Gemfile~ deleted file mode 100644 index 11e9d38..0000000 --- a/Gemfile~ +++ /dev/null @@ -1,59 +0,0 @@ -source 'https://rubygems.org' - -# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '4.2.0' - -# Use mysql as the database for Active Record -gem 'mysql2' -gem 'pg' -# Use SCSS for stylesheets -gem 'sass-rails', '~> 5.0' -# Use Uglifier as compressor for JavaScript assets -gem 'uglifier', '>= 1.3.0' -# Use CoffeeScript for .coffee assets and views -gem 'coffee-rails', '~> 4.1.0' -# See https://github.com/sstephenson/execjs#readme for more supported runtimes -# gem 'therubyracer', platforms: :ruby - -# Use jquery as the JavaScript library -gem 'jquery-rails' -# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks -gem 'turbolinks' -# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder -gem 'jbuilder', '~> 2.0' -# bundle exec rake doc:rails generates the API under doc/api. -gem 'sdoc', '~> 0.4.0', group: :doc - -gem 'slim' - -gem 'pry-rails' - -# Use ActiveModel has_secure_password -# gem 'bcrypt', '~> 3.1.7' - -# Use Unicorn as the app server -# gem 'unicorn' - -# Use Capistrano for deployment -# gem 'capistrano-rails', group: :development - -gem 'devise', '~> 3.4.1' -gem 'bootstrap-sass', '~> 3.3.1.0' -gem 'devise-bootstrap-views', '~> 0.0.3' -gem 'execjs' -gem 'therubyracer' -gem 'omniauth-facebook' -gem 'ancestry' - - -group :development, :test do - # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem 'byebug' - - # Access an IRB console on exception pages or by using <%= console %> in views - gem 'web-console', '~> 2.0' - - # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring - gem 'spring' - gem 'rspec-rails' -end diff --git a/app/controllers/folders_controller.rb b/app/controllers/folders_controller.rb index 9e63587..a51ee90 100644 --- a/app/controllers/folders_controller.rb +++ b/app/controllers/folders_controller.rb @@ -1,6 +1,5 @@ class FoldersController < ApplicationController - before_action :authenticate_user! def show @@ -17,7 +16,7 @@ def index def create @folder = Folder.create folder_params - redirect_to folders_path + redirect_to folders_tree_folders_path end def destroy diff --git a/app/views/layouts/_navigation.html.slim b/app/views/layouts/_navigation.html.slim index f62f164..1255ad3 100644 --- a/app/views/layouts/_navigation.html.slim +++ b/app/views/layouts/_navigation.html.slim @@ -7,7 +7,7 @@ nav.navbar.navbar-inverse.navbar-fixed-top span.icon-bar span.icon-bar span.icon-bar - = link_to 'Home', root_path, class: 'navbar-brand' + = link_to 'Home', folders_path, class: 'navbar-brand' .collapse.navbar-collapse ul.nav.navbar-nav = render 'layouts/navigation_links' \ No newline at end of file diff --git a/app/views/layouts/_navigation_links.html.erb b/app/views/layouts/_navigation_links.html.erb index c815701..de9dcb5 100644 --- a/app/views/layouts/_navigation_links.html.erb +++ b/app/views/layouts/_navigation_links.html.erb @@ -9,7 +9,7 @@ <% end %> <% if user_signed_in? %>
  • <%= link_to 'Users', users_path %>
  • -
  • <%= link_to 'Folders', folders_path %>
  • +
  • <%= link_to 'Folders', folders_tree_folders_path %>
  • <% end %>
  • <%= link_to 'Used Technologies', tools_path %>
  • <%= link_to 'About Us', about_us_path %>