Cannot display post of Blogger with custom template code - templates

I make this code:
<b:widget id='Blog1' type='Blog' locked='true'>
<b:includable id='wrap' var='post'>
<b:loop var='post' values='data:posts'>
<b:include name='post' data='post'/>
</b:loop>
</b:includable>
<b:includable id='post' var='post'>
<a expr:href='data:post.url'><h3><data:post.title/></h3></a>
<p><data:post.author/></p>
<section><data:post.body/></section>
</b:includable>
</b:widget>
Here is the problem, it cannot display the post which is title, author name, body. I don't understand why, I've done everything like the "Help page" of Blogger said but it is not working. I also try to use original code of old template (which still working well) but it just have a same fate with my code when I paste it into my new template, not working.
Does anyone have any idea?

I have a similar problem.
This happens because in a recent update Blogger automatically saves post.body elements in a specific order and does not let you to alter it.
Still trying to find a workaround myself.

Related

How can I configure VS Code to work with Prettier HTML formatter?

I am trying to have VS Code format my Django HTML files but I am getting:
There is no document formatter for 'django-html'-files installed.
The solution I found on the web works with Beautify, not Prettier.
How can I make it work with Prettier?
#Tedkovsky's answer might technically address the error you're getting, but once you're past that, you'll see that Prettier will mangle your templates since it tries to break long lines containing template tags like {{ }} and {% %}.
This is because Prettier currently (as of 2021-01-09) doesn't support Jinja or Django templates, and for the time being, it looks like the developers aren't interested in adding this functionality. There are 2 (closed) tickets about it here:
https://github.com/prettier/prettier/issues/5581
https://github.com/prettier/prettier/issues/5754
I wasn't able to find a plugin for it either, so it doesn't look like there's a solution for using Prettier with Django templates.
edit: I've been following this thread in the Django forum about autoformatters for Django templates. Perhaps something might materialize there.
later edit: Looks like djhtml can handle indentation, although it's separate from Prettier. It doesn't do full autoformatting, though.
even later edit: djlint can also be used for formatting templates
In settings.json, try
"[django-html]": {
"editor.defaultFormatter": "prettier"
},

How to modify a pyramid template on the fly before rendering

please I am working on a site where I would scrap another website's html table source code and append it to my template before rendering my page.
I have written the script which stores the html code in a variable but don't know how to appendix it.
Kindly suggest.
If you're using jinja, try this:
<div class="html-content">{{scraped_html|safe}}</div>
Here is the code for the chameleon template system. HTML is the variable that contains your html code that is passed to the template.
<div>${structure: HTML}</div>
Or I believe this will work also
<div tal:content="HTML"></div>

content empty when using scrapy

Thanks for everyone in advance.
I encountered a problem when using Scrapy on Python 2.7.
The webpage I tried to crawl is a discussion board for Chinese stock market.
When I tried to get the first number "42177" just under the banner of this page (the number you see on that webpage may not be the number you see in the picture shown here, because it represents the number of times this article has been read and is updated realtime...), I always get an empty content. I am aware that this might be the dynamic content issue, but yet don't have a clue how to crawl it properly.
The code I used is:
item["read"] = info.xpath("div[#id='zwmbti']/div[#id='zwmbtilr']/span[#class='tc1']/text()").extract()
I think the xpath is set correctly and I have checked the return value of this response and it indeed told me that there is nothing under this directory. Results shown here:'read': [u'<div id="zwmbtilr"></div>']
If it has something, there should be something between <div id="zwmbtilr"> and </div>.
Really appreciated if you guys share any thoughts on this!
I just opened your link in Firefox with NoScript enabled. There nothing inside the <div #id='zwmbtilr'></div>. If I enable the javascripts, I can see the content you want. So, as you already new, it is a dynamic content issue.
Your first option is try to identify the request generated by javascript. If you can do that, you can send the same request from scrapy. If you can't do it, the next option is usually to use some package with javascript/browser emulation or someting like that. Something like ScrapyJS or Scrapy + Selenium.

django - ckeditor bug renders text/string in raw html format

am using django ckeditor. Any text/content entered into its editor renders raw html output on the webpage.
for ex: this is rendered output of ckeditor field (RichTextField) on a webpage;
<p><span style="color:rgb(0, 0, 0)">this is a test file ’s forces durin</span><span style="color:rgb(0, 0, 0)">galla’s good test is one that fails Thereafter, never to fail in real environment. </span></p>
I have been looking for a solution for a long time now but unable to find one :( There are some questions which are similar but none of those have been able to help. It will be helpful if any changes suggested are provided with the exact location where it needs to be changed. Needless to say I am a newbie.
Thanks
You need to mark the relevant variable that contains the html snippet in your template as safe
Obviously you should be sure, that the text comes from trusted users and is safe, because with the safe filter you are disabling a security feature (autoescaping) that Django applies per default.
If your ckeditor is part of a comment form and your mark the entered text as safe, anybody with access to the form could inject Javascipt and other (potentially nasty) stuff in your page.
The whole story is explained pretty well in the official docs: https://docs.djangoproject.com/en/dev/topics/templates/#automatic-html-escaping

Customizing Containable Content in Orchard CMS

I am currently trying to understand a bit more about how Orchard handles Lists of Custom Content Types and I have run into a bit of an issue.
I created a Content Type named Story, which has the following parts:
Body
Common
Containable
Route
I created a list that holds these items, and all I am attempting to do is style them in such a way:
Story Title
Story Description (Basically a truncated version of the body?)
However, I cannot seem to figure out how to do the following:
Get the Title to actually appear (Currently all that appears is the body and a more link)
Remove the "more" link (and change this to be the actual Title)
I have looked into changing the Placement.info, and have looked all over in an attempt to find where the "more" link is added in each of the items. Any help would be greatly appreciated.
I finally managed to figure it out - Thanks to the Designer Tools Module, which made it very simple to go look into what was going on behind the scenes during Page Generation.
Basically - all that was necessary to accomplish this was to make some minor changes to the Parts.Common.Body.Summary.cshtml file. (found via ../Core/Common/Views/)
Which initially resembles the following:
#{
[~.ContentItem] contentItem = Model.ContentPart.ContentItem;
string bodyHtml = Model.Html.ToString();
var body = new HtmlString(Html.Excerpt(bodyHtml, 200).ToString()
.Replace(Environment.NewLine,"</p>"+Environment.NewLine+"<p>"));
}
<p>#body #Html.ItemDisplayLink(T("more").ToString(), contentItem)</p>
however by making a few changes (by using the Designer Tools) I change it into the following:
#{
[~.ContentItem] contentItem = Model.ContentPart.ContentItem;
string bodyHtml = Model.Html.ToString();
string title = Model.ContentPart.ContentItem.RoutePart.Title;
string summary = Html.Excerpt(bodyHtml, 100) + "...";
}
<div class='story'>
<p>
#Html.ItemDisplayLink(title, contentItem)
</p>
<summary>
#summary
</summary>
</div>
Although it could easily be shortened a bit - It does make the styling quite a big easier to handle. Anyways - I hope this helps :)
Alternately you can use the placement.info file in your theme assign different fields to your Summary and Detail views. It's much simplier.
http://orchardproject.net/docs/Understanding-placement-info.ashx
But, I used the same method you did till I discovered the .info file as well. It works and gives you a good understanding of how the system works, but the placement.info file seems easier.
Also, you probably don't want to be editing the view files in Core. I think your meant to override views in your theme directory.