Atom snippet description with link - atom-editor

Is there a way to make a link inside a snippet description clickable/styled?
I know about descriptionMoreURL but I am interested in adding a second link.
This does not work:
'.source.js':
'test 1':
'prefix' : 't1'
'body': 't1()'
'description': 'Also works in combination with https://link.com'
This does not work:
'description': '[Also works in combination with](https://link.com)'
And this also does not work:
'description': 'Also works in combination with]'
Does anyone know how to do it / is it even possible?

It's not possible, unfortunately. The description doesn't seem to support any formatting whatsoever.
You can add HTML via parameters leftLabelHTML and rightLabelHTML, but if you click the link, it inserts the snippet, which is not ideal.
For reference, here's the documentation for the underlying autocomplete-plus suggestion parameters.

Related

Is it possible to show all options in Tokenize2?

Tokenize2 is a javacsript lib to select multiple options.
It provides a very neat UI to start writing and then get a list of options to select from. Selected options will show up as "tags" that can be removed with "x" link.
So far all is fine. But Right now you need to know what your looking for and start write at least one character to see matching alternatives.
In my scenario there are very few alternatives and they are not known to the user. I would like to show ALL options when the user clicks the input box. There is a configuration option named searchMinLength but it is already set to 0.
Is there a workaround that can be used? Maybe like triggering load and dropdown manually?
I know there are a lot of similar alternatives but I picked Tokenize2 because:
It looks clean and nice
It works in mobile browsers
I don't know if there is an "official" approach, but after some investigation I have found an acceptable workaround.
After downloading the Tokenizer2 sourceode I found the following line that triggered my attention:
if(this.input.val().length > 0){
this.trigger('tokenize:search', [this.input.val()]);
}
My interpretation is that the internal search command is not triggered unless the user input has at least one character. This line in sourcecode could easily be modified. I have filed a suggestion for this here: https://github.com/zellerda/Tokenize2/issues/26
My current workaround is to add an event listener for the select event and there trigger the internal search command. That works fine for my scenario and does not force a source code rewrite.
$("#my-dropdown").on("tokenize:select", function (e: Event, routedEvent: boolean) {
$("#my-dropdown").trigger('tokenize:search', "");
});
Tokenize2
This link worked for me GitHub
$('.tokenize-sample-demo1').on('tokenize:select', function(container){
$(this).tokenize2().trigger('tokenize:search', [$(this).tokenize2().input.val()]);
});

How to add timestamp to Atom snippets?

I have been trying to figure out how to add add timestamp to Atom Snippets.
'.text.plain':
'Timestamp':
'prefix': 'isoT'
'body': 'new Date().toISOString()'
This just prints the text and without ' it throws an error.
Is it possible to add javascript to an Atom snippet?
This is not possible. Snippets are stored in a CSON file, which is CoffeeScripts equivalent of JSON.
In all likelyhood, there already exists a package that inserts a timestamp. Otherwise, with knowledge of JavaScript, it's fairly easy to write your own. Take note that all commands provided by a package can be bound to a keystroke.

Where did this $ne come from for this find method?

Given the following Meteor code helper from the websites "Try Meteor" tutorial:
// Add to Template.body.helpers
incompleteCount: function () {
return Tasks.find({checked: {$ne: true}}).count();
}
I get pretty much everything about this code except for this arbitrary looking $ne thing. I've seen this before with Meteor examples and I don't get it: What does $ne represent? Where did $ne come from?
$ne means not equal to.
It is preferable to use this instead of {checked: false} since it also includes the ones where the checked attribute isn't in the document {} and the case where {checked: null} as both of these are cases where checked isn't equal to true & are also not false.
This way if you have a fresh document without any attributes it would also be a result of the query.

TAL Condition in Plone to hide HTML if it's a Document (Page)

