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

preview POC

parent 0caacc68
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,11 @@ class Admin::Communication::Websites::PagesController < Admin::Communication::We
render layout: false
end
def preview
@url = @website.url
render layout: 'admin/layouts/preview'
end
def new
@page.website = @website
breadcrumb
......
<%= @page.text.to_s %>
<% @page.blocks.ordered.each do |block| %>
<%= render 'admin/communication/blocks/preview', block: block %>
<% end %>
\ No newline at end of file
<%
@html = Nokogiri::HTML open(@url)
@css_files = @html.xpath '//link[@rel="stylesheet"]/@href'
@css = ''
@css_files.each do |url|
uri = URI.parse url
data = Net::HTTP.get 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
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title><%= yield :title %></title>
</head>
<body class="is-loaded">
<style>
<%= @css %>
</style>
<main class="page-with-blocks" id="main" role="main" tabindex="-1">
<div class="blocks">
<%= yield %>
</div>
</main>
</body>
</html>
......@@ -12,6 +12,7 @@ namespace :communication do
member do
get :children
get :static
get :preview
end
end
resources :categories, controller: 'websites/categories' 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