Commit f6e249ac authored by Caleb Weeks's avatar Caleb Weeks

Merge branch 'master' of gitlab.entropy.cc:blacklight/bl-edit into feature/fse-557

Conflicts:
	apps/routes/dialogs/edit/edit.js
parents bb909cd4 5c9beb5c
......@@ -18,6 +18,14 @@ module.exports = function(options){
});
////////////////////////////////////////////////////////////////////////////////////
router.all("/bl", function(req, res, next){
var config=req.bl.config;
req.url = config.appsMount + "blacklight/edit/home";
next('route');
});
////////////////////////////////////////////////////////////////////////////////////
router.get("/libs/granite/csrf/token.json", function(req, res, next){
proxy.process(null,{express:{req, res}},function(){});
......
......@@ -270,7 +270,7 @@ module.exports.process=function(data,$,cb){
}
var mapping=blMapRender(blMaps, slingData['sling:resourceType']);
var mapping=slingData ? blMapRender(blMaps, slingData['sling:resourceType']) : '';
var dialogContent = $.template({body:dialogBody, mapping, lock:inheritFrom?true:false, widgetConfigs:configs, dialogConfig: dialogConfig, title: dialogConfig.title, blMaps: blMaps});
......@@ -286,4 +286,4 @@ module.exports.process=function(data,$,cb){
cb(null, false);
}
\ No newline at end of file
}
......@@ -5,7 +5,6 @@ var TOOLS_ROUTES_DIR = 'tools';
module.exports = function($, callback){
var req = $.express.req;
var appsRoot =_path.join(global.bl.appRoot, "apps");
var staticTreeContent = {};
......
......@@ -69,13 +69,17 @@
{{/if}}
<div class="collapsible-header blue accent-2 {{#unless startClosed}}active{{/unless}} white-text" style="padding:1rem;">
{{#if pageTitle}}
<h5 style="margin:0;" class="white-text"><span class="" style="color: #eee!important; margin-right:12px;">{{@component.title}}:</span>
{{pageTitle}}
{{else}}
<h5 class="white-text" style="margin:0;">{{@component.title}}</h5>
{{/if}}
<h5 style="margin:0;" class="white-text">
{{#if bl:placeholderStub}}
<i class="material-icons left yellow-text tooltipped" data-tooltip="Component does not yet exist." style="margin-right: -2px;top: -8px;position: relative;left: -6px;">new_releases</i>
{{/if}}
{{#if pageTitle}}
<span class="" style="color: #eee!important; margin-right:12px;">{{@component.title}}:</span>
{{pageTitle}}
{{else}}
{{@component.title}}
{{/if}}
</h5>
</div>
<div class="collapsible-body" style="background-color:#fafafa;">
{{> page.component-body bl:key=@component.key bl:fromTopLevel=true}}
......
......@@ -2,7 +2,7 @@
var _url=require("url");
var httpSecure=require("https");
var httpInsecure=require("http");
var log = global.bl.logger.get("blacklight.edit");
var log = global.bl.logger.get("blacklight.edit:proxy");
var _=require("lodash");
var authorUrls={};
......@@ -87,7 +87,7 @@ module.exports.process = function(data, $, cb){
}
// console.log("PROXY_REQUEST:", options);
log.info("Proxying: ",proxyUri);
log.info("Proxying: ", proxyUri);
// console.log("PROXY TO:", options);
......@@ -106,6 +106,10 @@ module.exports.process = function(data, $, cb){
end: true
});
proxy.on("error", (err)=>{
log.error("Could not proxy to:", proxyUri, err);
})
cb(null, false);
}
......
......@@ -9,6 +9,17 @@
padding-right:1em;
padding-left:4px;
cursor:pointer;
}
::-webkit-scrollbar{
width: 0px;
height: 0px;
background: transparent;
}
.rtype:hover{
background-color: #ffa;
}
.component{
......
/* globals module, require, Materialize, BL, _ */
/* globals window, module, require, Materialize, BL, _ */
var slingConnector=require("./sling-client-connector.js");
var editPageDialogs=require("./page-dialogs");
......@@ -7,7 +7,7 @@ module.exports=function($, window){
var sling=slingConnector({$:$, _:_, page: window.BL.page});
var tree=require("./tree.js")($, window, {hasPageListingCapability: window.BL.config.hasPageListingCapability, supressSlingProxy: window.BL.config.treeIgnoreProxy, treeIcon: window.BL.config.treeIcon, languageSupport: true});
var view={};
var $modeButtons, modeButtons={}, currentMode="view", currentPath;
var $modeButtons, modeButtons={}, currentMode="view", currentPath, currentExtraHashSegments="";
var $iframe, $loadingIndicator;
var dialog = window.BL.editDialog;
var $document=$(window.document);
......@@ -153,6 +153,24 @@ module.exports=function($, window){
});
settingsButton.modalButton($.extend({},dialog.getStandardEditDialogOptions(), {beforeClose: function(){allowDialogOpen = false; return true;}}));
(function watchForIframeURLChanges(){
var last=$iframe[0].contentWindow.location.href, modes=global.BL.config.modes;
// TODO: Polling is lame, but iframe URL change events are not readily available
window.setInterval(function(){
var currentIframeLocation = $iframe[0].contentWindow.location;
var currentIframeURL = currentIframeLocation.pathname + currentIframeLocation.hash;
if(last!==currentIframeURL && currentIframeURL!==defaultFrameURL){
last=currentIframeURL;
var result = view.parseUrlByMode(currentIframeURL);
view.brieflyIgnoreHashEvents();
view.path(result.path);
view.mode(result.mode || view.mode());
view.applyPathAndMode({skipIframeLoad:true});
}
}, 2000);
})();
$iframe.on("load", function(){
try{
......@@ -246,7 +264,13 @@ module.exports=function($, window){
/****************************************************/
view.parseUrlByMode=function(url){
view.parseUrlByMode=function(href){
var incomingLocation = window.document.createElement("a");
incomingLocation.href = href;
var incomingPath = incomingLocation.pathname;
currentExtraHashSegments = (incomingLocation.hash || "").replace(/^\#\!?/,"");
if(!viewModeRegexes){
viewModeRegexes = _.mapValues(viewModes, (mode)=>{
var reg=new RegExp("^" + regexize(mode.prefix) + "(.*)" + regexize(mode.postfix) + "$" );
......@@ -255,10 +279,10 @@ module.exports=function($, window){
});
}
var result={path:url};
var result={path:incomingPath};
_.each(viewModeRegexes, (rule, mode)=>{
var match=url.match(rule.reg);
var match=incomingPath.match(rule.reg);
if(match){
if(!result.score || rule.score>result.score){
result={path:match[1], mode, score:rule.score};
......@@ -290,11 +314,6 @@ module.exports=function($, window){
}
/****************************************************/
view.setHash=function(){
view.brieflyIgnoreHashEvents();
window.document.location.hash="!" + currentPath + "." + currentMode;
};
/****************************************************/
view.path=function(path, dontSetHash){
......@@ -333,7 +352,7 @@ module.exports=function($, window){
if(!targetNode){
tree.openPath($("#nav-tree"), currentPath);
if(currentPath && currentPath!==defaultFrameURL){tree.openPath($("#nav-tree"), currentPath);}
}else{
targetNode.setActive(true);
}
......@@ -355,7 +374,7 @@ module.exports=function($, window){
if(currentPath === defaultFrameURL){
url=currentPath;
}else{
url = (mode.prefix?mode.prefix:"") + currentPath + (mode.postfix?mode.postfix:"");
url = currentPath? ((mode.prefix?mode.prefix:"") + currentPath + (mode.postfix?mode.postfix:"") + (currentExtraHashSegments?("#!" + currentExtraHashSegments):"")) : defaultFrameURL;
}
}else{
url=currentPath;
......@@ -364,11 +383,16 @@ module.exports=function($, window){
url=url?url.replace(/\/\//g,"/"):url;
if(!options.skipIframeLoad){
var currentUrl=$iframe[0].contentWindow.location.pathname;
if(currentUrl!==url){
var currentIframeURL=$iframe[0].contentWindow.location.pathname;
if(currentIframeURL!==url){
view.brieflyIgnoreFrameLoadEvents();
$iframe.attr("src", url);
$loadingIndicator.css("display", "block");
if(url){
$iframe.attr("src", url);
var parts=url.split("#");
if(parts[0]!==currentIframeURL){
$loadingIndicator.css("display", "block");
}
}
}
}
......@@ -424,10 +448,21 @@ module.exports=function($, window){
view.applyPathAndMode(); //skip reload of iframe if not a real click
}
/****************************************************/
view.setHash=function(){
view.brieflyIgnoreHashEvents();
window.document.location.hash="!" + currentPath + "." + currentMode + (currentExtraHashSegments?("!" + currentExtraHashSegments):"");
};
/****************************************************/
view.getHash=function(){
var hash=window.document.location.hash.replace(/\.html/g,"");
var parts=hash.match(/^\#\!(.*?)((\.[^\/^\.]*)?)$/,"");
var fullHash=window.document.location.hash.replace(/^\#\!?|\.html/g,"");
var hashSegments=fullHash.split("!");
var hash = hashSegments.shift();
currentExtraHashSegments = hashSegments.join("!") || "";
var parts=hash.match(/^(.*?)((\.[^\/^\.]*)?)$/,"");
if(parts){
view.path(parts[1], "dontSetHash");
view.mode(parts[2].slice(1) || defaultFrameMode, "dontSetHash");
......
......@@ -68,8 +68,12 @@ module.exports=function($, window, page, editDialog){
$el.html(`<a href="${page.blProxyPrefix}${slingPath}" target="_blank">${oldHtml}</a>`);
});
$(".collapsible-header").hover(function(){
$(".collapsible-header, .edit-button").hover(function(){
var $header=$(this);
if($header.data("target")){ // oops, acutally an edit button, not a header.
$header = $header.closest(".item-buttons").siblings(".collapsible-header");
}
var childCount = $header.data("childCount");
var off=$header.offset();
......@@ -89,7 +93,11 @@ module.exports=function($, window, page, editDialog){
if(off){$count.css("top", `${off.top}px`)};
}, function(){
$(this).find(".child-count").css("display", "none");
var $header=$(this)
if($header.data("target")){ // oops, acutally an edit button, not a header.
$header = $header.closest(".item-buttons").siblings(".collapsible-header");
}
$header.find(".child-count").css("display", "none");
})
};
......
......@@ -103,7 +103,7 @@ module.exports=function($, window, options){
///////////////////////////////////////////////////////////////////////////////////////////
tree.openPath=function($el, path, options){
var parts=path.split("/"), node, currentKey="";
var parts=(path||"").split("/"), node, currentKey="";
options=options||{};
parts.shift();
......
......@@ -2,6 +2,7 @@
$(function(){
var lastHover;
var reservedRtypes=["blacklight/meta", "foundation/components/parsys"];
/////////////////////////////////////////
$(".raw-nav").each(function(){
......@@ -21,6 +22,18 @@ $(function(){
});
/////////////////////////////////////////
$(".rtype").click(
function(){
var $link=$(this);
var rtype=$link.text().trim();
if(reservedRtypes.indexOf(rtype)>-1){return false;}
var url=window.BL.appsMount + "/blacklight/develop/cm#!" + window.BL.appsMount + "blacklight/develop/components/" + rtype + ".edit"
var win = window.open(url, '_blank');
win.focus();
}
);
/////////////////////////////////////////
$(".key").hover(
function hoverIn(e){
......
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