I'm trying to modify my /portal_view_customizations/zope.interface.interface-plone.belowcontenttitle.documentbyline template with a tal expression, so that the document's author and the modification date do not show if the current portal type is a Document (Page). I don't mind if it shows for News Items, which are time sensitive, but not the Documents/Pages.
This is my failing Plone TAL expression:
<div class="documentByLine"
id="plone-document-byline"
i18n:domain="plone"
tal:condition="view/show and not:python:here.portal_type == 'Document'">
...
I've also tried:
<div class="documentByLine"
id="plone-document-byline"
i18n:domain="plone"
tal:condition="view/show and not:context/portal_type='Document'">
but still no luck. The tracebacks are pretty cryptic and don't relate to the TAL expression. However, if I get rid of my condition for portal_type, then it works again. Any thoughts are appreciated. A manual would be good, but I've looked at the official ones, and they don't mention this.
TAL's underlying TALES, the expression-engine of which TAL makes use of, doesn't support the mixing of expression-types in one expression. It's syntax allows only one expression-type to be specified (defaults to 'path', if omitted, btw), as no delimiter is provided (like a semicolon for chaining several TAL-statements in one element, e.g.).
But instead of mixing three expression-types you can use one python-expression, try:
python: view.show and context.portal_type()!='Document'
Update:
If you have customized a Plone's default-template via portal_view_customizations ('TTW'), now restricted python-methods cannot be accessed, that' why view/show throws an error.
It returns the allowAnonymousViewAbout-property of the site-properties, you can also check this condition yourself and your expression looks like:
tal:define="name user/getUserName"
tal:condition="python:test(name!='Anonymous User') and context.portal_type()!='Document';
Quick'n'dirty alternative:
Do it with CSS:
body.userrole-anonymous .documentByLine {display:none}
body:not(.template-document_view) .documentByLine {display:block}
This will render the hidden elements, but it's helpful for prototyping and such, or 'quickfixes' (no admin available, etc.).

Stop filtering WordPress function wp_insert_post

I have to make a few minor changes to a website built in WordPress, and I came across some problems with the wp_insert_content function. This function sanatizes input, taking some HTML tags completely out (like ) and deleting attributes on others. I would like to switch this off, and everywhere I find a link to http://pp19dd.com/2010/06/unfiltered-wp_insert_post/ where the solution is to add
'filter' => true
to the posts input array.
This article is from 2010 though, and from what I found an extra line was added in 2011 (http://web.archiveorange.com/archive/v/TDTh42SUwDEc1GFmSrvU). This line reads:
unset( $postarr[ 'filter' ] );
and is called right after merging the input with the defaults, and before sanitizing. It seems to me that this line cancels the 'filter' => true statement above. Indeed, sanitizing happens if the line is there, and disappears if the line is taken out.
So the easy solution would be to add the 'filter' => true and delete the extra line in the function. Problem though is that I have no idea where else the function is used, and I wonder if it's smart at all to hack right in the WP code. An update of WP would restore it anyway. So ... is there any other way to stop this function from sanitizing the input?
It is possible that some other plugin may be trying to sanitize the content, in such case remove all the filters is the only option, try the following:
remove_all_filters("content_save_pre");
$post_id = wp_insert_post($post);
Other possible filter tags are:
pre_content
pre_post_content
content_pre
Try them one by one also if it does not work.
i'm also in the process of importing posts with s in the content body.
i've been searching all morning for a solution, there have been some discussions on the topic. so far
kses_remove_filters();
has done nothing for me, neither did commenting these two lines:
unset( $postarr[ 'filter' ] ); // overrides 'filter' => true since 3.0 i guess
$postarr = sanitize_post($postarr, 'db');
in wp_insert_post() in post.php (defaults at line 2704).
there's another interesting bit at line 2874:
$data = apply_filters('wp_insert_post_data', $data, $postarr);
which seems like could be the source of our troubles, but i'm too much of a newbie to figure this out on my own.
really, truly, desperately need help! oh, and i can't comment, sorry for the spam action.
i would like to keep this thread open and find a solution.
I guess it worked before i posted, but the content i was importing already had HTML tags stripped
the easiest workaround would be to manually overwrite the content after inserting the post, but this only works for isolated environments or for importing
$wpdb->update($wpdb->posts, array("post_content"=>$content->content), array("ID"=>$postid), array("%s"), array("%d"));
anyhow,
remove_all_filters("content_save_pre");
did the trick!

Resources