diff --git a/app/assets/images/merged/card_preview/card_full_image.png b/app/assets/images/merged/card_preview/card_full_image.png new file mode 100644 index 0000000..28faabe Binary files /dev/null and b/app/assets/images/merged/card_preview/card_full_image.png differ diff --git a/app/assets/images/merged/section_preview/section_2_col.png b/app/assets/images/merged/section_preview/section_2_col.png new file mode 100644 index 0000000..b548340 Binary files /dev/null and b/app/assets/images/merged/section_preview/section_2_col.png differ diff --git a/app/assets/images/merged/section_preview/section_full_left2.png b/app/assets/images/merged/section_preview/section_full_left2.png new file mode 100644 index 0000000..725a0b7 Binary files /dev/null and b/app/assets/images/merged/section_preview/section_full_left2.png differ diff --git a/app/assets/images/merged/section_preview/section_full_up.png b/app/assets/images/merged/section_preview/section_full_up.png new file mode 100644 index 0000000..88a3d41 Binary files /dev/null and b/app/assets/images/merged/section_preview/section_full_up.png differ diff --git a/app/assets/images/merged/section_preview/section_half_left.png b/app/assets/images/merged/section_preview/section_half_left.png new file mode 100644 index 0000000..6d31b08 Binary files /dev/null and b/app/assets/images/merged/section_preview/section_half_left.png differ diff --git a/app/assets/images/merged/section_preview/section_half_right.png b/app/assets/images/merged/section_preview/section_half_right.png new file mode 100644 index 0000000..5eee23b Binary files /dev/null and b/app/assets/images/merged/section_preview/section_half_right.png differ diff --git a/app/assets/images/merged/section_preview/section_spacer.png b/app/assets/images/merged/section_preview/section_spacer.png new file mode 100644 index 0000000..ce8cba3 Binary files /dev/null and b/app/assets/images/merged/section_preview/section_spacer.png differ diff --git a/app/controllers/merged/cms_controller.rb b/app/controllers/merged/cms_controller.rb new file mode 100644 index 0000000..549d2e3 --- /dev/null +++ b/app/controllers/merged/cms_controller.rb @@ -0,0 +1,12 @@ +module Merged + class ViewController < ApplicationController + + def view + page = params[:id] + # assert file exists + @data = YAML.load_file(Rails.root.join('merge' , "#{page}.yaml")) + #assert data is an array (of hashes?) + end + + end +end diff --git a/app/controllers/merged/images_controller.rb b/app/controllers/merged/images_controller.rb new file mode 100644 index 0000000..1033582 --- /dev/null +++ b/app/controllers/merged/images_controller.rb @@ -0,0 +1,21 @@ +module Merged + + class ImagesController < MergedController + + def index + @images = Image.all + end + + def create + new_image = Image.create_new(params['filename'] , params['image_file']) + redirect = :merge_images + if(params[:redirect]) + redirect = params[:redirect].gsub("NEW" ,new_image.name) + puts "image redirect #{redirect}" + end + redirect_to redirect + end + + end + +end diff --git a/app/controllers/merged/merged_controller.rb b/app/controllers/merged/merged_controller.rb new file mode 100644 index 0000000..7433df3 --- /dev/null +++ b/app/controllers/merged/merged_controller.rb @@ -0,0 +1,6 @@ +module Merged + class MergedController < ApplicationController + layout 'merge_layout' + + end +end diff --git a/app/controllers/merged/pages_controller.rb b/app/controllers/merged/pages_controller.rb new file mode 100644 index 0000000..929c57a --- /dev/null +++ b/app/controllers/merged/pages_controller.rb @@ -0,0 +1,60 @@ +module Merged + class PagesController < MergedController + before_action :set_page, only: %i[ show edit update destroy ] + + # GET /merge/pages + def index + @pages = Merged::Page.all + end + + # GET /merge/pages/1 + def show + end + + # GET /merge/pages/new + def new + @page = Merged::Page.new + end + + # GET /merge/pages/1/edit + def edit + end + + # POST /merge/pages + def create + @page = Merged::Page.new(page_params) + + if @page.save + redirect_to @page, notice: "Page was successfully created." + else + render :new, status: :unprocessable_entity + end + end + + # PATCH/PUT /merge/pages/1 + def update + if @page.update(page_params) + redirect_to @page, notice: "Page was successfully updated." + else + render :edit, status: :unprocessable_entity + end + end + + # DELETE /merge/pages/1 + def destroy + @page.destroy + redirect_to page_url, notice: "Page was successfully destroyed." + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_page + @page = Merged::Page.find(params[:id]) + end + + # Only allow a list of trusted parameters through. + def page_params + params.fetch(:page, {}) + end + end +end diff --git a/app/controllers/merged/sections_controller.rb b/app/controllers/merged/sections_controller.rb new file mode 100644 index 0000000..c20ac1b --- /dev/null +++ b/app/controllers/merged/sections_controller.rb @@ -0,0 +1,35 @@ +module Merged + class SectionsController < MergedController + before_action :set_page, only: %i[ show edit update destroy set_image select_image] + + def select_image + @images = Image.all + end + + def set_image + @section.content["image"] = params[:image] + @page.save + redirect_to merge_page_section_url(@page.id,@section.id) + end + + def update + @section.content.each do |key , value| + next if key == "id" + if(!params[key].nil?) + @section.update(key, params[key]) + puts "updating:#{key}=#{params[key]}" + end + end + @page.save + redirect_to :merge_page_section + end + + private + def set_page + @page = Page.find(params[:page_id]) + section_id = params[:id] || params[:section_id] + @section = @page.find_section( section_id ) + end + + end +end diff --git a/app/helpers/merged/image_helper.rb b/app/helpers/merged/image_helper.rb new file mode 100644 index 0000000..0ae9975 --- /dev/null +++ b/app/helpers/merged/image_helper.rb @@ -0,0 +1,6 @@ +module Merged + + module ImageHelper + end + +end diff --git a/app/helpers/merged/pages_helper.rb b/app/helpers/merged/pages_helper.rb new file mode 100644 index 0000000..561be16 --- /dev/null +++ b/app/helpers/merged/pages_helper.rb @@ -0,0 +1,2 @@ +module Merged::PagesHelper +end diff --git a/app/helpers/merged/section_helper.rb b/app/helpers/merged/section_helper.rb new file mode 100644 index 0000000..4857e99 --- /dev/null +++ b/app/helpers/merged/section_helper.rb @@ -0,0 +1,10 @@ +module Merged::SectionHelper + + def section_form(options) + url = merge_page_section_url( @page.id , @section.id) + puts "URL #{url}" + form_tag( url , {method: :patch}) do + yield + end + end +end diff --git a/app/helpers/merged/view_helper.rb b/app/helpers/merged/view_helper.rb new file mode 100644 index 0000000..232514a --- /dev/null +++ b/app/helpers/merged/view_helper.rb @@ -0,0 +1,20 @@ +module Merged + module ViewHelper + # section should be hash with at least 'template' key + def find_template(section) + "sections/" + section["template"] + end + + def bg(section) + #{'background-image' => url('#{image_url('merge/' + section['image'])}')} + img = image_url "merge/house.jpg" + "background-image: url('#{img}');" + end + def image_for(section , classes) + image_tag("merge/#{section['image']}" , class: classes) + end + def has_button(section) + section['button'] + end + end +end diff --git a/app/models/merged/image.rb b/app/models/merged/image.rb new file mode 100644 index 0000000..d469b30 --- /dev/null +++ b/app/models/merged/image.rb @@ -0,0 +1,50 @@ +module Merged + class Image + include ActiveModel::API + include ActiveModel::Conversion + extend ActiveModel::Naming + + @@images = {} + + attr_reader :name , :type , :size , :created_at , :updated_at + + def initialize(filename) + puts "New Image #{filename}" + @name , @type = filename.split(".") + file = File.new(Rails.root.join(Image.root,filename)) + @created_at = file.birthtime + @updated_at = file.ctime + @size = (file.size/1024).to_i + end + + def self.all + return @@images unless @@images.empty? + Dir[Rails.root.join Image.root + "*.*"].each do |f| + file = f.split("/").last + self.add( file ) + end + @@images + end + + #save an io with given name (without ending, that is taken from io) + def self.create_new(filename , io) + original , ending = io.original_filename.split("/").last.split(".") + filename = original if( filename.blank? ) + full_filename = filename + "." + ending + File.open(Rails.root.join(Image.root, full_filename), "wb") do |f| + f.write( io.read ) + end + self.add( full_filename ) + end + + def self.root + "app/assets/images/merge/" + end + + private + def self.add(filename) + key = filename.split(".").first + @@images[key] = Image.new(filename) + end + end +end diff --git a/app/models/merged/page.rb b/app/models/merged/page.rb new file mode 100644 index 0000000..d761819 --- /dev/null +++ b/app/models/merged/page.rb @@ -0,0 +1,63 @@ +module Merged + class Page + include ActiveModel::API + include ActiveModel::Conversion + extend ActiveModel::Naming + + @@files = Set.new Dir.new(Rails.root.join("merge")).children + + attr_reader :name , :content + + alias :id :name + + def persisted? + false + end + + def initialize file_name + @name = file_name.split(".").first + @content = YAML.load_file(Rails.root.join("merge" , file_name)) + end + + def sections + sections = [] + @content.each_with_index do |section_data, index| + sections << Section.new(self , index, section_data) + end + sections + end + + def find_section(section_id) + @content.each_with_index do |section , index| + next unless section["id"] == section_id + return Section.new(self , index , section) + end + raise "Page #{name} as no section #{section_id}" + end + + def first_template + @content[0]["template"] + end + + def new_section + section = Hash.new + section['id'] = SecureRandom.hex(10) + @content << section + Section.new(self , 0 , section) + end + + def save + file_name = Rails.root.join("merge" , name + ".yaml") + File.write( file_name , @content.to_yaml) + end + + def self.all + @@files.collect{ |file| Page.new(file) } + end + + def self.find(name) + Page.new(name + ".yaml") + end + + end +end diff --git a/app/models/merged/section.rb b/app/models/merged/section.rb new file mode 100644 index 0000000..bfda48d --- /dev/null +++ b/app/models/merged/section.rb @@ -0,0 +1,53 @@ +module Merged + class Section + include ActiveModel::API + include ActiveModel::Conversion + extend ActiveModel::Naming + + attr_reader :name , :content , :page , :index + + def persisted? + false + end + + def initialize(page , index , section_data) + @page = page + raise "No number #{index}" unless index.is_a?(Integer) + raise "No has #{section_data}" unless section_data.is_a?(Hash) + @index = index + @content = section_data + end + + def update(key , value) + return if key == "id" #not updating that + if(! @content[key].nil? ) + if( @content[key].class != value.class ) + raise "Type mismatch #{key} #{key.class}!=#{value.class}" + end + end + @content[key] = value + end + + def template + @content["template"] + end + + def id + @content["id"] + end + + def save + raise "Called" + end + + def self.all + @page.sections + end + + def self.find(page_name , section_id) + raise "buggy" + Page.new(name + ".yaml") + end + + end +end diff --git a/app/views/layouts/_footer.haml b/app/views/layouts/_footer.haml new file mode 100644 index 0000000..e20d9bf --- /dev/null +++ b/app/views/layouts/_footer.haml @@ -0,0 +1,133 @@ +%footer.bg-white{"aria-label" => "Site Footer"} + .max-w-screen-xl.px-4.py-16.mx-auto.sm:px-6.lg:px-8 + .lg:flex.lg:items-start.lg:gap-8 + .text-teal-600 + %svg.h-8{:fill => "none", :viewBox => "0 0 28 24"} + %path{:d => "M0.41 10.3847C1.14777 7.4194 2.85643 4.7861 5.2639 2.90424C7.6714 1.02234 10.6393 0 13.695 0C16.7507 0 19.7186 1.02234 22.1261 2.90424C24.5336 4.7861 26.2422 7.4194 26.98 10.3847H25.78C23.7557 10.3549 21.7729 10.9599 20.11 12.1147C20.014 12.1842 19.9138 12.2477 19.81 12.3047H19.67C19.5662 12.2477 19.466 12.1842 19.37 12.1147C17.6924 10.9866 15.7166 10.3841 13.695 10.3841C11.6734 10.3841 9.6976 10.9866 8.02 12.1147C7.924 12.1842 7.8238 12.2477 7.72 12.3047H7.58C7.4762 12.2477 7.376 12.1842 7.28 12.1147C5.6171 10.9599 3.6343 10.3549 1.61 10.3847H0.41ZM23.62 16.6547C24.236 16.175 24.9995 15.924 25.78 15.9447H27.39V12.7347H25.78C24.4052 12.7181 23.0619 13.146 21.95 13.9547C21.3243 14.416 20.5674 14.6649 19.79 14.6649C19.0126 14.6649 18.2557 14.416 17.63 13.9547C16.4899 13.1611 15.1341 12.7356 13.745 12.7356C12.3559 12.7356 11.0001 13.1611 9.86 13.9547C9.2343 14.416 8.4774 14.6649 7.7 14.6649C6.9226 14.6649 6.1657 14.416 5.54 13.9547C4.4144 13.1356 3.0518 12.7072 1.66 12.7347H0V15.9447H1.61C2.39051 15.924 3.154 16.175 3.77 16.6547C4.908 17.4489 6.2623 17.8747 7.65 17.8747C9.0377 17.8747 10.392 17.4489 11.53 16.6547C12.1468 16.1765 12.9097 15.9257 13.69 15.9447C14.4708 15.9223 15.2348 16.1735 15.85 16.6547C16.9901 17.4484 18.3459 17.8738 19.735 17.8738C21.1241 17.8738 22.4799 17.4484 23.62 16.6547ZM23.62 22.3947C24.236 21.915 24.9995 21.664 25.78 21.6847H27.39V18.4747H25.78C24.4052 18.4581 23.0619 18.886 21.95 19.6947C21.3243 20.156 20.5674 20.4049 19.79 20.4049C19.0126 20.4049 18.2557 20.156 17.63 19.6947C16.4899 18.9011 15.1341 18.4757 13.745 18.4757C12.3559 18.4757 11.0001 18.9011 9.86 19.6947C9.2343 20.156 8.4774 20.4049 7.7 20.4049C6.9226 20.4049 6.1657 20.156 5.54 19.6947C4.4144 18.8757 3.0518 18.4472 1.66 18.4747H0V21.6847H1.61C2.39051 21.664 3.154 21.915 3.77 22.3947C4.908 23.1889 6.2623 23.6147 7.65 23.6147C9.0377 23.6147 10.392 23.1889 11.53 22.3947C12.1468 21.9165 12.9097 21.6657 13.69 21.6847C14.4708 21.6623 15.2348 21.9135 15.85 22.3947C16.9901 23.1884 18.3459 23.6138 19.735 23.6138C21.1241 23.6138 22.4799 23.1884 23.62 22.3947Z", :fill => "currentColor"} + .grid.grid-cols-2.gap-8.mt-8.lg:mt-0.lg:grid-cols-5.lg:gap-y-16 + .col-span-2 + %div + %h2.text-2xl.font-bold.text-gray-900 + Get the latest news! + %p.mt-4.text-gray-500 + Lorem ipsum dolor, sit amet consectetur adipisicing elit. Esse non + cupiditate quae nam molestias. + .col-span-2.lg:col-span-3.lg:flex.lg:items-end + %form.w-full + %label.sr-only{:for => "UserEmail"} Email + .p-2.border.border-gray-100.focus-within:ring.sm:flex.sm:items-center.sm:gap-4 + %input#UserEmail.w-full.border-none.focus:border-transparent.focus:ring-transparent.sm:text-sm{:placeholder => "john@rhcp.com", :type => "email"}/ + %button.w-full.px-6.py-3.mt-1.text-sm.font-bold.tracking-wide.text-white.uppercase.transition-none.bg-teal-500.hover:bg-teal-600.sm:mt-0.sm:w-auto.sm:flex-shrink-0 + Sign Up + .col-span-2.sm:col-span-1 + %p.font-medium.text-gray-900 Services + %nav.mt-6{"aria-label" => "Footer Navigation - Services"} + %ul.space-y-4.text-sm + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "#"} + 1on1 Coaching + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "#"} + Company Review + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "#"} + Accounts Review + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "#"} + HR Consulting + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "#"} + SEO Optimisation + .col-span-2.sm:col-span-1 + %p.font-medium.text-gray-900 Company + %nav.mt-6{"aria-label" => "Footer Navigation - Company"} + %ul.space-y-4.text-sm + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "#"} + About + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "#"} + Meet the Team + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "#"} + Accounts Review + .col-span-2.sm:col-span-1 + %p.font-medium.text-gray-900 Helpful Links + %nav.mt-6{"aria-label" => "Footer Navigation - Company"} + %ul.space-y-4.text-sm + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "#"} + Contact + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "#"} + FAQs + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "#"} + Live Chat + .col-span-2.sm:col-span-1 + %p.font-medium.text-gray-900 Legal + %nav.mt-6{"aria-label" => "Footer Navigation - Legal"} + %ul.space-y-4.text-sm + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "#"} + Accessibility + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "#"} + Returns Policy + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "#"} + Refund Policy + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "#"} + Hiring Statistics + .col-span-2.sm:col-span-1 + %p.font-medium.text-gray-900 Downloads + %nav.mt-6{"aria-label" => "Footer Navigation - Downloads"} + %ul.space-y-4.text-sm + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "#"} + Marketing Calendar + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "#"} + SEO Infographics + %ul.flex.justify-start.col-span-2.gap-6.lg:col-span-5.lg:justify-end + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "/", :rel => "noreferrer", :target => "_blank"} + %span.sr-only Facebook + %svg.w-6.h-6{"aria-hidden" => "true", :fill => "currentColor", :viewBox => "0 0 24 24"} + %path{"clip-rule" => "evenodd", :d => "M22 12c0-5.523-4.477-10-10-10S2 6.477 2 12c0 4.991 3.657 9.128 8.438 9.878v-6.987h-2.54V12h2.54V9.797c0-2.506 1.492-3.89 3.777-3.89 1.094 0 2.238.195 2.238.195v2.46h-1.26c-1.243 0-1.63.771-1.63 1.562V12h2.773l-.443 2.89h-2.33v6.988C18.343 21.128 22 16.991 22 12z", "fill-rule" => "evenodd"} + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "/", :rel => "noreferrer", :target => "_blank"} + %span.sr-only Instagram + %svg.w-6.h-6{"aria-hidden" => "true", :fill => "currentColor", :viewBox => "0 0 24 24"} + %path{"clip-rule" => "evenodd", :d => "M12.315 2c2.43 0 2.784.013 3.808.06 1.064.049 1.791.218 2.427.465a4.902 4.902 0 011.772 1.153 4.902 4.902 0 011.153 1.772c.247.636.416 1.363.465 2.427.048 1.067.06 1.407.06 4.123v.08c0 2.643-.012 2.987-.06 4.043-.049 1.064-.218 1.791-.465 2.427a4.902 4.902 0 01-1.153 1.772 4.902 4.902 0 01-1.772 1.153c-.636.247-1.363.416-2.427.465-1.067.048-1.407.06-4.123.06h-.08c-2.643 0-2.987-.012-4.043-.06-1.064-.049-1.791-.218-2.427-.465a4.902 4.902 0 01-1.772-1.153 4.902 4.902 0 01-1.153-1.772c-.247-.636-.416-1.363-.465-2.427-.047-1.024-.06-1.379-.06-3.808v-.63c0-2.43.013-2.784.06-3.808.049-1.064.218-1.791.465-2.427a4.902 4.902 0 011.153-1.772A4.902 4.902 0 015.45 2.525c.636-.247 1.363-.416 2.427-.465C8.901 2.013 9.256 2 11.685 2h.63zm-.081 1.802h-.468c-2.456 0-2.784.011-3.807.058-.975.045-1.504.207-1.857.344-.467.182-.8.398-1.15.748-.35.35-.566.683-.748 1.15-.137.353-.3.882-.344 1.857-.047 1.023-.058 1.351-.058 3.807v.468c0 2.456.011 2.784.058 3.807.045.975.207 1.504.344 1.857.182.466.399.8.748 1.15.35.35.683.566 1.15.748.353.137.882.3 1.857.344 1.054.048 1.37.058 4.041.058h.08c2.597 0 2.917-.01 3.96-.058.976-.045 1.505-.207 1.858-.344.466-.182.8-.398 1.15-.748.35-.35.566-.683.748-1.15.137-.353.3-.882.344-1.857.048-1.055.058-1.37.058-4.041v-.08c0-2.597-.01-2.917-.058-3.96-.045-.976-.207-1.505-.344-1.858a3.097 3.097 0 00-.748-1.15 3.098 3.098 0 00-1.15-.748c-.353-.137-.882-.3-1.857-.344-1.023-.047-1.351-.058-3.807-.058zM12 6.865a5.135 5.135 0 110 10.27 5.135 5.135 0 010-10.27zm0 1.802a3.333 3.333 0 100 6.666 3.333 3.333 0 000-6.666zm5.338-3.205a1.2 1.2 0 110 2.4 1.2 1.2 0 010-2.4z", "fill-rule" => "evenodd"} + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "/", :rel => "noreferrer", :target => "_blank"} + %span.sr-only Twitter + %svg.w-6.h-6{"aria-hidden" => "true", :fill => "currentColor", :viewBox => "0 0 24 24"} + %path{:d => "M8.29 20.251c7.547 0 11.675-6.253 11.675-11.675 0-.178 0-.355-.012-.53A8.348 8.348 0 0022 5.92a8.19 8.19 0 01-2.357.646 4.118 4.118 0 001.804-2.27 8.224 8.224 0 01-2.605.996 4.107 4.107 0 00-6.993 3.743 11.65 11.65 0 01-8.457-4.287 4.106 4.106 0 001.27 5.477A4.072 4.072 0 012.8 9.713v.052a4.105 4.105 0 003.292 4.022 4.095 4.095 0 01-1.853.07 4.108 4.108 0 003.834 2.85A8.233 8.233 0 012 18.407a11.616 11.616 0 006.29 1.84"} + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "/", :rel => "noreferrer", :target => "_blank"} + %span.sr-only GitHub + %svg.w-6.h-6{"aria-hidden" => "true", :fill => "currentColor", :viewBox => "0 0 24 24"} + %path{"clip-rule" => "evenodd", :d => "M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z", "fill-rule" => "evenodd"} + %li + %a.text-gray-700.transition.hover:opacity-75{:href => "/", :rel => "noreferrer", :target => "_blank"} + %span.sr-only Dribbble + %svg.w-6.h-6{"aria-hidden" => "true", :fill => "currentColor", :viewBox => "0 0 24 24"} + %path{"clip-rule" => "evenodd", :d => "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10c5.51 0 10-4.48 10-10S17.51 2 12 2zm6.605 4.61a8.502 8.502 0 011.93 5.314c-.281-.054-3.101-.629-5.943-.271-.065-.141-.12-.293-.184-.445a25.416 25.416 0 00-.564-1.236c3.145-1.28 4.577-3.124 4.761-3.362zM12 3.475c2.17 0 4.154.813 5.662 2.148-.152.216-1.443 1.941-4.48 3.08-1.399-2.57-2.95-4.675-3.189-5A8.687 8.687 0 0112 3.475zm-3.633.803a53.896 53.896 0 013.167 4.935c-3.992 1.063-7.517 1.04-7.896 1.04a8.581 8.581 0 014.729-5.975zM3.453 12.01v-.26c.37.01 4.512.065 8.775-1.215.25.477.477.965.694 1.453-.109.033-.228.065-.336.098-4.404 1.42-6.747 5.303-6.942 5.629a8.522 8.522 0 01-2.19-5.705zM12 20.547a8.482 8.482 0 01-5.239-1.8c.152-.315 1.888-3.656 6.703-5.337.022-.01.033-.01.054-.022a35.318 35.318 0 011.823 6.475 8.4 8.4 0 01-3.341.684zm4.761-1.465c-.086-.52-.542-3.015-1.659-6.084 2.679-.423 5.022.271 5.314.369a8.468 8.468 0 01-3.655 5.715z", "fill-rule" => "evenodd"} + .pt-8.mt-8.border-t.border-gray-100 + .grid.grid-cols-1.gap-8.lg:grid-cols-2 + %p.text-xs.text-left.text-gray-500 + 2022. Company Name. All rights reserved. + %nav{"aria-label" => "Footer Navigation - Support"} + %ul.flex.flex-wrap.justify-start.gap-4.text-xs.lg:justify-end + %li + %a.text-gray-500.transition.hover:opacity-75{:href => "#"} + Terms Conditions + %li + %a.text-gray-500.transition.hover:opacity-75{:href => "#"} + Privacy Policy + %li + %a.text-gray-500.transition.hover:opacity-75{:href => "#"} + Cookies diff --git a/app/views/layouts/_header.haml b/app/views/layouts/_header.haml new file mode 100644 index 0000000..71a8844 --- /dev/null +++ b/app/views/layouts/_header.haml @@ -0,0 +1,40 @@ +%header.bg-white{"aria-label" => "Site Header"} + .mx-auto.max-w-screen-xl.px-4.sm:px-6.lg:px-8 + .flex.h-16.items-center.justify-between + .flex-1.md:flex.md:items-center.md:gap-12 + %a.block.text-teal-600{:href => "/"} + %span.sr-only Home + %svg.h-8{:fill => "none", :viewbox => "0 0 28 24", :xmlns => "http://www.w3.org/2000/svg"} + %path{:d => "M0.41 10.3847C1.14777 7.4194 2.85643 4.7861 5.2639 2.90424C7.6714 1.02234 10.6393 0 13.695 0C16.7507 0 19.7186 1.02234 22.1261 2.90424C24.5336 4.7861 26.2422 7.4194 26.98 10.3847H25.78C23.7557 10.3549 21.7729 10.9599 20.11 12.1147C20.014 12.1842 19.9138 12.2477 19.81 12.3047H19.67C19.5662 12.2477 19.466 12.1842 19.37 12.1147C17.6924 10.9866 15.7166 10.3841 13.695 10.3841C11.6734 10.3841 9.6976 10.9866 8.02 12.1147C7.924 12.1842 7.8238 12.2477 7.72 12.3047H7.58C7.4762 12.2477 7.376 12.1842 7.28 12.1147C5.6171 10.9599 3.6343 10.3549 1.61 10.3847H0.41ZM23.62 16.6547C24.236 16.175 24.9995 15.924 25.78 15.9447H27.39V12.7347H25.78C24.4052 12.7181 23.0619 13.146 21.95 13.9547C21.3243 14.416 20.5674 14.6649 19.79 14.6649C19.0126 14.6649 18.2557 14.416 17.63 13.9547C16.4899 13.1611 15.1341 12.7356 13.745 12.7356C12.3559 12.7356 11.0001 13.1611 9.86 13.9547C9.2343 14.416 8.4774 14.6649 7.7 14.6649C6.9226 14.6649 6.1657 14.416 5.54 13.9547C4.4144 13.1356 3.0518 12.7072 1.66 12.7347H0V15.9447H1.61C2.39051 15.924 3.154 16.175 3.77 16.6547C4.908 17.4489 6.2623 17.8747 7.65 17.8747C9.0377 17.8747 10.392 17.4489 11.53 16.6547C12.1468 16.1765 12.9097 15.9257 13.69 15.9447C14.4708 15.9223 15.2348 16.1735 15.85 16.6547C16.9901 17.4484 18.3459 17.8738 19.735 17.8738C21.1241 17.8738 22.4799 17.4484 23.62 16.6547ZM23.62 22.3947C24.236 21.915 24.9995 21.664 25.78 21.6847H27.39V18.4747H25.78C24.4052 18.4581 23.0619 18.886 21.95 19.6947C21.3243 20.156 20.5674 20.4049 19.79 20.4049C19.0126 20.4049 18.2557 20.156 17.63 19.6947C16.4899 18.9011 15.1341 18.4757 13.745 18.4757C12.3559 18.4757 11.0001 18.9011 9.86 19.6947C9.2343 20.156 8.4774 20.4049 7.7 20.4049C6.9226 20.4049 6.1657 20.156 5.54 19.6947C4.4144 18.8757 3.0518 18.4472 1.66 18.4747H0V21.6847H1.61C2.39051 21.664 3.154 21.915 3.77 22.3947C4.908 23.1889 6.2623 23.6147 7.65 23.6147C9.0377 23.6147 10.392 23.1889 11.53 22.3947C12.1468 21.9165 12.9097 21.6657 13.69 21.6847C14.4708 21.6623 15.2348 21.9135 15.85 22.3947C16.9901 23.1884 18.3459 23.6138 19.735 23.6138C21.1241 23.6138 22.4799 23.1884 23.62 22.3947Z", :fill => "currentColor"} + .md:flex.md:items-center.md:gap-12 + %nav.hidden.md:block{"aria-label" => "Site Nav"} + %ul.flex.items-center.gap-6.text-sm + %li + %a.text-gray-500.transition{:class => "hover:text-gray-500/75", :href => "/"} + About + %li + %a.text-gray-500.transition{:class => "hover:text-gray-500/75", :href => "/"} + Careers + %li + %a.text-gray-500.transition{:class => "hover:text-gray-500/75", :href => "/"} + History + %li + %a.text-gray-500.transition{:class => "hover:text-gray-500/75", :href => "/"} + Services + %li + %a.text-gray-500.transition{:class => "hover:text-gray-500/75", :href => "/"} + Projects + %li + %a.text-gray-500.transition{:class => "hover:text-gray-500/75", :href => "/"} + Blog + .flex.items-center.gap-4 + .sm:flex.sm:gap-4 + %a.rounded-md.bg-teal-600.px-5.text-sm.font-medium.text-white.shadow{:class => "py-2.5", :href => "/"} + Login + .hidden.sm:flex + %a.rounded-md.bg-gray-100.px-5.text-sm.font-medium.text-teal-600{:class => "py-2.5", :href => "/"} + Register + .block.md:hidden + %button.rounded.bg-gray-100.p-2.text-gray-600.transition{:class => "hover:text-gray-600/75"} + %svg.h-5.w-5{:fill => "none", :stroke => "currentColor", "stroke-width" => "2", :viewbox => "0 0 24 24", :xmlns => "http://www.w3.org/2000/svg"} + %path{:d => "M4 6h16M4 12h16M4 18h16", "stroke-linecap" => "round", "stroke-linejoin" => "round"} diff --git a/app/views/layouts/application.haml b/app/views/layouts/application.haml new file mode 100644 index 0000000..94c1830 --- /dev/null +++ b/app/views/layouts/application.haml @@ -0,0 +1,16 @@ +!!! +%html + %head + %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/ + %title Gateway + %meta{:content => "width=device-width,initial-scale=1", :name => "viewport"}/ + = csrf_meta_tags + = csp_meta_tag + %link{:href => "https://cdn.jsdelivr.net/npm/tw-elements/dist/css/index.min.css", :rel => "stylesheet"} + = stylesheet_link_tag "application" + = stylesheet_link_tag "tailwind" + = javascript_importmap_tags + %body + =render "layouts/header" + = yield + =render "layouts/footer" diff --git a/app/views/layouts/cms_layout.haml b/app/views/layouts/cms_layout.haml new file mode 100644 index 0000000..64a8a9f --- /dev/null +++ b/app/views/layouts/cms_layout.haml @@ -0,0 +1,49 @@ +!!! +%html + %head + %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/ + %title Gateway + %meta{:content => "width=device-width,initial-scale=1", :name => "viewport"}/ + = csrf_meta_tags + = csp_meta_tag + %link{:href => "https://cdn.jsdelivr.net/npm/tw-elements/dist/css/index.min.css", :rel => "stylesheet"} + = stylesheet_link_tag "application" + = stylesheet_link_tag "tailwind" + = javascript_importmap_tags + %body + %header.bg-white{"aria-label" => "Site Header"} + .mx-auto.max-w-screen-xl.px-4.sm:px-6.lg:px-8 + .flex.h-16.items-center.justify-between + .flex-1.md:flex.md:items-center.md:gap-12 + %a.block.text-teal-600{:href => "/"} + %span.sr-only Home + %svg.h-8{:fill => "none", :viewbox => "0 0 28 24", :xmlns => "http://www.w3.org/2000/svg"} + %path{:d => "M0.41 10.3847C1.14777 7.4194 2.85643 4.7861 5.2639 2.90424C7.6714 1.02234 10.6393 0 13.695 0C16.7507 0 19.7186 1.02234 22.1261 2.90424C24.5336 4.7861 26.2422 7.4194 26.98 10.3847H25.78C23.7557 10.3549 21.7729 10.9599 20.11 12.1147C20.014 12.1842 19.9138 12.2477 19.81 12.3047H19.67C19.5662 12.2477 19.466 12.1842 19.37 12.1147C17.6924 10.9866 15.7166 10.3841 13.695 10.3841C11.6734 10.3841 9.6976 10.9866 8.02 12.1147C7.924 12.1842 7.8238 12.2477 7.72 12.3047H7.58C7.4762 12.2477 7.376 12.1842 7.28 12.1147C5.6171 10.9599 3.6343 10.3549 1.61 10.3847H0.41ZM23.62 16.6547C24.236 16.175 24.9995 15.924 25.78 15.9447H27.39V12.7347H25.78C24.4052 12.7181 23.0619 13.146 21.95 13.9547C21.3243 14.416 20.5674 14.6649 19.79 14.6649C19.0126 14.6649 18.2557 14.416 17.63 13.9547C16.4899 13.1611 15.1341 12.7356 13.745 12.7356C12.3559 12.7356 11.0001 13.1611 9.86 13.9547C9.2343 14.416 8.4774 14.6649 7.7 14.6649C6.9226 14.6649 6.1657 14.416 5.54 13.9547C4.4144 13.1356 3.0518 12.7072 1.66 12.7347H0V15.9447H1.61C2.39051 15.924 3.154 16.175 3.77 16.6547C4.908 17.4489 6.2623 17.8747 7.65 17.8747C9.0377 17.8747 10.392 17.4489 11.53 16.6547C12.1468 16.1765 12.9097 15.9257 13.69 15.9447C14.4708 15.9223 15.2348 16.1735 15.85 16.6547C16.9901 17.4484 18.3459 17.8738 19.735 17.8738C21.1241 17.8738 22.4799 17.4484 23.62 16.6547ZM23.62 22.3947C24.236 21.915 24.9995 21.664 25.78 21.6847H27.39V18.4747H25.78C24.4052 18.4581 23.0619 18.886 21.95 19.6947C21.3243 20.156 20.5674 20.4049 19.79 20.4049C19.0126 20.4049 18.2557 20.156 17.63 19.6947C16.4899 18.9011 15.1341 18.4757 13.745 18.4757C12.3559 18.4757 11.0001 18.9011 9.86 19.6947C9.2343 20.156 8.4774 20.4049 7.7 20.4049C6.9226 20.4049 6.1657 20.156 5.54 19.6947C4.4144 18.8757 3.0518 18.4472 1.66 18.4747H0V21.6847H1.61C2.39051 21.664 3.154 21.915 3.77 22.3947C4.908 23.1889 6.2623 23.6147 7.65 23.6147C9.0377 23.6147 10.392 23.1889 11.53 22.3947C12.1468 21.9165 12.9097 21.6657 13.69 21.6847C14.4708 21.6623 15.2348 21.9135 15.85 22.3947C16.9901 23.1884 18.3459 23.6138 19.735 23.6138C21.1241 23.6138 22.4799 23.1884 23.62 22.3947Z", :fill => "currentColor"} + .md:flex.md:items-center.md:gap-12 + %nav.hidden.md:block{"aria-label" => "Site Nav"} + %ul.flex.items-center.gap-6.text-sm + %li + %a.text-gray-500.transition{:class => "hover:text-gray-500/75", :href => merge_pages_path} + Pages + %li + %a.text-gray-500.transition{:class => "hover:text-gray-500/75", :href => merge_images_path} + Images + %li + %a.text-gray-500.transition{:class => "hover:text-gray-500/75", :href => "/merge/styles"} + Styles + %li + %a.text-gray-500.transition{:class => "hover:text-gray-500/75", :href => "/changes"} + Changes + .flex.items-center.gap-4 + .sm:flex.sm:gap-4 + %a.rounded-md.bg-teal-600.px-5.text-sm.font-medium.text-white.shadow{:class => "py-2.5", :href => "/"} + Login + .hidden.sm:flex + %a.rounded-md.bg-gray-100.px-5.text-sm.font-medium.text-teal-600{:class => "py-2.5", :href => "/"} + Register + .block.md:hidden + %button.rounded.bg-gray-100.p-2.text-gray-600.transition{:class => "hover:text-gray-600/75"} + %svg.h-5.w-5{:fill => "none", :stroke => "currentColor", "stroke-width" => "2", :viewbox => "0 0 24 24", :xmlns => "http://www.w3.org/2000/svg"} + %path{:d => "M4 6h16M4 12h16M4 18h16", "stroke-linecap" => "round", "stroke-linejoin" => "round"} + + = yield diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000..cbd34d2 --- /dev/null +++ b/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + +
+ + + + + + <%= yield %> + + diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000..37f0bdd --- /dev/null +++ b/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/app/views/merged/cards/_card_full_image.haml b/app/views/merged/cards/_card_full_image.haml new file mode 100644 index 0000000..5c0b773 --- /dev/null +++ b/app/views/merged/cards/_card_full_image.haml @@ -0,0 +1,7 @@ +.group.m-4.overflow-hidden.relative.flex.h-96.items-end.bg-black + = image_for( element , "absolute inset-0 h-full w-full object-cover hover:scale-110 ease-in duration-700") + .relative.w-full.bg-cyan-600.m-2.p-4.text-center.tracking-widest.text-white.transition-colors.group-hover:bg-cyan-700{:class => "sm:w-1/2"} + %h3.text-lg.uppercase + = element["header"] + %p.mt-1.text-xs.font-medium + = element["text"] diff --git a/app/views/merged/elements/_button.haml b/app/views/merged/elements/_button.haml new file mode 100644 index 0000000..a4d6c0f --- /dev/null +++ b/app/views/merged/elements/_button.haml @@ -0,0 +1,2 @@ +%a.inline-block.rounded.bg-emerald-600.px-12.py-3.text-sm.font-medium.text-white.transition.hover:bg-emerald-700.focus:outline-none.focus:ring.focus:ring-yellow-400{:href => button["link"]} + =button['text'] diff --git a/app/views/merged/images/index.haml b/app/views/merged/images/index.haml new file mode 100644 index 0000000..589a919 --- /dev/null +++ b/app/views/merged/images/index.haml @@ -0,0 +1,24 @@ +.grid.grid-cols-6.gap-4.m-8 + .relative.block.border.border-gray-100 + %h3.mt-4.text-lg.font-bold Add new image + = form_tag({action: :create}, multipart: true) do + = text_field_tag 'filename' + %h5.mt-4.text-lg.font-bold Name is optional + %p will be taken from uploaded file + = file_field_tag 'image_file' + .inline-block.rounded.border.border-indigo-600.bg-indigo-600.px-12.py-3.text-sm.font-medium.text-white.hover:bg-transparent.hover:text-indigo-600.focus:outline-none.focus:ring.active:text-indigo-500{:href => new_merge_image_path} + = submit_tag 'Submit' + -@images.each do |name , image| + .relative.block.border.border-gray-100 + =image_tag("merge/#{name}" , class: "h-56 w-full object-contain lg:h-72") + .p-3 + %strong.inline-block.bg-yellow-400.px-3.py-1.text-md.font-medium + = "#{image.size}k" + %strong.inline-block.bg-yellow-400.px-3.py-1.text-md.font-medium + = image.created_at.to_date + %h3.mt-4.text-lg.font-bold + = image.name + %strong.inline-block.bg-yellow-400.px-3.py-1.text-xs.font-medium + =image.type + + %p.mt-2.text-sm.text-gray-700 diff --git a/app/views/merged/pages/_form.haml b/app/views/merged/pages/_form.haml new file mode 100644 index 0000000..1670884 --- /dev/null +++ b/app/views/merged/pages/_form.haml @@ -0,0 +1,10 @@ += form_for @merge_page do |f| + - if @merge_page.errors.any? + #error_explanation + %h2= "#{pluralize(@merge_page.errors.count, "error")} prohibited this merge_page from being saved:" + %ul + - @merge_page.errors.full_messages.each do |message| + %li= message + + .actions + = f.submit 'Save' diff --git a/app/views/merged/pages/edit.haml b/app/views/merged/pages/edit.haml new file mode 100644 index 0000000..8435c15 --- /dev/null +++ b/app/views/merged/pages/edit.haml @@ -0,0 +1,7 @@ +%h1 Editing #{@merge_page.name} + += render 'form' + += link_to 'Show', merge_page_url(@merge_page.name) +\| += link_to 'Back', merge_pages_path diff --git a/app/views/merged/pages/index.haml b/app/views/merged/pages/index.haml new file mode 100644 index 0000000..3d08191 --- /dev/null +++ b/app/views/merged/pages/index.haml @@ -0,0 +1,33 @@ +.overflow-hidden.overflow-x-auto.rounded-lg.border.border-gray-200.m-20 + %table.min-w-full.divide-y.divide-gray-200.text-sm + %thead.bg-gray-100 + %tr + %th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900 + .flex.items-center.gap-2 + Name + %th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900 + .flex.items-center.gap-2 + First Template + %th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900 + .flex.items-center.gap-2 + Size (Sections) + %th.whitespace-nowrap.px-4.py-2.text-left.font-medium.text-gray-900 + Status + %tbody.divide-y.divide-gray-200 + - @pages.each do |merge_page| + %tr + %td.whitespace-nowrap.px-4.py-2.text-gray-700 + = link_to merge_page.name , merge_page_path(merge_page.name) + %td.whitespace-nowrap.px-4.py-2.text-gray-700 + = merge_page.first_template + %td.whitespace-nowrap.px-4.py-2.text-gray-700 + = merge_page.content.length + %td.whitespace-nowrap.px-4.py-2 + %strong.rounded.bg-green-100.px-3.text-xs.font-medium.text-green-700{:class => "py-1.5"} + = link_to 'Show', merge_page_path(merge_page.name) + %strong.rounded.bg-amber-100.px-3.text-xs.font-medium.text-amber-700{:class => "py-1.5"} + = link_to 'Edit', edit_merge_page_path(merge_page.name) + +%section + %a.inline-block.rounded.border.border-indigo-600.bg-indigo-600.px-12.py-3.text-sm.font-medium.text-white.hover:bg-transparent.hover:text-indigo-600.focus:outline-none.focus:ring.active:text-indigo-500{:href => new_merge_page_path} + New Page diff --git a/app/views/merged/pages/new.haml b/app/views/merged/pages/new.haml new file mode 100644 index 0000000..a194a59 --- /dev/null +++ b/app/views/merged/pages/new.haml @@ -0,0 +1,5 @@ +%h1 New merge_page + += render 'form' + += link_to 'Back', merge_pages_path diff --git a/app/views/merged/pages/show.haml b/app/views/merged/pages/show.haml new file mode 100644 index 0000000..2086df6 --- /dev/null +++ b/app/views/merged/pages/show.haml @@ -0,0 +1,24 @@ +%p#notice= notice +.flex.flex-col.bg-white + .flex.items-center.justify-center.flex-1 + .max-w-xl.px-4.py-8.mx-auto.text-center + %h1.text-2xl.font-bold.tracking-tight.text-gray-900.sm:text-4xl + Page #{@page.name} + +-@page.sections.each_with_index do |section , index| + .grid.grid-cols-6.gap-2.m-8{class: (index%2)==1 ? 'bg-cyan-50' : 'bg-red-50' } + .relative.block.border.border-gray-100 + .p-4 + %h3.mt-4.text-lg.font-bold Section #{index + 1} + %button.mt-4.rounded-lg.bg-yellow-500.p-4 + =link_to "Up" , "/index" + %button.mt-4.rounded-lg.bg-yellow-500.p-4 + =link_to "Down" , "/index" + %button.mt-4.rounded-lg.bg-blue-400.p-4 + =link_to "Edit" , merge_page_section_path(@page.name , section.id) + %button.mt-4.rounded-lg.bg-cyan-400.p-4 + =link_to "New" , "/index" + %button.mt-4.rounded-lg.bg-red-400.p-4 + =link_to "Delete" , "/index" + -section.content.each do |key , value| + = render "merge/sections/overview/#{key}", section: section , key: key , value: value diff --git a/app/views/merged/sections/_form.html.haml b/app/views/merged/sections/_form.html.haml new file mode 100644 index 0000000..75c04a0 --- /dev/null +++ b/app/views/merged/sections/_form.html.haml @@ -0,0 +1,10 @@ += form_for @merge_section do |f| + - if @merge_section.errors.any? + #error_explanation + %h2= "#{pluralize(@merge_section.errors.count, "error")} prohibited this merge_section from being saved:" + %ul + - @merge_section.errors.full_messages.each do |message| + %li= message + + .actions + = f.submit 'Save' diff --git a/app/views/merged/sections/edit.html.haml b/app/views/merged/sections/edit.html.haml new file mode 100644 index 0000000..8aac50c --- /dev/null +++ b/app/views/merged/sections/edit.html.haml @@ -0,0 +1,7 @@ +%h1 Editing merge_section + += render 'form' + += link_to 'Show', @merge_section +\| += link_to 'Back', merge_sections_path diff --git a/app/views/merged/sections/editors/_button.haml b/app/views/merged/sections/editors/_button.haml new file mode 100644 index 0000000..bd91f0e --- /dev/null +++ b/app/views/merged/sections/editors/_button.haml @@ -0,0 +1,9 @@ +.relative.block.border.border-gray-100 + %h3.mt-4.text-lg.font-bold= key.upcase + %p + .font-bold Text + = value["text"] +.relative.block.border.border-gray-100 + %p + .font-bold Link + = value["link"] diff --git a/app/views/merged/sections/editors/_card_template.haml b/app/views/merged/sections/editors/_card_template.haml new file mode 100644 index 0000000..7b24760 --- /dev/null +++ b/app/views/merged/sections/editors/_card_template.haml @@ -0,0 +1,7 @@ +.relative.block.border.border-gray-100 + %h3.mt-4.text-lg.font-bold= key.upcase + %p= value + %p #{section.content['cards'].length} cards + %p view cards (index) +.relative.block.border.border-gray-100 + =image_tag("merge/card_preview/#{value}" , class: "w-full object-contain") diff --git a/app/views/merged/sections/editors/_cards.haml b/app/views/merged/sections/editors/_cards.haml new file mode 100644 index 0000000..e69de29 diff --git a/app/views/merged/sections/editors/_header.haml b/app/views/merged/sections/editors/_header.haml new file mode 100644 index 0000000..2e6c0b2 --- /dev/null +++ b/app/views/merged/sections/editors/_header.haml @@ -0,0 +1,6 @@ +.relative.block.border.border-gray-100 + %h3.mt-4.text-lg.font-bold= key.upcase += section_form( class: "mx-auto mt-8 mb-0 max-w space-y-4") do + = text_field_tag( :header , @section.content["header"], class: "w-full.rounded-lg.border-gray-200.p-4.pr-12.text-sm.shadow-sm") + %button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-sm.font-medium.text-white{:type => "submit"} + Update diff --git a/app/views/merged/sections/editors/_id.haml b/app/views/merged/sections/editors/_id.haml new file mode 100644 index 0000000..e69de29 diff --git a/app/views/merged/sections/editors/_image.haml b/app/views/merged/sections/editors/_image.haml new file mode 100644 index 0000000..9d62da2 --- /dev/null +++ b/app/views/merged/sections/editors/_image.haml @@ -0,0 +1,13 @@ +.relative.block.border.border-gray-100 + %h3.mt-4.text-lg.font-bold= key.upcase + %button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-md.font-medium.text-white + =link_to "Change Image" , merge_page_section_select_image_url(@page.name,@section.id) + %button.ml-3.inline-block.rounded-lg.bg-red-500.px-5.py-3.text-md.font-medium.text-white + = link_to( "Remove image" , merge_page_section_set_image_path( @page.name, @section.id , image: "")) + + +.relative.block.border.border-gray-100 + -if( value.blank? ) + No image + -else + = image_tag( "merge/" + value) diff --git a/app/views/merged/sections/editors/_template.haml b/app/views/merged/sections/editors/_template.haml new file mode 100644 index 0000000..f2db409 --- /dev/null +++ b/app/views/merged/sections/editors/_template.haml @@ -0,0 +1,5 @@ +.relative.block.border.border-gray-100 + %h3.mt-4.text-lg.font-bold= key.upcase + %p= value +.relative.block.border.border-gray-100 + =image_tag("merge/section_preview/#{section.template}" , class: "w-full object-contain") diff --git a/app/views/merged/sections/editors/_text.haml b/app/views/merged/sections/editors/_text.haml new file mode 100644 index 0000000..72e3700 --- /dev/null +++ b/app/views/merged/sections/editors/_text.haml @@ -0,0 +1,7 @@ +.relative.block.border.border-gray-100 + %h3.mt-4.text-lg.font-bold= key.upcase +.relative.block.border.border-gray-100 + = section_form( class: "mx-auto mt-8 mb-0 max-w space-y-4") do + = text_area_tag( :text , @section.content["text"], class: "w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm") + %button.ml-3.inline-block.rounded-lg.bg-blue-500.px-5.py-3.text-sm.font-medium.text-white{:type => "submit"} + Update diff --git a/app/views/merged/sections/index.html.haml b/app/views/merged/sections/index.html.haml new file mode 100644 index 0000000..3a07049 --- /dev/null +++ b/app/views/merged/sections/index.html.haml @@ -0,0 +1,19 @@ +%h1 Listing merge_sections + +%table + %thead + %tr + %th + %th + %th + + %tbody + - @merge_sections.each do |merge_section| + %tr + %td= link_to 'Show', merge_section + %td= link_to 'Edit', edit_merge_section_path(merge_section) + %td= link_to 'Destroy', merge_section, method: :delete, data: { confirm: 'Are you sure?' } + +%br + += link_to 'New Section', new_merge_section_path diff --git a/app/views/merged/sections/new.html.haml b/app/views/merged/sections/new.html.haml new file mode 100644 index 0000000..1a8a38a --- /dev/null +++ b/app/views/merged/sections/new.html.haml @@ -0,0 +1,5 @@ +%h1 New merge_section + += render 'form' + += link_to 'Back', merge_sections_path diff --git a/app/views/merged/sections/overview/_button.haml b/app/views/merged/sections/overview/_button.haml new file mode 100644 index 0000000..fe2d63a --- /dev/null +++ b/app/views/merged/sections/overview/_button.haml @@ -0,0 +1,8 @@ +.p-6 + %h3.mt-4.text-lg.font-bold= key.upcase + %p + .font-bold Text + = value["text"] + %p + .font-bold Link + = value["link"] diff --git a/app/views/merged/sections/overview/_card b/app/views/merged/sections/overview/_card new file mode 100644 index 0000000..e69de29 diff --git a/app/views/merged/sections/overview/_card_template.haml b/app/views/merged/sections/overview/_card_template.haml new file mode 100644 index 0000000..33daa46 --- /dev/null +++ b/app/views/merged/sections/overview/_card_template.haml @@ -0,0 +1,5 @@ +.p-6 + %h3.mt-4.text-lg.font-bold= key.upcase + %p= value + =image_tag("merge/card_preview/#{value}" , class: "w-full object-contain") + %p #{section.content['cards'].length} cards diff --git a/app/views/merged/sections/overview/_cards.haml b/app/views/merged/sections/overview/_cards.haml new file mode 100644 index 0000000..e69de29 diff --git a/app/views/merged/sections/overview/_header.haml b/app/views/merged/sections/overview/_header.haml new file mode 100644 index 0000000..eaf2df3 --- /dev/null +++ b/app/views/merged/sections/overview/_header.haml @@ -0,0 +1,3 @@ +.p-6 + %h3.mt-4.text-lg.font-bold= key.upcase + %p= value diff --git a/app/views/merged/sections/overview/_id.haml b/app/views/merged/sections/overview/_id.haml new file mode 100644 index 0000000..e69de29 diff --git a/app/views/merged/sections/overview/_image.haml b/app/views/merged/sections/overview/_image.haml new file mode 100644 index 0000000..069ea8b --- /dev/null +++ b/app/views/merged/sections/overview/_image.haml @@ -0,0 +1,6 @@ +.p-6 + %h3.mt-4.text-lg.font-bold= key.upcase + -if value + = image_tag "merge/" + value + -else + No image diff --git a/app/views/merged/sections/overview/_template.haml b/app/views/merged/sections/overview/_template.haml new file mode 100644 index 0000000..3078c77 --- /dev/null +++ b/app/views/merged/sections/overview/_template.haml @@ -0,0 +1,4 @@ +.p-6 + %h3.mt-4.text-lg.font-bold= key.upcase + %p= value + =image_tag("merge/section_preview/#{section.template}" , class: "w-full object-contain") diff --git a/app/views/merged/sections/overview/_text.haml b/app/views/merged/sections/overview/_text.haml new file mode 100644 index 0000000..eaf2df3 --- /dev/null +++ b/app/views/merged/sections/overview/_text.haml @@ -0,0 +1,3 @@ +.p-6 + %h3.mt-4.text-lg.font-bold= key.upcase + %p= value diff --git a/app/views/merged/sections/select_image.haml b/app/views/merged/sections/select_image.haml new file mode 100644 index 0000000..8fe3160 --- /dev/null +++ b/app/views/merged/sections/select_image.haml @@ -0,0 +1,15 @@ +.grid.grid-cols-6.gap-2.m-8 + .relative.block.border.border-gray-100 + %h3.mt-4.text-lg.font-bold Add new image or select (click) + = form_tag(merge_images_path, multipart: true) do + = text_field_tag 'filename' + %h5.mt-4.text-lg.font-bold Name is optional + %p will be taken from uploaded file + = hidden_field_tag :redirect , merge_page_section_set_image_url(@page.name,@section.id,image: "NEW") + = file_field_tag 'image_file' + .inline-block.rounded.border.border-indigo-600.bg-indigo-600.px-12.py-3.text-sm.font-medium.text-white.hover:bg-transparent.hover:text-indigo-600.focus:outline-none.focus:ring.active:text-indigo-500{:href => new_merge_image_path} + = submit_tag 'Submit' + -@images.each do |name , image| + .relative.block.border.border-gray-100 + = link_to( merge_page_section_set_image_path( image: name)) do + =image_tag("merge/#{name}" , class: "h-56 w-full object-contain lg:h-72") diff --git a/app/views/merged/sections/show.html.haml b/app/views/merged/sections/show.html.haml new file mode 100644 index 0000000..c62efb7 --- /dev/null +++ b/app/views/merged/sections/show.html.haml @@ -0,0 +1,18 @@ +%p#notice= notice + +.flex.flex-col.bg-white + .flex.items-center.justify-center.flex-1 + .max-w-xl.px-4.py-8.mx-auto.text-center + %h1.text-2xl.font-bold.tracking-tight.text-gray-900 + Page #{@page.name} + .flex.items-center.justify-center.flex-1 + %h3.text-xl.font-bold.tracking-tight.text-gray-900 + Section #{@section.id} + +.grid.grid-cols-2.gap-2.m-8 + - @section.content.each do |key , value| + = render "merge/sections/editors/#{key}", section: @section , key: key , value: value + += #link_to 'Edit', edit_merge_section_path(@merge_section) +\| += #link_to 'Back', merge_sections_path diff --git a/app/views/merged/view/_section_2_col.haml b/app/views/merged/view/_section_2_col.haml new file mode 100644 index 0000000..8bec66a --- /dev/null +++ b/app/views/merged/view/_section_2_col.haml @@ -0,0 +1,11 @@ +.flex.flex-col.bg-cyan-100.mx-5 + .flex.items-center.justify-center.flex-1 + .max-w-prose.px-4.py-8.mx-auto.text-center + %h1.text-2xl.font-bold.tracking-tight.text-gray-900.sm:text-4xl + = section["header"] + %p.mt-4.text-gray-500 + = section["text"] + - template = "cards/" + section["card_template"] + .grid.grid-cols-1.md:grid-cols-2 + - section["cards"].each do |element| + = render( template , element: element) diff --git a/app/views/merged/view/_section_full_left1.haml b/app/views/merged/view/_section_full_left1.haml new file mode 100644 index 0000000..1c3bdac --- /dev/null +++ b/app/views/merged/view/_section_full_left1.haml @@ -0,0 +1,13 @@ +%section.overflow-hidden.bg-cover.bg-center.bg-no-repeat{style: bg(section)} + .p-8.md:p-12.lg:px-16.lg:py-24 + .max-w-lg.text-center.sm:text-left{:class => "bg-black/25"} + %h2.text-2xl.font-bold.text-white.sm:text-3xl.md:text-5xl + = section["header"] + %p.hidden.max-w-md.md:mt-6.md:block.md:text-lg.md:leading-relaxed{:class => "text-white/90"} + = section["text"] + -if section["button_text"] + .mt-4.sm:mt-8 + %a.inline-flex.items-center.rounded-full.bg-indigo-700.px-8.py-3.text-white.shadow-lg.transition.hover:bg-indigo-600.focus:outline-none.focus:ring{:href => section["button_link"]} + %span.text-sm.font-medium section["button_text"] + %svg.ml-3.h-5.w-5{:fill => "none", :stroke => "currentColor", :viewbox => "0 0 24 24", :xmlns => "http://www.w3.org/2000/svg"} + %path{:d => "M17 8l4 4m0 0l-4 4m4-4H3", "stroke-linecap" => "round", "stroke-linejoin" => "round", "stroke-width" => "2"} diff --git a/app/views/merged/view/_section_full_left2.haml b/app/views/merged/view/_section_full_left2.haml new file mode 100644 index 0000000..fef7853 --- /dev/null +++ b/app/views/merged/view/_section_full_left2.haml @@ -0,0 +1,14 @@ +%section.overflow-hidden.bg-cover.bg-center.bg-no-repeat{style: bg(section)} + .mx-auto.max-w-screen-2xl.px-4.py-8.sm:px-6.lg:px-8 + .grid.grid-cols-1.gap-4.md:grid-cols-2 + .p-8.md:p-12.lg:px-16.lg:py-24{class: 'bg-black/25'} + .mx-auto.max-w-xl.text-center + %h2.text-2xl.font-bold.text-white.md:text-5xl + = section["header"] + %p.hidden.sm:mt-4.sm:block.text-2xl.text-white + = section["text"] + .mt-4.md:mt-8 + -if section["button_text"] + %a.inline-block.rounded.border.border-white.bg-white.px-12.py-3.text-sm.font-medium.text-blue-500.transition.hover:bg-transparent.hover:text-white.focus:outline-none.focus:ring.focus:ring-yellow-400{:href => section["button_link"]} + =section["button_text"] + .grid.grid-cols-2.gap-4.md:grid-cols-1.lg:grid-cols-2 diff --git a/app/views/merged/view/_section_full_up.haml b/app/views/merged/view/_section_full_up.haml new file mode 100644 index 0000000..09dcf27 --- /dev/null +++ b/app/views/merged/view/_section_full_up.haml @@ -0,0 +1,7 @@ +.flex.flex-col.bg-white + .flex.items-center.justify-center.flex-1 + .max-w-xl.px-4.py-8.mx-auto.text-center + %h1.text-2xl.font-bold.tracking-tight.text-gray-900.sm:text-4xl + = section["header"] + %p.mt-4.text-gray-500 + = section["text"] diff --git a/app/views/merged/view/_section_half_header.haml b/app/views/merged/view/_section_half_header.haml new file mode 100644 index 0000000..a6517e3 --- /dev/null +++ b/app/views/merged/view/_section_half_header.haml @@ -0,0 +1,14 @@ +%section + .mx-auto.max-w-screen-xl.px-4.py-16.sm:px-6.sm:py-24.lg:px-8 + .max-w-3xl + %h2.text-3xl.font-bold.sm:text-4xl + = section["header"] + .mt-8.grid.grid-cols-1.gap-8.lg:grid-cols-2.lg:gap-16 + .relative.h-64.overflow-hidden.sm:h-80.lg:h-full + %img.absolute.inset-0.h-full.w-full.object-cover{:alt => "Party", :src => "https://images.unsplash.com/photo-1496843916299-590492c751f4?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1771&q=80"}/ + .lg:py-16 + %article.space-y-4.text-gray-600 + %p + = section["text"] + %p + = section["text"] diff --git a/app/views/merged/view/_section_half_left.haml b/app/views/merged/view/_section_half_left.haml new file mode 100644 index 0000000..395255d --- /dev/null +++ b/app/views/merged/view/_section_half_left.haml @@ -0,0 +1,11 @@ +%section.overflow-hidden.sm:grid.sm:grid-cols-2 + = image_for( section , "p-5 h-56 w-full object-cover sm:h-full") + .p-8.m-5.bg-cyan-100.md:p-12.lg:px-16.lg:py-24 + .mx-auto.max-w-xl.text-center.sm:text-left + %h2.text-2xl.font-bold.text-gray-900.md:text-3xl + = section["header"] + %p.hidden.text-gray-500.md:mt-4.md:block + = section["text"] + .mt-4.md:mt-8 + -if section["button"] + = render 'elements/button' , button: section["button"] diff --git a/app/views/merged/view/_section_half_right.haml b/app/views/merged/view/_section_half_right.haml new file mode 100644 index 0000000..c8bb012 --- /dev/null +++ b/app/views/merged/view/_section_half_right.haml @@ -0,0 +1,11 @@ +%section.overflow-hidden.sm:grid.sm:grid-cols-2 + .p-8.m-5.bg-cyan-100.md:p-12.lg:px-16.lg:py-24 + .mx-auto.max-w-xl.text-center.sm:text-left + %h2.text-2xl.font-bold.text-gray-900.md:text-3xl + = section["header"] + %p.hidden.text-gray-500.md:mt-4.md:block + = section["text"] + .mt-4.md:mt-8 + -if section["button"] + = render 'elements/button' , button: section["button"] + = image_for( section , "p-5 h-56 w-full object-cover sm:h-full") diff --git a/app/views/merged/view/_section_spacer.haml b/app/views/merged/view/_section_spacer.haml new file mode 100644 index 0000000..b3a0f6b --- /dev/null +++ b/app/views/merged/view/_section_spacer.haml @@ -0,0 +1 @@ +.h-24 diff --git a/app/views/merged/view/view.haml b/app/views/merged/view/view.haml new file mode 100644 index 0000000..3327f8f --- /dev/null +++ b/app/views/merged/view/view.haml @@ -0,0 +1,3 @@ +- @data.each do |section| + - template = find_template(section) + = render( template , section: section) diff --git a/config/routes.rb b/config/routes.rb index 99b1dda..b1d40fb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,10 @@ Merged::Engine.routes.draw do + + resources :pages do + resources :sections do + get :select_image + get :set_image + end + end resources :images end