Commit 74f3aa76 by Eva Gächter
parents fa280e81 4aa980ec
......@@ -29,10 +29,17 @@ import java.util.List;
*/
public interface Page {
public MString getPageTitle();
public MString getMetaTitle();
public MString getPageDescription();
public List<PageBlock> getSubPages();
public String alternateLanguageUrl(String key);
public String getKey();
boolean isSearchable();
MString getPageTitle();
MString getMetaTitle();
MString getPageDescription();
List<PageBlock> getSubPages();
String alternateLanguageUrl(String key);
String getKey();
}
......@@ -22,7 +22,6 @@ import org.slf4j.Logger;
import play.Play;
import play.i18n.Lang;
import play.i18n.Messages;
import play.i18n.MessagesApi;
import java.util.ArrayList;
......@@ -34,7 +33,7 @@ import java.util.List;
* to pass values to shared templates.
*
*/
public class StandalonePage implements Page {
public class StandalonePage implements Page {
private final static Logger logger = LoggerFactory.getLogger(StandalonePage.class);
protected String key;
......@@ -74,6 +73,11 @@ public class StandalonePage implements Page {
}
@Override
public boolean isSearchable() {
return false;
}
@Override
public MString getPageTitle() {
return fromMessage(titleKey);
}
......@@ -98,18 +102,16 @@ public class StandalonePage implements Page {
@Override
public List<PageBlock> getSubPages() {
return new ArrayList<PageBlock>();
return new ArrayList<>();
}
@Override
public String alternateLanguageUrl(String lang) {
if(alternateLanguageUrls.get(lang) != null) {
return alternateLanguageUrls.get(lang);
} else {
try {
return PageBlock.find.byKey(PageBlock.KEY_HOMEPAGE).getNavItem(lang).getURL();
} catch (Exception e) {
logger.error("alternateLanguageUrl: Error while trying to find homepage with key " + PageBlock.KEY_HOMEPAGE + " in language: " + lang + ". This means your setup is not correct.", e);
e.printStackTrace();
......
......@@ -33,12 +33,6 @@
case _ => None
}
}
@responsiveBlockClass = @{
Some(data).map(_.getParentBlock).map {
case rs: ResponsiveCollection => Template.addColWidthClass(data)
case _ => "container"
}
}
@wrapIntoContainer(content: Html) = {
@Some(data).map {
case rc: ResponsiveCollection => {
......@@ -125,7 +119,7 @@
</div>
} else {
@wrapIntoContainer {
<div class="@Some(CssClass).filterNot(_.isEmpty) @responsiveBlockClass @responsiveCollectionClass">
<div class="@Some(CssClass).filterNot(_.isEmpty).getOrElse("pcms-container") @Template.addColWidthClass(data) @responsiveCollectionClass">
@content
</div>
}
......
@import ch.insign.cms.models.PageBlock
@import ch.insign.cms.views.html._blockBase
@import ch.insign.cms.models.Template
@import ch.insign.cms.views.html.{_loginFormModal, deleteBlockModal, restrictBlockModal, unrestrictBlockModal}
@import ch.insign.cms.controllers.AuthController
@import ch.insign.playauth.views.helper.hasPermission
@import ch.insign.cms.permissions.BlockPermission
@(
page: ch.insign.cms.models.Page,
add: Boolean = false,
edit: Boolean = true,
delete: Boolean = true,
restrict: Boolean = false,
name: String = "",
color: String = "gray",
sortableContainer: Boolean = false,
CssClass: String = ""
)(content: Html)
<body @hasPermission(BlockPermission.MODIFY){class="fe-admin"}>
@Some(page).map {
case cmsManaged: PageBlock => {
@_loginFormModal(AuthController.LOGIN_FORM, flash.get("backUrl"), Messages("frontend.login.modal.title"))
@_blockBase(cmsManaged, add, edit, delete, restrict, name, color, sortableContainer, CssClass)(content)
@if(!Template.isIndexer && cmsManaged.canModify) {
@deleteBlockModal()
@restrictBlockModal()
@unrestrictBlockModal()
}
}
case _ => {
@*Here could be any standalone specific code*@
@content
}
}
</body>
\ No newline at end of file
......@@ -2,7 +2,7 @@
@(
data: ch.insign.cms.models.ContentBlock
)(extension: Html = Html.apply(""))
@_blockBase(data = data, color = "red") {
@_blockBase(data = data, color = "red", CssClass = "container") {
<h3>@data.getTitle</h3>
<p>@Html(data.getContent.get)</p>
@extension
......
......@@ -29,7 +29,9 @@
'placeholder -> ""
) { (id, name, value, args) =>
<input type="text" id="@id" name="@name" value="@value" @toHtmlArgs(args) style="width: @{width}px;display:inline;" />
<a class="btn btn-primary image-upload" href="#"> Browse </a>
<button type="button" class="btn btn-primary image-upload" data-field="#@id">
Browse
</button>
@if(helperText != null){
<span class="help-block">@helperText</span>
}
......
@import play.api.i18n.Messages;
@import play.api.i18n.Messages
@import ch.insign.cms.controllers
@import views.html.helper.form
<div id="image-upload-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-content">
......@@ -14,15 +15,22 @@
<!-- loader.gif -->
<img style="display:none" id="image-upload-loader" src="@ch.insign.cms.views.html.tags._asset("frontend/img/loader.gif")" alt="Loading...." title="Loading...." />
<!-- simple file uploading form -->
<form id="image-upload-form" action="@controllers.routes.ImageUploadController.imageUpload()" method="post" enctype="multipart/form-data">
@form(controllers.routes.ImageUploadController.imageUpload(), 'id -> "image-upload-form", 'enctype -> "multipart/form-data") {
<input id="uploadImage" style="display:none;" type="file" accept="image/*" name="userfile" />
<label for="uploadImage" class="btn btn-primary"><i class="glyphicon glyphicon-plus"></i> @Messages("block.modal.imageUpload.title.selettFile")</label>
</form>
<label for="uploadImage" class="btn btn-primary">
<i class="glyphicon glyphicon-plus"></i> @Messages("block.modal.imageUpload.title.selettFile")
</label>
}
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn default" data-dismiss="modal" aria-hidden="true">@Messages("modal.cancel.btn")</button>
<a href="#" class="btn btn-primary disabled" id="confirmUpload" >@Messages("block.modal.imageUpload.confirmBtn")</a>
<button type="button" class="btn default" data-dismiss="modal" aria-hidden="true">
@Messages("modal.cancel.btn")
</button>
<button type="button" class="btn btn-primary disabled" id="confirmUpload">
@Messages("block.modal.imageUpload.confirmBtn")
</button>
</div>
</div>
</div>
......@@ -17,40 +17,30 @@
package ch.insign.commons.util;
import org.apache.commons.codec.digest.DigestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import play.mvc.Result;
import play.twirl.api.Content;
import static play.mvc.Controller.request;
import static play.mvc.Controller.response;
import static play.mvc.Http.HeaderNames.ETAG;
import static play.mvc.Http.HeaderNames.*;
import static play.mvc.Results.notFound;
import static play.mvc.Results.ok;
import static play.mvc.Results.status;
/**
* Class to create thumbnails
*/
public class Etag {
private final static Logger logger = LoggerFactory.getLogger(Etag.class);
public static Result resultWithETag(Content content) {
if (content == null) {
return notFound("Given Content was not found");
}
String eTag = DigestUtils.md5Hex(content.body());
String ifNoneMatch = request().getHeader("If-None-Match");
if (ifNoneMatch != null && ifNoneMatch.equals(eTag)) {
return status(304);
}
String eTag = '"' + DigestUtils.md5Hex(content.body()) + '"';
response().setHeader(ETAG, eTag);
return ok(content);
return request().header(IF_NONE_MATCH)
.filter(eTag::equals)
.<Result>map(h -> status(304))
.orElseGet(() -> ok(content).withHeader(ETAG, eTag));
}
}
......@@ -11,8 +11,10 @@
'placeholder -> ""
) { (id, name, value, args) =>
<input type="text" id="@id" name="@name" value="@value" @toHtmlArgs(args) style="width: @{width}px;display:inline;" />
<a class="btn btn-primary image-upload" href="#"> Browse </a>
@if(helperText != null){
<button type="button" class="btn btn-primary image-upload" data-field="#@id">
Browse
</button>
@if(helperText != null) {
<span class="help-block">@helperText</span>
}
}
jQuery(document).ready(function($) {
$(function() {
var $form = $('#image-upload-form');
var $loader = $('#image-upload-loader'); // loder.gif image
var $confirmButton = $('#confirmUpload');
var $previewArea = $('#image-upload-modal .preview'); // preview area
$('.image-upload').click(function(e){
e.preventDefault();
$('.image-upload').click(function() {
$previewArea.html('');
$confirmButton.addClass('disabled');
$confirmButton.data('inputId', $('form').find('input[name="image"]').attr('id'));
$confirmButton.data('inputId', $(this).data("field"));
$('#image-upload-modal').modal('show');
});
......@@ -24,7 +23,7 @@ jQuery(document).ready(function($) {
$loader.hide();
$form.resetForm();
$confirmButton.removeClass('disabled');
$previewArea.html( '<img src="' + e.filename + '">' ).fadeIn();
$previewArea.html('<img src="' + e.filename + '">').fadeIn();
$confirmButton.data('filename', e.filename);
},
error: function(e){
......@@ -34,9 +33,9 @@ jQuery(document).ready(function($) {
$form.submit();
});
$('#confirmUpload' ).click(function() {
var imputId = $confirmButton.data('inputId');
$('#'+imputId).val($confirmButton.data('filename'));
$('#confirmUpload').click(function() {
var inputId = $confirmButton.data('inputId');
$(inputId).val($confirmButton.data('filename'));
$('#image-upload-modal').modal('hide');
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment