-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1029 from projecthydra-labs/split_pages_from_cont…
…ent_blocks_406 Split page-type content blocks into new controller and route
- Loading branch information
Showing
21 changed files
with
334 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,50 @@ | ||
module Hyrax | ||
# Shows the about and help page | ||
class PagesController < ApplicationController | ||
helper Hyrax::ContentBlockHelper | ||
load_and_authorize_resource class: ContentBlock, except: :show | ||
layout :pages_layout | ||
|
||
layout 'homepage' | ||
helper Hyrax::ContentBlockHelper | ||
|
||
def show | ||
@page = ContentBlock.find_or_create_by(name: params[:id]) | ||
end | ||
|
||
def edit | ||
add_breadcrumb t(:'hyrax.controls.home'), root_path | ||
add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path | ||
add_breadcrumb t(:'hyrax.admin.sidebar.configuration'), '#' | ||
add_breadcrumb t(:'hyrax.admin.sidebar.pages'), hyrax.edit_pages_path | ||
end | ||
|
||
def update | ||
respond_to do |format| | ||
if @page.update(value: update_value_from_params) | ||
format.html { redirect_to hyrax.edit_pages_path, notice: t(:'hyrax.pages.updated') } | ||
else | ||
format.html { render :edit } | ||
end | ||
end | ||
end | ||
|
||
protected | ||
|
||
def permitted_params | ||
params.require(:content_block).permit(:about_page, :help_page) | ||
end | ||
|
||
# When a request comes to the controller, it will be for one and | ||
# only one of the content blocks. Params always looks like: | ||
# {'about_page' => 'Here is an awesome about page!'} | ||
# So reach into permitted params and pull out the first value. | ||
def update_value_from_params | ||
permitted_params.values.first | ||
end | ||
|
||
private | ||
|
||
def pages_layout | ||
action_name == 'show' ? 'homepage' : 'dashboard' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<div class="panel panel-default tabs"> | ||
<ul class="nav nav-tabs" role="tablist"> | ||
<li class="active"> | ||
<a href="#about_page" role="tab" data-toggle="tab"><%= t(:'hyrax.pages.tabs.about_page') %></a> | ||
</li> | ||
<li> | ||
<a href="#help_page" role="tab" data-toggle="tab"><%= t(:'hyrax.pages.tabs.help_page') %></a> | ||
</li> | ||
</ul> | ||
<div class="tab-content"> | ||
<div id="about_page" class="tab-pane active"> | ||
<div class="panel panel-default labels"> | ||
<%= simple_form_for ContentBlock.about_page, url: hyrax.page_path(ContentBlock.about_page) do |f| %> | ||
<div class="panel-body"> | ||
<div class="field form-group"> | ||
<%= f.label :about_page %><br> | ||
<%= f.text_area :about_page, value: f.object.value, class: 'form-control tinymce', rows: 20, cols: 120 %> | ||
</div> | ||
</div> | ||
<div class="panel-footer"> | ||
<%= link_to t(:'hyrax.pages.cancel'), hyrax.admin_admin_sets_path, class: 'btn btn-default pull-right'%> | ||
<%= f.button :submit, class: 'btn btn-primary pull-right'%> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
<div id="help_page" class="tab-pane"> | ||
<div class="panel panel-default labels"> | ||
<%= simple_form_for ContentBlock.help_page, url: hyrax.page_path(ContentBlock.help_page) do |f| %> | ||
<div class="panel-body"> | ||
<div class="field form-group"> | ||
<%= f.label :help_page %><br> | ||
<%= f.text_area :help_page, value: f.object.value, class: 'form-control tinymce', rows: 20, cols: 120 %> | ||
</div> | ||
</div> | ||
<div class="panel-footer"> | ||
<%= link_to t(:'hyrax.pages.cancel'), hyrax.admin_admin_sets_path, class: 'btn btn-default pull-right'%> | ||
<%= f.button :submit, class: 'btn btn-primary pull-right'%> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<% content_for :page_header do %> | ||
<h1><span class="fa fa-file-text-o"></span> <%= t(:'hyrax.admin.sidebar.pages') %></h1> | ||
<% end %> | ||
|
||
<div class="row"> | ||
<div class="col-md-12"> | ||
<%= render 'form' %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.