Gatsby Page Creator Slugify Options - slugify

{
resolve: `gatsby-plugin-page-creator`,
options: {
path: `${__dirname}/src/pages/places/`,
slugify: { customReplacements: [['.', '..']] },
},
},
This is my plugin in gatsby-config.
I am trying to preserve the dots that are in the url of the pages i created, but somehow the custom replacements option does not work. Does anybody know how to solve this problem ?

Related

Deleting from within the edit page

Hi I'm trying to make it so I can have a delete button within the edit page to just directly delete whatever crud resource is being edited, now I began with taking a look at the list view and trying to reverse engineer the jQuery stuff that creates the delete buttons in the list and for the life of me I can't figure out how to do it. I tried grabbing the blade code in the delete.blade.php view and when I click the button that generates I get a 403 forbidden error. Now I was thinking I could continue messing with the jQuery but shouldn't that delete button code also work? My conclusion so far is I'm missing something stupidly obvious regarding permissions maybe? We're running the crud permissions package as well, would that impact anything? It's weird because I have the button in the
#if ($crud->hasAccess('delete'))
checking stuff so shouldn't that mean I already have permissions? I sure can delete the items from the list view still.
Sorry if I'm confusing, I'm a bit of a super tired dad and could use some help :p
Are you sure you're pointing the AJAX call in the right direction?
The list.blade.js javascript points to the current page, because it's the same URL, just a different protocol. If you place it on another page, it won't work as-is. You have to point it to $this->crud->route, still using the DELETE method. So something like this:
function register_delete_button_action() {
$("[data-button-type=delete]").unbind('click');
// CRUD Delete
// ask for confirmation before deleting an item
$("[data-button-type=delete]").click(function(e) {
e.preventDefault();
var delete_button = $(this);
var delete_url = '{{ url($this->crud->route) }}'; <---- notice the change here
if (confirm("{{ trans('backpack::crud.delete_confirm') }}") == true) {
$.ajax({
url: delete_url,
type: 'DELETE',
success: function(result) {
// Show an alert with the result
new PNotify({
title: "{{ trans('backpack::crud.delete_confirmation_title') }}",
text: "{{ trans('backpack::crud.delete_confirmation_message') }}",
type: "success"
});
// delete the row from the table
delete_button.parentsUntil('tr').parent().remove();
},
error: function(result) {
// Show an alert with the result
new PNotify({
title: "{{ trans('backpack::crud.delete_confirmation_not_title') }}",
text: "{{ trans('backpack::crud.delete_confirmation_not_message') }}",
type: "warning"
});
}
});
} else {
new PNotify({
title: "{{ trans('backpack::crud.delete_confirmation_not_deleted_title') }}",
text: "{{ trans('backpack::crud.delete_confirmation_not_deleted_message') }}",
type: "info"
});
}
});
}

Sencha Cmd disable compressor

Does anyone know how to remove compression of javascript file in sencha cmd?
I want that my production app.js file what fully readable.
And I want to configure this in my app.json if possible.
I did this:
/**
* Settings specific to production builds.
*/
"production": {
"compressor": null, // compressor null
"output": {
"js": {
"optimize": false, // optimize false
},
"appCache": {
"enable": false,
"path": "../cache.appcache"
}
},
"loader": {
"cache": "${build.timestamp}"
},
"cache": {
"enable": false
}
}
But whereas the compressor option work, at the end my file is still "compressed" (not minified but still in one line).
I try the optimize method in the ideal situation, I would like all Sencha Cmd optimization to be perform except to shrink everything in one line...
If somebody know.
Thanks in advance!
thanks to #bnz, the proposed answer was not fully right but it helps me found the solution.
So, to disable the last compression of the app.js file during the build process, you have to go to your <appFolder>/.sencha/app/production.properties and this directive:
enable.resource.compression=false
I did not found yet how to set this in the app.json
No answer worked for me, but I found further possible solutions at Sencha Forum (that worked): https://www.sencha.com/forum/showthread.php?315722-How-to-ignore-compression-in-production-build
I leave it here for future people reaching this thread :)
[copied from the link]
Sencha Cmd v6.5.3.16:
app.json:
"production": {
"compressor": {
"type": "none"
}
}
To disable optimizations:
"output": {
"js": {
"optimize": false
}
}
Sencha Cmd 6.2.2.36 (change all the following):
app.json:
"production": {
"compressor": {
"type": "none"
}
}
.sencha/app/production.properties:
enable.resource.compression=false
Using app.json you can add
"debug" : {
"enable":false/true
}
to your production build object.
If you wanna disable this in general, until the next app upgrade,
you can have a look under
.sencha/app/production.defaults.properties
OR better to overwrite the settings
.sencha/app/production.properties
You need to set
build.options.debug=true
there.

