English
Tramway::Landing
It uses Material Design Bootstrap by default
Want to upgrade gem version? Don't forget to look at migration doc
Description
Tramway-landing provides several types of blocks for main page.
List of blocks:
- Header
- Header with form
- Footer
- Block with text and image
- Block with text, image and button
- Cards
- Features list
- Contacts, also Contacts without map
- View
- Just text
- Link to the object
All block's previews you can see at the bottom of this Readme
Installation
1. Add this line to your application's Gemfile:
gem 'tramway-landing'
2. Then run:
rails g tramway:landing:install
rails db:migrate
3. Add landing blocks to the initializer
config/initializers/tramway.rb
Tramway::Admin.set_available_models ::Tramway::Landing::Block, project: #{project_name_which_you_use_in_the_application}
Tramway::Admin.navbar_structure ::Tramway::Landing::Block
4. Add PhotoVersions
to middleware (will be removed soon)
lib/middleware/tramway/landing_middleware.rb
module Tramway
class LandingMiddleware
def initialize(app)
@app = app
end
def call(env)
PhotoUploader.include Tramway::Landing::PhotoVersions
@app.call(env)
end
end
end
confing/initializers/application.rb
...
require_relative '../lib/middleware/tramway/landing_middleware'
...
module YourApplication
class Application < Rails::Application
config.middleware.use = ::Tramway::LandingMiddleware
end
end
5. Run server rails s
6. Open localhost:3000/admin
7. Click on Blocks
, add new block with type Header
8. Click Show
in the block menu
9. Then create your main page controller rails g controller web/welcome
app/controllers/web/welcome_controller.rb
class Web::WelcomeController < ApplicationController
before_action :application
layout 'tramway/landing/application'
def index
@blocks = ::Tramway::Landing::BlockDecorator.decorate ::Tramway::Landing::Block.on_main_page
end
private
def application
@application = ::Tramway::Core.application_object
end
end
10. Add new controller to the routes
config/routes.rb
# ...
root to: 'web/welcome#index'
# ...
11. Add view for the new landing
app/views/web/welcome/index.html.haml
= content_for :title do
-# your content for <title>
= content_for :application_name do
-# your content for h1
= content_for :application_tagline do
-# tagline in the header type block
= content_for :address do
-# main address info
= content_for :phone do
-# main phone info
= content_for :footer_links do
-# list of footer links
= content_for :footer_logo do
-# list of footer logos
= content_for :latitude do
-# latitude for contacts block type map
= content_for :longtitude do
-# longtitude for contacts block type map
-# everything you want on the main page
Head Content
Tramway::Landing 2.x
It will push this content to <head>
tag in every landing page. Including public page in tramway-event
, tramway-sport_school
, tramway-conference
, tramway-news
, tramway-page
gems.
config/initializers/tramway.rb
::Tramway::Landing.head_content = lambda do
concat javascript_include_tag :application
concat stylesheet_link_tag :application
# don't forget to use `concat` method here
end
Tramway::Landing 1.x
It will push this content to <head>
tag only on main page. You aren't able to manage head tag in other gems and pages.
app/views/web/welcome/index.html.haml
= content_for :head_content do
-# your content for <head>
Then all your showing blocks will be on the main page.
Migrate from tramway-landing 2.x to tramway-landing 3.x
1. Add tramway-page gem to the Gemfile
Gemfile
gem 'tramway-page', '>= 1.4.1'
2. Run install generator of tramway-page gem
rails g tramway:page:install
3. Run upgraded generator of tramway-landing gem
rails g tramway:landing:install
4. Create new Tramway::Page::Page object for main page
$> rails c
Tramway::Page::Page.create! title: 'Main page', page_type: :main
5. Associate every Tramway::Landing::Block with the main page
$> rails c
Tramway::Landing::Block.update_all page_id: Tramway::Page::Page.last.id
Blocks docs
How create blocks you can find here
- Header
- Header with form
- Footer
- Block with text and image
- Block with text, image and button
- Cards
- Features list
- Contacts
- Contacts without map
- View
- Just text
- Link to object
Tools
Google Tag Manager, Google Analytics, Yandex Metrika
1. Add landing tools to the initializer
config/initializers/tramway.rb
Tramway::Admin.set_available_models(
::Tramway::Landing::Block,
::Tramway::Landing::Tool,
project: #{project_name_which_you_use_in_the_application}
)
Tramway::Admin.(
::Tramway::Landing::Block,
::Tramway::Landing::Tool
)
2. Click on Tools
, create new tool with type [Google Tag Manager, Google Analytics, Yandex Metrika]
and add account_id for your profile in this tool.
3. Add to WelcomeController
query to get @tools
app/controllers/web/welcome_controller.rb
class Web::WelcomeController < ApplicationController
before_action :application
layout 'tramway/landing/application'
def index
@blocks = ::Tramway::Landing::BlockDecorator.decorate ::Tramway::Landing::Block.on_main_page
@tools = ::Tramway::Landing::Tool.active
end
private
def application
@application = ::Tramway::Core.application_object
end
end
And now all we need to integrate tool to your web page will be integrated automatically. Enjoy!
Contributing
Contribution directions go here.
License
The gem is available as open source under the terms of the MIT License.
Русский
Инструкцию по созданию блоков, Вы можете посмотреть здесь
- Начальный (Header)
- Начальный блок с формой (Header)
- Подвал (Footer)
- Свободный блок (картинка+текст)
- Свободный блок с кнопкой (картинка + текст + кнопка)
- Карточки (выводит опредеделенный набор карточек)-программируется
- Список возможностей-программируется
- Блок с контактами
- Представление
- Просто текст
- Ссылка на объект