Skip to content
Snippets Groups Projects
Commit 386a8efd authored by Arnaud Levy's avatar Arnaud Levy
Browse files

working prototype (with posts)

parent 6039e3eb
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,10 @@ class Admin::Communication::WebsitesController < Admin::Communication::Applicati
breadcrumb
end
def style
render body: @website.preview_style, content_type: "text/css"
end
def new
breadcrumb
end
......
......@@ -74,4 +74,20 @@ class Communication::Website < ApplicationRecord
dependencies
end
def preview_style
return '' if url.blank?
html = Nokogiri::HTML open(url)
css_files = html.xpath '//link[@rel="stylesheet"]/@href'
css = ''
css_files.each do |css_url|
css_uri = URI.parse css_url
data = Net::HTTP.get css_uri
data = data.force_encoding("UTF-8")
data = data.gsub "src:url(../", "src:url(#{url}/assets/"
data = data.gsub ",url(../", ",url(#{url}/assets/"
css << data
end
css
end
end
<h2 class="h4 mt-5"><%= block.title %></h2>
<% @block = block %>
<%= render "admin/communication/blocks/templates/#{@block.template_kind}/preview" %>
<section class="block-<%= block.template_kind %>">
<div class="container">
<div class="block-content">
<div class="top">
<h2><%= block.title %></h2>
</div>
<% @block = block %>
<%= render "admin/communication/blocks/templates/#{@block.template_kind}/preview" %>
</div>
</div>
</section>
\ No newline at end of file
<% if @block.data %>
<% if @block.template.category %>
<h2 class="mb-4"><%= @block.template.category %></h2>
<div class="posts">
<% if @block.data %>
<% @block.template.selected_posts.each do |post| %>
<div>
<article class="post">
<div>
<p class="title"><%= post %></p>
<p><%= post.description_short %></p>
<time datetime="<%= post.published_at %>"><%= post.published_at.to_date %></time>
</div>
<% if post.best_featured_image.attached? %>
<div class="media">
<%= kamifusen_tag post.best_featured_image %>
</div>
<% end %>
</article>
</div>
<% end %>
<% end %>
<% @block.template.selected_posts.each do |post| %>
<h3 class="h5"><%= post %></h3>
<p><%= post.description_short %></p>
<% end %>
<% end %>
</div>
\ No newline at end of file
<%= @page.text.to_s %>
<div class="container">
<%= @page.text.to_s %>
</div>
<% @page.blocks.ordered.each do |block| %>
<%= render 'admin/communication/blocks/preview', block: block %>
<%= render 'admin/communication/blocks/preview', block: block %>
<% end %>
\ No newline at end of file
......@@ -17,11 +17,9 @@ end
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title><%= yield :title %></title>
<link rel="stylesheet" media="all" href="<%= style_admin_communication_website_path @website.id, website_id: nil %>" />
</head>
<body class="is-loaded">
<style>
<%= @css %>
</style>
<body>
<main class="page-with-blocks" id="main" role="main" tabindex="-1">
<div class="blocks">
<%= yield %>
......
......@@ -4,6 +4,7 @@ namespace :communication do
member do
get :import
post :import
get :style
end
resources :pages, controller: 'websites/pages' do
collection do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment