Skip to content

Commit

Permalink
Make content blocks editable in settings UI
Browse files Browse the repository at this point in the history
Fixes #74
  • Loading branch information
mjgiarlo committed Apr 22, 2016
1 parent f287632 commit 5195eaa
Show file tree
Hide file tree
Showing 16 changed files with 97 additions and 52 deletions.
25 changes: 9 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ GIT

GIT
remote: https://github.com/projecthydra/sufia.git
revision: 9d0c339c0dbe8ce22aee22824bfd8ac826afbbc3
revision: 9c9eb31f23a392b51ac5a9b81573ad56bd22dd72
branch: master
specs:
sufia (7.0.0.beta1)
Expand All @@ -26,11 +26,11 @@ GIT
blacklight-gallery (~> 0.1)
browse-everything (~> 0.10)
carrierwave (~> 0.9)
curation_concerns (~> 0.12.0.pre8)
curation_concerns (~> 0.13.0)
daemons (~> 1.1)
font-awesome-rails (~> 4.2)
google-api-client (~> 0.7, < 0.9)
hydra-batch-edit (~> 1.1)
hydra-batch-edit (~> 2.0)
hydra-works (~> 0.7)
jquery-ui-rails (~> 5.0)
json-schema
Expand All @@ -46,7 +46,7 @@ GIT
tinymce-rails (~> 4.1)
tinymce-rails-imageupload (~> 4.0.16.beta)
yaml_db (~> 0.2)
zeroclipboard-rails (~> 0.1)
zeroclipboard-rails (~> 0.0.13)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -200,7 +200,7 @@ GEM
term-ansicolor (~> 1.3)
thor (~> 0.19.1)
tins (~> 1.6.0)
curation_concerns (0.12.0)
curation_concerns (0.13.0)
active-fedora (~> 9.9)
active_attr
active_fedora-noid (~> 1.0)
Expand Down Expand Up @@ -310,17 +310,10 @@ GEM
blacklight-access_controls (~> 0.1)
cancancan (~> 1.8)
deprecation (~> 0.2)
hydra-batch-edit (1.1.1)
hydra-batch-edit (2.0.2)
blacklight
hydra-collections
hydra-collections (8.2.0)
active-fedora (~> 9.9)
blacklight (~> 6.0)
deprecation (~> 0.1)
hydra-head (~> 9.9)
hydra-works (~> 0.4)
rdf (~> 1.99)
rdf-vocab (~> 0)
curation_concerns (>= 0.12.0.pre2)
rails
hydra-core (9.10.0)
hydra-access-controls (= 9.10.0)
rails (~> 4.0)
Expand Down Expand Up @@ -750,7 +743,7 @@ GEM
yaml_db (0.3.0)
rails (>= 3.0, < 4.3)
rake (>= 0.8.7)
zeroclipboard-rails (0.1.1)
zeroclipboard-rails (0.0.13)
railties (>= 3.1)
zk (1.9.6)
zookeeper (~> 1.4.0)
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/batch_edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//= require batch_edit/batch_edit
1 change: 1 addition & 0 deletions app/assets/stylesheets/batch_edit.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'batch_edit/batch_edit';
3 changes: 3 additions & 0 deletions app/controllers/sites_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ class SitesController < ApplicationController

# GET /sites/1/edit
def edit
@announcement_text = ContentBlock.find_or_create_by(name: ContentBlock::ANNOUNCEMENT)
@marketing_text = ContentBlock.find_or_create_by(name: ContentBlock::MARKETING)
@featured_researcher = ContentBlock.find_or_create_by(name: ContentBlock::RESEARCHER)
end

# PATCH/PUT /sites/1
Expand Down
1 change: 1 addition & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module ApplicationHelper
include ::SufiaHelper
include ContentBlockHelper
end
20 changes: 20 additions & 0 deletions app/helpers/content_block_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module ContentBlockHelper
include Sufia::ContentBlockHelperBehavior

def displayable_content_block(content_block, **options)
return if content_block.value.blank?
content_tag :div, content_block.value, options
end

