Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Menus #38

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby `cat .ruby-version`.chomp.tr('ruby-', '')

'master'.tap do |branch|
gem 'alchemy_cms', github: 'AlchemyCMS/alchemy_cms', branch: branch
gem 'alchemy_cms', github: 'tvdeyen/alchemy_cms', branch: 'add-menus'
gem 'alchemy-devise', github: 'AlchemyCMS/alchemy-devise', branch: branch
gem 'alchemy_i18n', github: 'AlchemyCMS/alchemy_i18n', branch: branch
gem 'alchemy_cloudinary', github: 'AlchemyCMS/alchemy_cloudinary', branch: branch
Expand Down
20 changes: 10 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@ GIT
cloudinary (~> 1.9)

GIT
remote: https://github.com/AlchemyCMS/alchemy_cms.git
revision: 93dd8c0ce56dcac9191e9d290109d8f7f44c4144
remote: https://github.com/AlchemyCMS/alchemy_i18n.git
revision: 286d7bab2b428129daa4a955d487c36be1e5503f
branch: master
specs:
alchemy_i18n (1.0.0)
alchemy_cms (>= 4.1.0.beta, < 5.0)

GIT
remote: https://github.com/tvdeyen/alchemy_cms.git
revision: 6058b44a139d744778f4eee666fcca26cd8009b4
branch: add-menus
specs:
alchemy_cms (4.4.0.alpha)
active_model_serializers (~> 0.10.0)
Expand All @@ -53,14 +61,6 @@ GIT
simple_form (>= 4.0, < 6)
turbolinks (>= 2.5)

GIT
remote: https://github.com/AlchemyCMS/alchemy_i18n.git
revision: 286d7bab2b428129daa4a955d487c36be1e5503f
branch: master
specs:
alchemy_i18n (1.0.0)
alchemy_cms (>= 4.1.0.beta, < 5.0)

GEM
remote: https://rubygems.org/
specs:
Expand Down
7 changes: 7 additions & 0 deletions app/views/alchemy/menus/footer_navigation/_node.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<%= content_tag :li do %>
<%= link_to_if node.url,
node.name,
@preview_mode ? 'javascript: void(0)' : node.url,
target: node.external? ? '_blank' : nil,
rel: node.nofollow? ? 'nofollow' : nil %>
<% end %>
6 changes: 6 additions & 0 deletions app/views/alchemy/menus/footer_navigation/_wrapper.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<ul class="inline-list right">
<%= render partial: options[:node_partial_name],
collection: node.children.includes(:page, :children),
locals: { options: options },
as: 'node' %>
</ul>
8 changes: 8 additions & 0 deletions app/views/alchemy/menus/main_navigation/_node.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<%= content_tag :li, class: ['nav-item', node.children.any? ? 'dropdown' : nil].compact do %>
<%= link_to_if node.url,
node.name,
@preview_mode ? 'javascript: void(0)' : node.url,
class: ['button', current_page?(node.url) ? 'active' : nil].compact,
target: node.external? ? '_blank' : nil,
rel: node.nofollow? ? 'nofollow' : nil %>
<% end %>
6 changes: 6 additions & 0 deletions app/views/alchemy/menus/main_navigation/_wrapper.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<ul class="button-group">
<%= render partial: options[:node_partial_name],
collection: node.children.includes(:page, :children),
locals: { options: options },
as: 'node' %>
</ul>
2 changes: 1 addition & 1 deletion app/views/shared/_default_header.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<header class="row">
<div class="large-12 columns">
<div class="nav-bar right">
<%= render_navigation({navigation_link_partial: 'alchemy/navigation/button_link'}, {class: 'button-group'}) %>
<%= render_menu('Main Navigation') %>
</div>
<h1>
<small><%= @page && @page.title %></small></h1>
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_footer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<%= render_elements(only: 'social_button', from_page: footer_page) %>
</div>
<div class="large-4 columns">
<%= render_elements(only: 'footer_links', from_page: footer_page) %>
<%= render_menu('Footer Navigation') %>
</div>
<% end %>
</div>
Expand Down
24 changes: 24 additions & 0 deletions db/migrate/20191107080120_create_alchemy_nodes.alchemy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This migration comes from alchemy (originally 20191029212236)
class CreateAlchemyNodes < ActiveRecord::Migration[5.0]
def change
create_table :alchemy_nodes do |t|
t.string :name
t.string :title
t.string :url
t.boolean :nofollow, null: false, default: false
t.boolean :external, null: false, default: false

t.integer :parent_id, index: true
t.integer :lft, null: false, index: true
t.integer :rgt, null: false, index: true
t.integer :depth, null: false, default: 0

t.references :page, foreign_key: { to_table: :alchemy_pages }
t.references :language, null: false, foreign_key: { to_table: :alchemy_languages }
t.references :creator, index: true
t.references :updater, index: true

t.timestamps
end
end
end
29 changes: 28 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2019_11_07_075514) do
ActiveRecord::Schema.define(version: 2019_11_07_080120) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -219,6 +219,31 @@
t.index ["urlname"], name: "index_alchemy_legacy_page_urls_on_urlname"
end

create_table "alchemy_nodes", id: :serial, force: :cascade do |t|
t.string "name"
t.string "title"
t.string "url"
t.boolean "nofollow", default: false, null: false
t.boolean "external", default: false, null: false
t.integer "parent_id"
t.integer "lft", null: false
t.integer "rgt", null: false
t.integer "depth", default: 0, null: false
t.integer "page_id"
t.integer "language_id", null: false
t.integer "creator_id"
t.integer "updater_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["creator_id"], name: "index_alchemy_nodes_on_creator_id"
t.index ["language_id"], name: "index_alchemy_nodes_on_language_id"
t.index ["lft"], name: "index_alchemy_nodes_on_lft"
t.index ["page_id"], name: "index_alchemy_nodes_on_page_id"
t.index ["parent_id"], name: "index_alchemy_nodes_on_parent_id"
t.index ["rgt"], name: "index_alchemy_nodes_on_rgt"
t.index ["updater_id"], name: "index_alchemy_nodes_on_updater_id"
end

create_table "alchemy_pages", id: :serial, force: :cascade do |t|
t.string "name"
t.string "urlname"
Expand Down Expand Up @@ -367,4 +392,6 @@
add_foreign_key "alchemy_elements", "alchemy_cells", column: "cell_id", name: "alchemy_elements_cell_id_fkey", on_update: :cascade, on_delete: :cascade
add_foreign_key "alchemy_elements", "alchemy_pages", column: "page_id", name: "alchemy_elements_page_id_fkey", on_update: :cascade, on_delete: :cascade
add_foreign_key "alchemy_essence_pages", "alchemy_pages", column: "page_id"
add_foreign_key "alchemy_nodes", "alchemy_languages", column: "language_id"
add_foreign_key "alchemy_nodes", "alchemy_pages", column: "page_id"
end