HelpPath in AEM6.1 Touch UI Dialogs

Along the top of Touch UI dialogs are a series of buttons. I need to configure the help button (leftmost) so it points to the documentation for the component. I see that helppath is the property name I should use according to this example from Adobe. But it's not working, and instead always points to https://www.adobe.com/go/aem6_1_docs which is not what we need.
Here is the cq:dialog http://localhost:4502/apps/blah/components/events/cq%3Adialog.2.json
I've tried both helpPath (works in Classic UI)and helppath, but it is not working in the Touch UI. Any help would be truly appreciated. Thanks!
{ jcr:primaryType: "nt:unstructured", helpPath:
"/content/blah/en/aem-support/events.html",
helppath:
"/content/blah/en/aem-support/events.html",
sling:resourceType: "cq/gui/components/authoring/dialog", content: {
jcr:primaryType: "nt:unstructured", sling:resourceType:
"granite/ui/components/foundation/container", layout: {
jcr:primaryType: "nt:unstructured", type: "nav", sling:resourceType:
"granite/ui/components/foundation/layouts/tabs" }, items: {
jcr:primaryType: "nt:unstructured" } } }
looking at the code it seems pretty well hard-coded...
private AttrBuilder getHelpAttrs(SlingHttpServletRequest req, Config cfg, XSSAPI xssAPI, I18n i18n) {
String url = i18n.getVar("https://www.adobe.com/go/aem6_1_docs");
AttrBuilder attrs = new AttrBuilder(req, xssAPI);
attrs.add("type", "button");
attrs.addClass("coral-MinimalButton cq-dialog-header-action cq-dialog-help");
attrs.addHref("data-href", url);
attrs.add("title", i18n.get("Help"));
return attrs;
}
I can see you have used 2 times "helpPath" property. Kindly add once under cq:dialog node and check. For me its working fine.

How can I make a chrome packaged app which runs in fullscreen at startup?

Currently it seems that the fullscreen ability can only be activated from a user action (mouse/keyboard event). Is there a way to circumvent this?
Now, you can just add the state:"fullscreen" property on your main .js:
chrome.app.runtime.onLaunched.addListener(
function() {
chrome.app.window.create('index.html',
{
state: "fullscreen",
}
);
}
);
Make sure you don't add resizable: false or bounds properties, and you add a "fullscreen" permision on the manifest.json.
{
...
"permissions": [
...
"fullscreen"
]
}
You can use the HTML5 Fullscreen API, which requires a user action:
button.addEventListener('click', function() {
document.body.webkitRequestFullscreen();
});
or the more "app-y" way using the AppWindow object, which doesn't require a user action:
chrome.app.window.current().fullscreen();
Both need the "fullscreen" permission in the manifest.json.
I have got it working with below code
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', {
'width': 1024,
'height': 768
},
function(win) {
win.maximize();
});
});
Check out https://plus.google.com/100132233764003563318/posts/2SuD7MVd8mG referring to recently landed changelist https://chromiumcodereview.appspot.com/12205002. You can lift sample code from either of those sources:
document.body.addEventListener('click', function() {
document.body.webkitRequestFullscreen();
});
Make sure in your manifest you're requesting the "fullscreen" permission and that you're testing on a sufficiently recent Chrome build (beta channel ought to have this feature by now, and dev definitely does).
Your question specifically refers to packaged apps, but in case anyone reading this answer missed this, this will work only with Chrome packaged apps.
main.js
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html',{},function(window) {
window.fullscreen();
});
});
manifest.json
{
...
"manifest_version": 2,
"minimum_chrome_version": "23",
"app": {
"background": {
"scripts": ["main.js"]
}
},
"permissions": ["fullscreen"]
}
Edit: Per BeardFist's comment, my original answer was wrong on two fronts. You can do this on a Chrome Extension (which this is tagged as), but probably not on a packaged app.
For extensions you can make it go fullscreen using the state:"fullscreen" option, which can be applied with chrome.window.update. The code below chains the creation of the window via chrome.windows.create with chrome.window.update. In my experiments you could not set the fullscreen state directly through the window creation.
chrome.windows.create(
{url:"PATH/TO/POPUP"},
function(newWindow) {
chrome.windows.update(newWindow.id, {state:"fullscreen"})
});