def editable_content_block(content_block)
capture do
concat form_for([sufia, content_block]) { |f|
concat f.label :value, content_block.name.titleize
concat f.text_area :value, class: "tinymce", rows: 20, cols: 120
concat f.submit 'Save', class: "btn btn-primary"
}
concat tinymce_assets
concat tinymce
end
end
end
2 changes: 1 addition & 1 deletion app/models/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ class Collection < ActiveFedora::Base
include ::CurationConcerns::CollectionBehavior
include Sufia::CollectionBehavior
# You can replace these metadata if they're not suitable
include Hydra::Collections::BasicMetadata
include CurationConcerns::BasicMetadata
end
4 changes: 2 additions & 2 deletions app/views/_toolbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<% if can? :manage, Site %>
<li><%= link_to 'Settings', main_app.edit_site_path%></li>
<% end %>
<% if Site.account && can?(:manage, Site.account) %>
<li><%= link_to 'Account', main_app.account_path(Site.account) %></li>
<% end %>
Expand Down Expand Up @@ -85,7 +85,7 @@
<% end %>
<ul class="dropdown-menu">
<li><%= link_to 'My Collections', sufia.dashboard_collections_path %></li>
<li><%= link_to 'New Collection', collections.new_collection_path %></li>
<li><%= link_to 'New Collection', main_app.new_collection_path %></li>
</ul>
</li>
<% end %>
Expand Down
5 changes: 5 additions & 0 deletions app/views/sites/_content_blocks_tab.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div role="tabpanel" class="tab-pane" id="content_blocks">
<%= editable_content_block @announcement_text %>
<%= editable_content_block @marketing_text %>
<%= editable_content_block @featured_researcher %>
</div>
30 changes: 0 additions & 30 deletions app/views/sites/_form.html.erb

This file was deleted.

32 changes: 32 additions & 0 deletions app/views/sites/_settings_tab.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<div role="tabpanel" class="tab-pane active" id="labels">
<%= form_for(@site, url: site_path) do |f| %>
<% if @site.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@site.errors.count, "error") %> prohibited this site from being saved:</h2>

<ul>
<% @site.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="field form-group">
<%= f.label :application_name %><br>
<%= f.text_field :application_name, class: 'form-control'%>
</div>

<div class="field form-group">
<%= f.label :institution_name %><br>
<%= f.text_field :institution_name, class: 'form-control'%>
</div>

<div class="field form-group">
<%= f.label :institution_name_full %><br>
<%= f.text_field :institution_name_full, class: 'form-control'%>
</div>

<%= f.submit class: 'btn btn-primary' %>
<% end %>
</div>
18 changes: 16 additions & 2 deletions app/views/sites/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
<h1>Editing Site</h1>
<h1>Settings</h1>

<%= render 'form' %>
<nav id="admin-nav" role="navigation">
<ul class="nav nav-pills" role="tablist">
<li role="presentation" class="active">
<a href="#labels" aria-controls="labels" role="tab" data-toggle="pill">Labels</a>
</li>
<li role="presentation">
<a href="#content_blocks" aria-controls="content_blocks" role="tab" data-toggle="pill">Content Blocks</a>
</li>
</ul>

<div class="tab-content">
<%= render 'settings_tab' %>
<%= render 'content_blocks_tab' %>
</div>
</nav>
1 change: 1 addition & 0 deletions app/views/sufia/homepage/_announcement.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= displayable_content_block @announcement_text, class: 'row', id: 'announcement' %>
3 changes: 3 additions & 0 deletions app/views/sufia/homepage/_featured_researcher.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h2>Featured Researcher</h2>
<%= link_to 'View other featured researchers', sufia.featured_researchers_path %>
<%= displayable_content_block @featured_researcher %>
1 change: 1 addition & 0 deletions app/views/sufia/homepage/_marketing.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= displayable_content_block @marketing_text, class: 'col-sm-offset-2 col-sm-9 col-md-offset-1 home_marketing_text' %>
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Rails.application.routes.draw do
Hydra::BatchEdit.add_routes(self)
mount BrowseEverything::Engine => '/browse'
resource :site, only: [:edit, :update] do
resources :roles, only: [:index, :update]
Expand All @@ -8,7 +9,6 @@
root 'sufia/homepage#index'

mount Blacklight::Engine => '/'
mount Hydra::Collections::Engine => '/'
mount CurationConcerns::Engine, at: '/'

concern :searchable, Blacklight::Routes::Searchable.new
Expand Down

0 comments on commit 5195eaa

Please sign in to comment.