Using variables in blogger posts - templates

I'm using blogger to make a podcast. It works really well, but I find myself copy/pasting a lot of things, when two or three variables and a template would do the job really well.
Most of the posts look like this:
Étude de Exode 6.14-7.13.
<br />
<audio controls>
<source src="file.mp3" type="audio/mpeg">
<embed height="50" width="100" src="file.mp3">
</audio>
<biblia:bible layout="minimal" resource="lsg" width="400" height="600" historyButtons="false" navigationBox="false" resourcePicker="false" shareButton="false" textSizeButton="false" startingReference="Ex6.14-7.13"></biblia:bible>
Where three things change:
the text on top ("Étude de Exode 6.14-7.13." in the example)
the link to the sound file (which is actually data:post.link, but I can't seem to be able to use expr:src there unfortunately)
the references passed to the biblia:bible tag (here 'Ex6.14-7.13')
Is there a way I could use a template and variables for my blog posts instead of copying and changing things manually every time?

You can, however, convert a string object into valid Blogger XML data. So, first, you need to write this object as your post content (make sure you are in the HTML mode):
{
text: "Étude de Exode 6.14-7.13.",
source: "file.mp3",
ref: "Ex6.14-7.13"
}
After that, inside your blog template, find <data:post.body/> then replace with this:
<b:with var='param' expr:value='data:post.body'>
<data:param.text/>
<br/>
<audio controls='controls'>
<source expr:src='data:param.source' type='audio/mpeg'/>
<embed height='50' width='100' expr:src='data:param.source'/>
</audio>
<biblia:bible layout='minimal' resource='lsg' width='400' height='600' historyButtons='false' navigationBox='false' resourcePicker='false' shareButton='false' textSizeButton='false' expr:startingReference='data:param.ref'/>
</b:with>
Here’s the basic concept: https://www.dte.web.id/2018/07/custom-blogger-widget.html

I am not personally familiar with blogger, but it looks like you can create a widget, and assign variables that way:
<html
xmlns = 'http://www.w3.org/1999/xhtml'
xmlns:b = 'http://www.google.com/2005/gml/b'
xmlns:data = 'http://www.google.com/2005/gml/data'
xmlns:expr = 'http://www.google.com/2005/gml/expr'
>
<b:includable id='post' var='post'>
<data:post.title/>
<br />
<audio controls>
<source src="<data:post.file/>" type="audio/mpeg">
<embed height="50" width="100" src="<data:post.file/>">
</audio>
<biblia:bible layout="minimal" resource="lsg" width="400" height="600" historyButtons="false" navigationBox="false" resourcePicker="false" shareButton="false" textSizeButton="false" startingReference="<data:post.reference/>"></biblia:bible>
</b:includable>
and then to use it...
<b:include name='post' data='p' cond='index < 10'/>
This is a total crap shoot though as I have never used blogger personally, this is just from documentation.
I am referencing material from here:
https://support.google.com/blogger/answer/46995?hl=en
http://thoughtsomething.blogspot.com/2009/01/understanding-blogger-template-1.html
http://helplogger.blogspot.com/2014/03/how-to-create-custom-color-and-font-variable-definitions-to-blogger.html

Related

How to display base64 image on html without putting all the big base64 string in my html?

I have generated my base64 string from my image and assigned it to : session['graph']
When I have this code, it works:
<pre>
<img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYA
..... " />
</pre>
This works as well:
def graph():
d=base64 string
return '<img src="data:image/png;base64,%s" width="640" height="480" border="0"/>' %(d)
But I want use jinja for dynamic display of my images and graphs.
Using jina, this code is not working: can you help me to fix it please? thanks
<pre>
<img src="data:image/png;base64,{{session['graph']}}" />
<pre>
or this one is also not working in html file:
<p>
'<img src="data:image/png;base64,%s" width="640" height="480" border="0"/>' %(d)
</p>
It might worth checking for {{seession['graph']}} not to accidentally include data:image/png;base64 part. Exactly my recent issue in a similar case

Mako inhereting from multiple files

I have a pyramid application with multiple views each depending on a single mako template. The views are quite complicated and bug free, so I don't want to split or merge views, and by extension, the corresponding templates.
However, I would like a single view to represent all the others. Merging all the pyramid views and templates is practically not an option.
For example, I have a login view & template and a signup view & template. Now I want my root page to contain both of them. Both login and signup inherit from base.mak, which contains common scripts and style sheet imports. The following is a pictorial representation of the mako import structure I want.
base.mak
/ \
login.mak signup.mak
\ /
root.mak
Alternatively, I tried chaining them as such:
base -> login -> signup -> root
However, I think that the views no longer talk to their respective templates.
My problem comes in when I do the 3rd chain (login.mak -> signup). I'll post analogous and extract code below, since my full code is a bit long (If more code is needed, feel free to shout).
base.mak:
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<title>
${next.title()}
</title>
#Imports
${next.head()}
</head>
<body>
<div id = "content">
${next.body()}
</div>
</body>
</html>
login.mak:
<%inherit file="base.mak"/>
<%def name="title()">
${next.title()}
</%def>
<%def name="head()">
${next.head()}
</%def>
<div id="login">
<div id="message">
${sMessage}
</div>
<div id="form">
<form action="${url}" method="post"> <--- url returned in views.py
...
</div>
${next.body()}
signup.mak:
<%inherit file="login.mak"/>
<%def name="title()">
</%def>
<%def name="head()">
</%def>
<div id="box">
...
</div>
Now my problem here is that my url returned from my views is undefined when I try to inherit as in above.
Then of course if I get this working, adding base.mak to to inherit from signup should be trivial.
I assume that there is a simple fix for this, but I can't find an example/explanation on how to do this in pyramid, where the templates actually do stuff.
Alternatively, Is there another way to bring together multiple pyramid views and templates into a single view?
Ok, I figured it out. One has to use mako's <%include/>, and then there is no complicated inheritance structure. So, now my files look like this:
root.mak
<%inherit file="base.mak"/>
<%def name="title()">
Welcome
</%def>
<%def name="head()">
</%def>
<%include file="login.mak"/>
<%include file="signup.mak"/>
login.mak:
<%inherit file="base.mak"/>
<%def name="title()">
</%def>
<%def name="head()">
<link rel="stylesheet" type="text/css" href="${request.static_url(...
</%def>
<div id="login">
<div id=".....
</div>
and the same structure with signup.mak. base.mak still looks the same as in the question above.
Now, if you're using pyramid (I assume another framework will work the same), and you have views that receive and pass information from forms for example, then turn them into normal functions (without #view_config(renderer='path/file.mak') and place their functionality into the parent view function, in my case root. In other words:
#view_config(renderer='pyramidapp:templates/root.mak',
context=Root,
name="")
#forbidden_view_config(renderer='pyramidapp:templates/root.mak')
def root(self):
xLoginRet = login(self)
xSignupRet = signup(self)
#logic and functionality for both, return stuff to go to base.mak