Chrome Extension - Duplication of the event listener?

Introduction
I've got a problem with my extension for Chrome. It supposed to show a small overlay popup window (created in jQuery) with search results from google based on your text selection. Basically you should be able to highlight a text on any page, right click on it (context menu), click on "Search for 'selected keyword'" and a small window pops up in the same tab as an overlay with all search results from google or different search engine.
The problem
Now the extension works really well and without problems, HOWEVER after extensive using of this extension (let's say 1 hour) when I'll highlight another keyword and search for it, extension REMEMBERS last keyword and shows wrong search results. Then again, when I'll highlight another keywords it rememebrs the keyword I've just highlighted but previously didn't get the results for it. It's like a chaining process and I'm always one keyword behind.
My thoughts
I think that the cause of this problem might be event listeners, because when this problem occurs I've got a log from console.log(chrome.extension.onRequest.hasListeners()); which says true. It means that there are 2 or more event listeners attached and they shouldn't as I'm removing them by chrome.extension.onRequest.removeListener(listener1);
Maybe it happens when the actual web page is still loading and I'm highlighting keyword, clicking on context menu and extension can't load yet but somehow event listeners firing... I really can't fully replicate this problem... and what causes this problem.
Manifest File
{
"name": "Search Accelerator",
"version": "1.0",
"manifest_version": 2,
"description": "Search Accelerator extension",
"icons": {
"16": "icon19.png",
"48": "icon48.png",
"128": "icon128.png"
},
"background": {
"scripts": ["content_script.js"]
},
"minimum_chrome_version": "18",
"permissions": [
"contextMenus",
"tabs",
"http://*/*",
"https://*/*",
"management",
"webRequest"
]
}
Content Script
chrome.contextMenus.create({ "title": 'Search for "%s"',
"contexts":['selection'], "onclick": getClickHandler() });
function getClickHandler() { return function(info, tab) {
console.log(chrome.extension.onRequest.hasListeners());
chrome.extension.onRequest.addListener(function listener1 (request, sender, sendResponse) {
var url = "http://www.google.com/?s=" + info.selectionText;
console.log(url); var keywordObj = {keyword: url};
if (request.keywordRequest == "Yes") {
console.log(keywordObj);
sendResponse(keywordObj);
};
chrome.extension.onRequest.removeListener(listener1); } );
chrome.tabs.executeScript(null, { file: "jquery.js" }, function() {
chrome.tabs.executeScript(null, { file: "popup.js" });
}); }; };
Popup js
chrome.extension.sendRequest({keywordRequest: "Yes"}, function(response) {
$(document).ready(function() {
if($("#e14_accelerator")) {
$("#e14_accelerator").remove();
}
var rkeyword = response.keyword;
$("body").append("<div id=\"e14_accelerator\" style=\"position: fixed;top: 30px;right: -330px;z-index: 999999; \"><iframe style=\"border:5px solid #c9c9c9;-webkit-box-shadow: 1px 1px 15px 1px rgba(0, 0, 0, 0.2);\" src=\""+ rkeyword +"\" width=\"328\" height=\"240\"></iframe></div>");
$("#e14_accelerator").animate({right:-13},500);
$(document).click(function() {
$("#e14_accelerator").remove();
});
$("#e14_accelerator").click(function() {
return false;
});
});
});
Error messages that appear when this problem occur:
Error during tabs.executeScript: Cannot access contents of url "chrome-devtools://devtools/devtools.html?docked=true&dockSide=bottom&toolbarColor=rgba(230,230,230,1)&textColor=rgba(0,0,0,1)". Extension manifest must request permission to access this host. sendRequest:21
chromeHidden.handleResponse sendRequest:21
Error during tabs.executeScript: Cannot access contents of url "chrome-devtools://devtools/devtools.html?docked=true&dockSide=bottom&toolbarColor=rgba(230,230,230,1)&textColor=rgba(0,0,0,1)". Extension manifest must request permission to access this host. sendRequest:21
chromeHidden.handleResponse