Skip to content

Commit

Permalink
Allow HTML in Mostly Static Pages body field (CFM-62) (#291)
Browse files Browse the repository at this point in the history
* Allow HTML in Mostly Static Pages body field (CFM-62)

* Improve navigation and rendering for Mostly Static Pages (CFM-62)

* Hide topbar on Mostly Static pages (CFM-62)
  • Loading branch information
arlen authored Feb 12, 2025
1 parent 06d2dca commit 9171c58
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/src/Model/Table/MostlyStaticPagesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public function validationDefault(Validator $validator): Validator {
$validator->notEmptyString('context');

$validator->add('body', [
'filter' => ['rule' => ['validateInput'],
'filter' => ['rule' => ['validateInput',['type' => 'html']],
'provider' => 'table']
]);
$validator->allowEmptyString('body');
Expand Down
36 changes: 36 additions & 0 deletions app/templates/MostlyStaticPages/fields-nav.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* COmanage Registry Mostly Static Pages Edit Links
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v5.0.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

if($vv_action == 'edit') {
$topLinks[] = [
'icon' => 'arrow_outward',
'order' => 'Default',
'label' => __d('operation', 'view'),
'url' => $vv_base_url . '/' . $vv_obj->name,
'class' => ''
];
}
7 changes: 6 additions & 1 deletion app/templates/Standard/add-edit-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@
foreach(($topLinks ?? []) as $t) {
$perm = false;

if(!empty($t['link']['controller'])) {
if(!empty($t['url'])) {
// We are passing in a plain URL. Pass it along directly.
// For the moment (v5.1+), this is only used to create a toplink to a Mostly Static Page.
$perm = true;
$t['link'] = $t['url'];
} elseif(!empty($t['link']['controller'])) {
// We're linking into a related model, which may or may not be in a plugin

$linkModel = \Cake\Utility\Inflector::camelize($t['link']['controller']);
Expand Down
14 changes: 14 additions & 0 deletions app/templates/element/menuPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,20 @@
<em class="material-symbols-outlined" aria-hidden="true">email</em>
<span class="menu-panel-link-text"><?= __d('controller', 'MessageTemplates', [99]) ?></span>
</a>
<?php
$menuUrl = $this->Url->build(
['plugin' => null,
'controller' => 'mostly_static_pages',
'action' => 'index',
'?' => [
'co_id' => $vv_cur_co->id
]]
);
?>
<a href="<?= $menuUrl ?>">
<em class="material-symbols-outlined" aria-hidden="true">article</em>
<span class="menu-panel-link-text"><?= __d('controller', 'MostlyStaticPages', [99]) ?></span>
</a>
</li>
<?php /* More placeholders:
<li><a href="#"><em class="material-symbols" aria-hidden="true">room_service</em> Self Service Permissions</a></li>
Expand Down
8 changes: 8 additions & 0 deletions app/webroot/css/co-base.css
Original file line number Diff line number Diff line change
Expand Up @@ -2177,6 +2177,14 @@ ul.petition-attrs-subset li {
.petition-attrs-subset-label {
color: var(--cmg-color-txt-soft);
}
/* MOSTLY STATIC PAGES */
body.pages.logged-out #top-bar,
body.pages.logged-out #breadcrumbs {
display: none;
}
body.pages.logged-out .page-title-container {
margin: 0;
}
/* GENERAL */
.hidden,
.invisible,
Expand Down
2 changes: 1 addition & 1 deletion app/webroot/js/comanage/components/mvea/mvea-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export default {
<li class="field-data-container linked-row" v-if="this.core.mveaType == 'urls'" @click="followRowLink">
<div class="field-data force-wrap with-hover-button">
<a :href="mveaLink" class="row-link" @click.prevent>{{ this.mvea.description != '' && this.mvea.description != null ? this.mvea.description : this.mvea.url }}</a>
<a :href="this.mvea.url" class="canvas-url-link" :title="this.txt['information.global.visit.link']"><span class="material-symbols">north_east</span></a>
<a :href="this.mvea.url" class="canvas-url-link" :title="this.txt['information.global.visit.link']"><span class="material-symbols">open_in_new</span></a>
<copy-value-button
:txt="this.txt"
:valueToCopy="this.mvea.url">
Expand Down

0 comments on commit 9171c58

Please sign in to comment.