Mirror-API: Can html cards be shared to Google+ contacts? - google-mirror-api

I am trying to share timeline cards with Google+ contacts. All the testing I've done is with one-to-one (private) shares.
If I set only the 'html' property, the share will be blank (other than the #throughglass tag).
If I set only the 'text' property, the share will include the string value that 'text' is set to (and the hash tag).
If I set both the 'html' and 'text' properties, the share will include the string value that 'text' is set to (and the hash tag).
Is this the expected behavior, or is there a way to share html content?

This is expected behavior.
If you want to share HTML content, you can add a custom menu option, which will send the timeline item and all its parameters to your server. You can then parse the timeline item's HTML parameter and send it to Google+ with the Google+ API.

Related

Reference an editable image in the CSS

How can I reference an image, editable in the Wagtail admin, from a CSS file?
I am designing a page type that will have a FooPage.banner_image field. The field is editable for each page, in the Wagtail admin; it describes the image to use for that page, as background on the banner.
The page style for that page then needs to use the banner image, referencing a URL to that specific image. What reference can I write in the CSS, so that it will get “the banner_image for this page” as a URL?
If you are needing an image URL outside of the template - see the docs about Generating renditions in Python.
To get a URL of an image, you need to generate a rendition and then get the URL of that rendition.
A rendition is what is generated when you pass in the resize rules (eg. width-400) in your templates.
To get a URL you can use this example code:
image_url = FooPage.banner_image.get_rendition('fill-300x186').url
OR get the original:
image_url = FooPage.banner_image.get_rendition('original').url

Google tag manager button reference

I'm trying to get google tag manager to track a couple of different buttons on a site. We're currently unable to change the site to aid with this, so we have to find a solution solely with tag manager.
There are several buttons on the site all with the same format as to the two below.. they all have "submit" as the type and a unique term for value so I'm trying to use the tag manager Form Listener which picks up on type="submit". Is there any variable I can use to pull the value field into my event so I can create individual goals in analytics?
etc etc
Any help is greatly appreciated.
You can use built-in variable "Click Element", then create custom JS-variable:
function(){
try{
return {{element}}.getAttribute("value"); //I am not sure now if it is {{element}} or {{Click Element}}
}catch(err){}
}
This will give you a value attribute of clicked button.
Maybe a useful link by Simo Ahava:
http://www.simoahava.com/analytics/track-form-engagement-with-google-tag-manager/#3
You can use built-in auto-event variable Element Attribute to get value. And be sure to use click tracking and not form tracking, because you want to track button clicks and not form submissions.

ngSanitize does not allow allow id attribute

I am using ngBindHtml to display some HTML from an (internal) CMS:
<span ng-bind-html="cmsHtml"></span>
The HTML contains a link with an id attribute:
"<a id='fsgPdfLink' href='http://blah/download.pdf' target='_blank'>Click here to download the PDF</a>"
However, I notice that the id attribute is removed by angular before writing the link to the page, so what gets rendered is just:
<a href='http://blah/download.pdf' target='_blank'>Click here to download the PDF</a>
Looking at the source for the ngSanitize module, it seems that for some reason the id attribute is not on the list of valid attributes:
https://github.com/angular/angular.js/blob/master/src/ngSanitize/sanitize.js#L206
What's the reason for not allowing the id attribute? Is it a security risk?
I'd really like to continue to use ngBindHtml if possible. Is there an API where I can add safe tags to the sanitizer's list? Or do I have to edit the source myself to add this tag?
To partially answer my own question, there doesn't seem to be an API to change the built-in whitelist, as described in this open issue:
https://github.com/angular/angular.js/issues/5900

Django-taggit: how to search for all tags based on another column or foreign key?

The django-taggit example shows how to get all tags for one specific model, and I know there is a way to get all tags in the system, but how do I get all tags based on a foreign-key?
I have tags for the Event model, and there is a primary-key/foreign-key relationship between the EventOrganizer and Event. Each EventOrganizer will have different set of tags, and when he/she logs in, I only want to show the tags that this organizer is concerned about.
Thanks!
Assuming your Event model looks something like this:
class Event(models.Model):
organizer = models.ForeignKey(EventOrganizer)
tags = TaggableManager(blank=True)
# ...
You can filter tags by event.organizer:
from taggit.models import Tag
tags = Tag.objects.filter(event__organizer=organizer)

How To Display HTML Tags Saved In Database Using Symfony 2 and Twig

I've managed to build a page that will display data from the database dynamically. However, this code which is saved in the database:
<p>This is the content for the radio page.</p>
Displays like this:
<p>This is the content for the radio page.</p>
The HTML tags aren't rendered. I understand that Symfony (for security purposes) renders any HTML code like this for security reasons. I want Symfony (obviously) to render these HTML tags. How can I achieve this just for this purpose only, so that Symfony still sanitises any HTML tag that is saved to the database elsewhere on the site?
For your information as well, this is the code that I am using to pull the data from the database:
public function mainpageAction($slug)
{
$content = $this->getDoctrine()
->getRepository('SiteMainBundle:Content')
->find($slug);
if (!$content) {
throw $this->createNotFoundException('No product found for slug '.$slug);
}
return $this->render('SiteMainBundle:Default:page.html.twig', array('content' => $content, 'slug' => $slug));
}
Also, just so I can learn more about Symfony, is the rendering of the HTML tags just the sole job of PHP or could it be rendered properly using Twig?
Many thanks!
If you want to do that, you need to use the raw filter in the twig template. Like described in the twig documentation, the raw filter marks the value as safe which means that in an environment with automatic escaping enabled this variable will not be escaped if raw is the last filter applied to it.
In your case, it's : {{ content | raw }}

Resources