From 941958b8777c339279b1b918dae20b2f730d5831 Mon Sep 17 00:00:00 2001 From: "esref.viduslu" Date: Thu, 30 Nov 2017 17:26:55 +0300 Subject: [PATCH] ARI-119 #time 8h - Landing pages created. --- bin/build_app | 10 ++--- lib/cybele.rb | 1 + lib/cybele/app_builder.rb | 1 + lib/cybele/generators/app_generator.rb | 15 ++++--- lib/cybele/helpers/landing_pages.rb | 28 +++++++++++++ templates/config/locales/view.en.yml | 14 ++++++- templates/config/locales/view.tr.yml | 14 ++++++- templates/docker/docker_env_local.erb | 2 +- templates/landing_pages/about.html.haml.erb | 3 ++ .../landing_pages/application.html.haml.erb | 34 ++++++++++++++++ templates/landing_pages/contact.html.haml.erb | 3 ++ templates/landing_pages/landing_route.erb | 9 +++++ .../partials/_warnings.html.haml.erb | 3 ++ templates/landing_pages/welcome_controller.rb | 10 +++++ .../landing_pages/welcome_index.html.haml.erb | 16 ++++++++ .../assets/stylesheets/application.css.sass | 40 +++++++++++++++++++ 16 files changed, 190 insertions(+), 13 deletions(-) create mode 100644 lib/cybele/helpers/landing_pages.rb create mode 100644 templates/landing_pages/about.html.haml.erb create mode 100644 templates/landing_pages/application.html.haml.erb create mode 100644 templates/landing_pages/contact.html.haml.erb create mode 100644 templates/landing_pages/landing_route.erb create mode 100644 templates/landing_pages/partials/_warnings.html.haml.erb create mode 100644 templates/landing_pages/welcome_controller.rb create mode 100644 templates/landing_pages/welcome_index.html.haml.erb diff --git a/bin/build_app b/bin/build_app index cd07503..a94511e 100755 --- a/bin/build_app +++ b/bin/build_app @@ -4,9 +4,9 @@ echo "Build cybele gem" ./bin/build_gem -# Remove dummy_app -echo "Remove dummy_app" -rm -rf tmp/dummy_app +# Remove example +echo "Remove test" +rm -rf tmp/example # Disable spring export DISABLE_SPRING=1 @@ -14,5 +14,5 @@ export DISABLE_SPRING=1 # ps ax | grep spring | grep dummy_app | cut -f1 -d' ' | xargs kill # Create dummy_app -echo "Create dummy_app" -cybele tmp/dummy_app --skip-create-database \ No newline at end of file +echo "Create example" +cybele tmp/example --skip-ask \ No newline at end of file diff --git a/lib/cybele.rb b/lib/cybele.rb index d0cc6a1..1603166 100644 --- a/lib/cybele.rb +++ b/lib/cybele.rb @@ -20,4 +20,5 @@ require 'cybele/helpers/view_files/assets_files' require 'cybele/helpers/view_files/view_gems' require 'cybele/helpers/pronto' +require 'cybele/helpers/landing_pages' require 'cybele/app_builder' diff --git a/lib/cybele/app_builder.rb b/lib/cybele/app_builder.rb index 0550ec3..ba952dd 100644 --- a/lib/cybele/app_builder.rb +++ b/lib/cybele/app_builder.rb @@ -20,6 +20,7 @@ class AppBuilder < Rails::AppBuilder include Cybele::Helpers::ViewFiles::ViewGems include Cybele::Helpers::Docker include Cybele::Helpers::Pronto + include Cybele::Helpers::LandingPages def readme template 'README.md.erb', diff --git a/lib/cybele/generators/app_generator.rb b/lib/cybele/generators/app_generator.rb index cf634e4..354a5e3 100644 --- a/lib/cybele/generators/app_generator.rb +++ b/lib/cybele/generators/app_generator.rb @@ -245,11 +245,6 @@ def customize_view_files build :customize_assets_files end - def setup_git_and_git_flow - say 'Initialize git and git flow' - build :git_and_git_flow_commands - end - def docker_development_env return if @options[:skip_docker] say 'Setup docker development environment', :green @@ -261,6 +256,16 @@ def setup_pronto_config build :configure_pronto end + def setup_landing_pages + say 'Generate Landing Pages' + build :generate_landing_pages + end + + def setup_git_and_git_flow + say 'Initialize git and git flow' + build :git_and_git_flow_commands + end + def goodbye say 'Congratulations! That\'s all...', :green end diff --git a/lib/cybele/helpers/landing_pages.rb b/lib/cybele/helpers/landing_pages.rb new file mode 100644 index 0000000..96a3c1c --- /dev/null +++ b/lib/cybele/helpers/landing_pages.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Cybele + module Helpers + module LandingPages + def generate_landing_pages + # Edit application file + template 'landing_pages/application.html.haml.erb', + 'app/views/layouts/application.html.haml', force: true + + # Welcome_controller route + inject_into_file 'config/routes.rb', + template_content('landing_pages/landing_route.erb'), + before: ' if Rails.env.production? || Rails.env.staging?' + + # Welcome_controller and welcome/index.html.haml + copy_file 'landing_pages/welcome_controller.rb', 'app/controllers/welcome_controller.rb' + template 'landing_pages/welcome_index.html.haml.erb', 'app/views/welcome/index.html.haml', force: true + template 'landing_pages/about.html.haml.erb', 'app/views/welcome/about.html.haml', force: true + template 'landing_pages/contact.html.haml.erb', 'app/views/welcome/contact.html.haml', force: true + + # Partials + template 'landing_pages/partials/_warnings.html.haml.erb', + 'app/views/layouts/partials/_warnings.html.haml', force: true + end + end + end +end \ No newline at end of file diff --git a/templates/config/locales/view.en.yml b/templates/config/locales/view.en.yml index 3373fc5..1d0399e 100644 --- a/templates/config/locales/view.en.yml +++ b/templates/config/locales/view.en.yml @@ -2,4 +2,16 @@ en: view: error: internal_server_error: "We are sorry. An error occured. Our engineers are working on it. We will solve it as soon as possible." - not_found: "We are sorry. Page was not found. It may have been moved." \ No newline at end of file + not_found: "We are sorry. Page was not found. It may have been moved." + navbar: + settings: Settings + signup: Signup + signin: Signin + sign_out: Sign Out + edit_login_info: Edit Login Info + edit_profile_info: Edit Profile Info + home_page: Home Page + admin_portal: Admin Portal + profile: Profile + about: About + contact: Contact \ No newline at end of file diff --git a/templates/config/locales/view.tr.yml b/templates/config/locales/view.tr.yml index ce108f7..9788925 100644 --- a/templates/config/locales/view.tr.yml +++ b/templates/config/locales/view.tr.yml @@ -2,4 +2,16 @@ tr: view: error: internal_server_error: "Üzgünüz. Şu anda bir hata var. Mühendislerimiz bu hata üzerinde çalışma yapıyorlar. En kısa sürede çözeceğiz." - not_found: "Üzgünüz. Bu sayfa bulunamadı. Taşınmış olabilir. Buraya gitmek istediğinizden emin olun." \ No newline at end of file + not_found: "Üzgünüz. Bu sayfa bulunamadı. Taşınmış olabilir. Buraya gitmek istediğinizden emin olun." + navbar: + settings: Ayarlar + signup: Kayıt ol + signin: Giriş Yap + sign_out: Çıkış yap + edit_login_info: Giriş bilgilerini güncelle + edit_profile_info: Profil bilgilerini güncelle + home_page: Anasayfa + admin_portal: Yönetici Portalı + profile: Profil + about: Hakkında + contact: İletişim \ No newline at end of file diff --git a/templates/docker/docker_env_local.erb b/templates/docker/docker_env_local.erb index df04f73..707604d 100644 --- a/templates/docker/docker_env_local.erb +++ b/templates/docker/docker_env_local.erb @@ -6,5 +6,5 @@ REDISTOGO_URL=redis://redis:6379/0 # Set Rails/Rack environment RACK_ENV=development -POSTGRESQL_HOST=postgres +# POSTGRESQL_HOST=postgres REDIS_HOST=redis \ No newline at end of file diff --git a/templates/landing_pages/about.html.haml.erb b/templates/landing_pages/about.html.haml.erb new file mode 100644 index 0000000..ef4805f --- /dev/null +++ b/templates/landing_pages/about.html.haml.erb @@ -0,0 +1,3 @@ +.row.about-contact + %h4 About + %p Donec id elit non mi porta gravida at eget metus. Maecenas faucibus mollis interdum. \ No newline at end of file diff --git a/templates/landing_pages/application.html.haml.erb b/templates/landing_pages/application.html.haml.erb new file mode 100644 index 0000000..ecda46b --- /dev/null +++ b/templates/landing_pages/application.html.haml.erb @@ -0,0 +1,34 @@ +!!! +%html{lang: I18n.locale} + %head + %title= content_for?(:title) ? "#{yield(:title)} - <%= app_name.capitalize %>" : '<%= app_name.capitalize %>' + %meta(http-equiv="content-type" content="text/html" charset="utf-8") + %meta(http-equiv="x-ua-compatible" content="ie=edge,chrome=1") + %meta(name="description" content="<%= app_name.capitalize %>") + %meta(name="author" content="<%= app_name.capitalize %>") + %link(rel="shortcut icon" href="/images/favicon.png") + + = stylesheet_link_tag 'application', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', + media: 'all', 'data-turbolinks-track' => true + = javascript_include_tag 'application', 'data-turbolinks-track' => true + = csrf_meta_tags + = yield :headls + %body + = render 'layouts/partials/warnings' + .container-narrow + .header + %nav + / Brand and toggle get grouped for better mobile display + = link_to root_path, class: 'navbar-brand' do + %i.fa.fa-home + = "<%= app_name.capitalize %>" + %ul.nav.nav-pills.float-right + %li.nav-item + %a.nav-link{href: about_welcome_index_path} + = t('navbar.about') + %li.nav-item + %a.nav-link{href: contact_welcome_index_path} + = t('navbar.contact') + = yield + .footer + %p Dummy_app Copyright © #{Time.zone.now.year} Tüm Hakları Saklıdır. \ No newline at end of file diff --git a/templates/landing_pages/contact.html.haml.erb b/templates/landing_pages/contact.html.haml.erb new file mode 100644 index 0000000..ef19e73 --- /dev/null +++ b/templates/landing_pages/contact.html.haml.erb @@ -0,0 +1,3 @@ +.row.about-contact + %h4 Contact + %p Donec id elit non mi porta gravida at eget metus. Maecenas faucibus mollis interdum. diff --git a/templates/landing_pages/landing_route.erb b/templates/landing_pages/landing_route.erb new file mode 100644 index 0000000..d1b2506 --- /dev/null +++ b/templates/landing_pages/landing_route.erb @@ -0,0 +1,9 @@ + + # Common pages + root to: 'welcome#index' + + resources :welcome, path: '', only: :index do + get :about, on: :collection + get :contact, on: :collection + end + diff --git a/templates/landing_pages/partials/_warnings.html.haml.erb b/templates/landing_pages/partials/_warnings.html.haml.erb new file mode 100644 index 0000000..ca0b8d3 --- /dev/null +++ b/templates/landing_pages/partials/_warnings.html.haml.erb @@ -0,0 +1,3 @@ +- if Rails.env.staging? + #warnings.alert.alert-warning.panel-reset.text-center{style: 'margin-bottom: 10px;' } + = t('staging_warning').html_safe \ No newline at end of file diff --git a/templates/landing_pages/welcome_controller.rb b/templates/landing_pages/welcome_controller.rb new file mode 100644 index 0000000..23178ac --- /dev/null +++ b/templates/landing_pages/welcome_controller.rb @@ -0,0 +1,10 @@ +class WelcomeController < ApplicationController + def index + end + + def about + end + + def contact + end +end \ No newline at end of file diff --git a/templates/landing_pages/welcome_index.html.haml.erb b/templates/landing_pages/welcome_index.html.haml.erb new file mode 100644 index 0000000..4d980e6 --- /dev/null +++ b/templates/landing_pages/welcome_index.html.haml.erb @@ -0,0 +1,16 @@ +.jumbotron + %h1 Welcome to <%= app_name.capitalize %> + - if current_user + = link_to t('navbar.sign_out'), destroy_user_session_path, class: 'btn btn-large', method: :delete + .row-fluid.marketing + %p + %strong Name: + = current_user.name + %p + %strong Email: + = current_user.email + = link_to t('navbar.edit_login_info'), edit_user_registration_path, class: 'btn btn-large' + = link_to t('navbar.profile'), user_profile_path(current_user), class: 'btn btn-link' + - else + = link_to t('navbar.signup'), new_user_registration_path, class: 'btn btn-large btn-success' + = link_to t('navbar.signin'), new_user_session_path, class: 'btn btn-large' \ No newline at end of file diff --git a/templates/view_files/app/assets/stylesheets/application.css.sass b/templates/view_files/app/assets/stylesheets/application.css.sass index 19997ee..b9b5932 100644 --- a/templates/view_files/app/assets/stylesheets/application.css.sass +++ b/templates/view_files/app/assets/stylesheets/application.css.sass @@ -11,3 +11,43 @@ *= require_self @import "bootstrap" + +/* Custom container + +body + padding-top: 1.5rem + padding-bottom: 1.5rem + +.container-narrow + margin: 0 auto + max-width: 700px + > hr + margin: 30px 0 + +/* Main marketing message and sign up button +.jumbotron + margin: 60px 0 + text-align: center + h1 + font-size: 72px + line-height: 1 + .btn + font-size: 21px + padding: 14px 24px + +.header + padding-bottom: 1rem + color: #777 + border-bottom: .05rem solid #e5e5e5 + +.footer + padding-top: 1.5rem + color: #777 + border-top: .05rem solid #e5e5e5 + +/* Supporting marketing content + +.about-contact + margin: 60px 0 + p + h4 + margin-top: 28px \ No newline at end of file