jSoup - How to get elements with background style (inline CSS)?

I'm building an app in Railo, which uses the jSoup .jar library. It all works really well in my CFML language.
Anyhow, I can grab every element with a "style" attribute doing:
<cfset variables.mySelection = variables.myDocument.select("*[style]") />
But this returns an array which contains elements that sometimes do not have a "background" or "background-image" style on them. As an example, the HTML might looks like so:
<p style="color: red;">I should not be selected</p>
<p style="background: green">I **should** be selected</p>
<p style="text-align: left;">I should not be selected</p>
<p style="background-image: url("/path/to/image.jpg");">I **should** be selected</p>
So I can get these elements above, but I don't want the 1st and 3rd in my array, as they don't have a background style...do you know how I can only grab and work with these?
Please note, I'm not after a COMPUTATED style, or anything that complicated, I'm just wondering if I can filter based on the properties of an inline CSS style. Perhaps some regex after the fact? I'm open to ideas!
I tried messing with :contains(background) as a key word, but I wasn't sure if that was the correct path?
Many thanks for your help.
Michael.
Try with:
variables.myDocument.select("*[style*='background']")
As *= is the standard selector to match a substring in the attribute content.
Elements els = doc.select(div[style*=dashed]);
Or
Elements elements = doc1.select("span[style*=font-weight:bold]");

Sitecore Field Renderer - add markup inside rendering

