diff --git a/app/controllers/admin/communication/websites/pages_controller.rb b/app/controllers/admin/communication/websites/pages_controller.rb index d4c34e11234b7c96c1704a2366a8c8e276b8d579..c6c290817899f759a8648cd5b61c6146260fafc3 100644 --- a/app/controllers/admin/communication/websites/pages_controller.rb +++ b/app/controllers/admin/communication/websites/pages_controller.rb @@ -36,7 +36,6 @@ class Admin::Communication::Websites::PagesController < Admin::Communication::We end def preview - @url = @website.url render layout: 'admin/layouts/preview' end diff --git a/app/controllers/admin/communication/websites/posts_controller.rb b/app/controllers/admin/communication/websites/posts_controller.rb index 3c711ef52fd17b9dafd94f0f68c83b0a299f38b9..0b432a85668a56f2dbb9afd84fbcd4f3aee8ee36 100644 --- a/app/controllers/admin/communication/websites/posts_controller.rb +++ b/app/controllers/admin/communication/websites/posts_controller.rb @@ -36,6 +36,10 @@ class Admin::Communication::Websites::PostsController < Admin::Communication::We breadcrumb end + def preview + render layout: 'admin/layouts/preview' + end + def static @about = @post render layout: false diff --git a/app/controllers/admin/education/programs_controller.rb b/app/controllers/admin/education/programs_controller.rb index 230760853db7be73108426cfd5582281fb722471..edb22802238dd74a988112f6c3626beac2c65d94 100644 --- a/app/controllers/admin/education/programs_controller.rb +++ b/app/controllers/admin/education/programs_controller.rb @@ -54,6 +54,11 @@ class Admin::Education::ProgramsController < Admin::Education::ApplicationContro breadcrumb end + def preview + @website = @program.websites&.first + render layout: 'admin/layouts/preview' + end + def new breadcrumb end diff --git a/app/views/admin/communication/websites/posts/preview.html.erb b/app/views/admin/communication/websites/posts/preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..2e02e06629774ed1d06bf6637363b52eaeb1fb20 --- /dev/null +++ b/app/views/admin/communication/websites/posts/preview.html.erb @@ -0,0 +1,6 @@ +<div class="container"> + <%= @post.text.to_s %> +</div> +<% @post.blocks.ordered.each do |block| %> + <%= render 'admin/communication/blocks/preview', block: block %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/communication/websites/posts/show.html.erb b/app/views/admin/communication/websites/posts/show.html.erb index fd1c4ea35281c2bbb8c223eaf2179f9b114b579c..77aee23f876abb60567700e350f4bd07b91be64f 100644 --- a/app/views/admin/communication/websites/posts/show.html.erb +++ b/app/views/admin/communication/websites/posts/show.html.erb @@ -87,13 +87,6 @@ </div> <% end %> -<% content_for :preview do %> - <%= @post.text.to_s %> - <% @post.blocks.ordered.each do |block| %> - <%= render 'admin/communication/blocks/preview', block: block %> - <% end %> -<% end %> - <% content_for :action_bar_left do %> <%= destroy_link @post %> <%= link_to t('static'), diff --git a/app/views/admin/education/programs/preview.html.erb b/app/views/admin/education/programs/preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..1826c48e8c39d14e5f76134d46c5cd2a2d580bd3 --- /dev/null +++ b/app/views/admin/education/programs/preview.html.erb @@ -0,0 +1,27 @@ +<% [ + :presentation, + :objectives + ].each do |property| %> + <%= @program.send(property).to_s %> +<% end %> + +<% @program.blocks.ordered.each do |block| %> + <%= render 'admin/communication/blocks/preview', block: block %> +<% end %> + +<% [ + :opportunities, + :results, + :accessibility, + :duration, + :pricing, + :content, + :pedagogy, + :evaluation, + :prerequisites, + :registration, + :other, + :contacts + ].each do |property| %> + <%= @program.send(property).to_s %> +<% end %> diff --git a/app/views/admin/education/programs/show.html.erb b/app/views/admin/education/programs/show.html.erb index 1699cb9e83ce391edda4423c183a81dc156be25b..7c6c2659641c685fd2c61a792013a301489c99bc 100644 --- a/app/views/admin/education/programs/show.html.erb +++ b/app/views/admin/education/programs/show.html.erb @@ -179,27 +179,6 @@ </div> </div> -<% content_for :preview do %> - <% [ - :presentation, - :objectives, - :opportunities, - :results, - :accessibility, - :duration, - :pricing, - :content, - :pedagogy, - :evaluation, - :prerequisites, - :registration, - :other, - :contacts - ].each do |property| %> - <%= @program.send(property).to_s %> - <% end %> -<% end %> - <% content_for :action_bar_left do %> <%= destroy_link @program %> <% end %> diff --git a/app/views/admin/layouts/preview.html.erb b/app/views/admin/layouts/preview.html.erb index 8012119e125f814341b2aff1851230d9a9ace30a..791854a7d1449b14f88d8accfbda64a904f7c50d 100644 --- a/app/views/admin/layouts/preview.html.erb +++ b/app/views/admin/layouts/preview.html.erb @@ -1,23 +1,14 @@ -<% -@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> - <link rel="stylesheet" media="all" href="<%= style_admin_communication_website_path @website.id, website_id: nil %>" /> + <% if @website %> + <link rel="stylesheet" media="all" href="<%= style_admin_communication_website_path @website.id, website_id: nil %>" /> + <% else %> + <%= stylesheet_link_tag 'admin', media: 'all' %> + <% end %> </head> <body> <main class="page-with-blocks" id="main" role="main" tabindex="-1"> diff --git a/config/routes/admin/communication.rb b/config/routes/admin/communication.rb index 03f7821a30a1c838a1510742e66e45dfb581835e..2d1b47145ac7924c0139c2e919947dc99029de03 100644 --- a/config/routes/admin/communication.rb +++ b/config/routes/admin/communication.rb @@ -30,6 +30,7 @@ namespace :communication do post :publish, on: :collection member do get :static + get :preview end end resources :curations, diff --git a/config/routes/admin/education.rb b/config/routes/admin/education.rb index b2ebafe49b92cf9ae3d3d31cc6fad48ca0630fb7..acac8d244692957fc6a9cf4d645c3ae66e928e55 100644 --- a/config/routes/admin/education.rb +++ b/config/routes/admin/education.rb @@ -30,6 +30,7 @@ namespace :education do end member do get :children + get :preview end end resources :academic_years