As part of an SEO enhancement project, I've been tasked with adding the following property inside the markup for the image that the field renderer is generating on the page:
itemprop="contentURL" - before the closing tag.
<sc:FieldRenderer ID='FieldRenderer_MainImage' Runat='server' FieldName='Homepage Image'
CssClass="_image" Parameters="w=150" itemprop="contentURL" />
When I tried to place this inside the Field Renderer, or add it as a "parameter" - it doesn't work.
Is there another way to do this, without having to create a control file and generate the output in the code-behind?
You need to use the "Parameters" property for setting extra properties on both the and control.
You can to it like this :
<sc:FieldRenderer ID="PageImage" runat="server" FieldName="ContentImage" Parameters="ControlType=C4Image&rel=relString" />
<sc:Image ID="SCPageImage" runat="server" Field="ContentImage" Parameters="ControlType=C4Image&rel=relString" />
That will be rendered like this :
<img width="1232" height="637" controltype="C4Image" rel="relString" alt="" src="~/media/Images/DEMO backgrounds/background2.ashx">
Note: This works in 6.5 and 6.6 - not sure which version is being used in this question.
Couldn't this be done by extending the RenderField pipeline? You could potentially decompile (using Reflector or ILSpy) the GetImageFieldValue and add your own logic to adjust the output from the ImageRenderer?
Reference Sitecore.Pipelines.RenderField.GetImageFieldValue.
In cases where "Parameters" doesn't work or trying to create a Custom control, and instead of wrapping the control in a classed div like this:
<div class="my-class">
<sc:FieldRenderer runat="server" />
</div>
You can use this:
<sc:FieldRenderer Before="<div class='my-class'>" After="</div>" runat="server" />
Notice the Single quotes in the class declaration of the div above.
This keeps it a little cleaner and in context with the Sitecore control instead of a Web Developer adding an external div that might later lose its context if changes occur.
I recommend saving yourself some trouble and using the MVC version of Sitecore though, now, (when starting new Sitecore projects), as you can very simply add a class to it like so:
How can I get Sitecore Field Renderer to use a css class for an image
You actually cannot do this on a FieldRenderer. You're options are:
Extend the FieldRenderer with the ability to do this (this will likely require a high level of effort)
Use a regular .NET control and bind the data from the Sitecore item via the C# code-behind.
You may want to try using the <sc:image /> tag.
If you add a custom parameter there, it's added as an attribute to the img tag.
In your case the tag will look like this:
<sc:image runat="server" field="Homepage Image" width="150" itemprop="contentURL" class="_image" />
using mvc, I found this was easier than extending the FieldRender, should be reusable, but will have to test a bit more. WIP.
var image = "<span class=\"rightImage\">" + FieldRenderer.Render(contentBlock, "Image", "mw=300") + "</span>";
var text = FieldRenderer.Render(contentBlock, "Text");
model.Text = FieldRendererHelper.InjectIntoRenderer(text, image, "<p>");
public static HtmlString InjectIntoRenderer(string parentField, string injectField, string injectTag)
{
return new HtmlString(parentField.Insert(parentField.IndexOf(injectTag, StringComparison.InvariantCulture) + injectTag.Length, injectField));
}

Find ColdFusion Generated ID

Is there a way to find the elements generated by ColdFusion's <CFLayout> and <CFLayoutArea> tags?
These tags:
<cflayout type="tab" name="MyAccount">
<cflayoutarea name="OrderStatus" title="P" source="/o.cfm" />
Generate this code:
<td id="ext-gen31" style="width: 174px;">
<a id="ext-gen28" class="x-tabs-right" href="#">
<span class="x-tabs-left">
<em id="ext-gen29" class="x-tabs-inner" style="width: 154px;">
<span id="ext-gen30" class="x-tabs-text" title="P" unselectable="on" style="width: 154px;">
I want to update the title information in the id of ext-gen30 but don't know what that name is going to be or how to find it.
It doesn't directly answer your question, but if your goal is to get a reference to the DOM objects in order to set their properties (and it sounds like that's the case), then the documentation suggests that you should be able to use the function ColdFusion.Layout.getTabLayout() to get a reference to the Ext layout object, and then manipulate that however you'd like.