Is there any change in the usage of readingTime parameter in config.toml for displaying the reading time of the posts?
[params]
# Shown in the home page
dateFormat = "02 Jan 2006, 15:04"
# Show estimated reading time for posts?
readingTime = true
The above configuration is not working, when used along with Blackburn theme.
The readingTime param is not supported for the Blackburn theme.
See the example site config file for all supported params:
https://github.com/yoshiharuyamashita/blackburn/blob/master/exampleSite/config.toml
Related
I am trying to set up some URL rewrites in Netlify.
I want to set up a rewrite to redirect
https://example.com/blog/2019/05/15/hello.html
to
https://example.com/blog/2019/05/hello.html
I read the document - https://www.netlify.com/docs/redirects/#placeholders:
You can use placeholders in the origin and target paths:
/news/:year/:month/:date/:slug /blog/:year/:month/:date/:slug
This would redirect a URL like /news/2004/02/12/my-story to /blog/2004/02/12/my-story
And I have my _redirects file like this:
# Redirect old permalinks to new format
/blog/:year/:month/:date/:slug.html /blog/:year/:month/:slug.html 301!
It did work to redirect
https://example.com/blog/2019/05/15/hello.html
to
https://example.com/blog/2019/05/hello.html
But there is a weird problem, it also redirects
https://example.com/blog/2019/05/not-a-date/index.html
to
https://example.com/blog/2019/05/index.html
My question is, Is it able to (if yes, how can I) make the :date placeholder matching day only? not-a-date is not a date obviously, shouldn't :date match 01 to 31 only?
To my knowledge the placeholders aren't typed (allowing only numbers). So anything will match and it's not possible to define only days as a pattern to match.
https://www.healingislands.com/* http://www.healingisland.com:splat 301!
putting { /* } this at the end of the first link and putting { :splat 301! } this at the end just worked for me
I have a very simple code
Logger logger = Logger.getLogger(HelloAppEngine.class.getName());
logger.log(Level.INFO, "This is now: {0}", new Date());
defined inside a (Maven based) Google App Engine project.
The output of this log is
giu 10, 2017 6:03:10 PM it.log.HelloAppEngine doGet
INFO: This is now: 10/06/17 18.03
with the default Date format. I want to customize the Date format with my own.
I don't really know where this configuration need to be placed, I think that can be inside the logging.properties file, but I'm unable to find the proper cofniguration
Which is the proper way to customize the Date format provided by the lazy-evaluted log message?
I found the relevant code inside the java.text.MessageFormat class.
which is triggered to format the Date object
It does not seem that is accessing to an external configuration in order to format the date, it uses a fixed DateFormat.SHORT format. Maybe there is a way to provide a custom formatter which will override that entire implementation.
I want to customize the Date format with my own.
I don't really know where this configuration need to be placed, I think that can be inside the logging.properties file, but I'm unable to find the proper configuration
You have to include the date format in the log string as described in the java.text.MessageFormat class level docs. As stated there you can use any of the java.text.SimpleDateFormat patterns.
For example, you can use the DateFormat constants:
logger.log(Level.INFO, "This is now: {0,date,long} at {0,time,full}", new Date());
Otherwise, you can use a pattern:
logger.log(Level.INFO, "This is now: {0,date,EEE, MMM dd HH:mm:ss:S ZZZ yyyy}", new Date());
If you use localization in your logging you can replace the messages with a shorter key and leave the date format patterns in your ResourceBundle.
I can not figure out how to get the flow field working in admin,
I would like example shown at shown https://raw.githubusercontent.com/lektor/lektor-assets/master/screenshots/admin.png When I then click through to localhost:5000/admin/root/edit and get the http://i.imgur.com/EPCrBRC.png
Got I feel I am doing something simple wrong. But cutting it down to basic here is what I tried:-
$ cd /tmp/
$ lektor quickstart
Lektor Quickstart
=================
This wizard will generate a new basic project with some sensible defaults for
getting started quickly. We jsut need to go through a few questions so that
the project is set up correctly for you.
Step 1:
| A project needs a name. The name is primarily used for the admin UI and
| some other places to refer to your project to not get confused if multiple
| projects exist. You can change this at any later point.
> Project Name: flow-example
Step 2:
| This is the path where the project will be located. You can move a
| project around later if you do not like the path. If you provide a
| relative path it will be relative to the working directory.
> Project Path [/tmp/flow-example]:
Step 3:
| Do you want to generate a basic blog module? If you enable this the
| models for a very basic blog will be generated.
> Add Basic Blog [Y/n]: n
Step 4:
| Your name. This is used in a few places in the default template to refer
| to in the default copyright messages.
> Author Name [Brendan M. Sleight,,,]:
That's all. Create project? [Y/n] Y
$ cd flow-example/
$ echo "[fields.extra]
> label = Extra
> type = flow
> flow_blocks = text" >>./models/page.ini
$ cat ./models/page.ini
[model]
name = Page
label = {{ this.title }}
[fields.title]
label = Title
type = string
[fields.body]
label = Body
type = markdown
[fields.extra]
label = Extra
type = flow
flow_blocks = text
$ lektor server
* Project path: /tmp/flow-example/flow-example.lektorproject
* Output path: /home/bms/.cache/lektor/builds/76682e6a8f99116f0da91bcf96203e94
Started source info update
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Finished source info update in 0.05 sec
Started build
U index.html
U about/index.html
U projects/index.html
Finished build in 0.12 sec
Started prune
Finished prune in 0.00 sec
```
It takes a bit of careful documentation reading to find out what needs to go where to make flow blocks work.
You need to create a folder flowblocks at the same level where your content and models folders are.
Put your flowblock model files in this folder (example: image-paragraph.ini)
Create a blocks folder inside your templates folder.
Put your HTML templates for your flowblock in the blocks folder (example: image-paragraph.html)
Directory structure should look like this:
my-lektor-project
assets
content
flowblocks
image-paragraph.ini (your model)
models
templates
blocks
image-paragraph.html (your template for the block)
Currently the admin responds really badly to misconfiguration. Usually it just dies with an error you can see in the console window. Most likely the flow block itself does not exist or has a bug in it. Just open the console window and look at the error message printed. That might give an indication.
See https://www.getlektor.com/docs/models/flow/
To use Flow you need to define flow block models. If you are not familiar with Flow yet, you should read the Introduction Documentation to Flow first
Defining Models
Flow block models work pretty much exactly the same as Regular Models. The differences are mostly minor and of cosmetic nature. They are stored in the flowblocks/ folder and are ini files just like models.
Best explained with an example.
First, create a model containing a field with type set to flow and put it into models/flow_page.ini.
[model]
name = FlowPage
label = {{ this.title }}
[fields.title]
label = Title
type = string
[fields.body]
label = Body
type = flow
Create a new template in templates/flow_page.html. You can just copy page.html if you want.
Then write the following flow block config to flowblocks/colored_text.ini:
[block]
name = Text Block
button_label = Text
[fields.text]
label = Text
type = markdown
[fields.color]
label = Class
type = select
choices = red, blue, green
choice_labels = Red, Blue, Green
default = red
Now you need a template for the flow block. Add it to templates/blocks/colored_text.html.
<span style="color: {{ this.color }}">{{ this.text }}</span>
Finally, create a new subpage, choose FlowPage under model.
Now you can add the block we defined earlier to the body.
I'm trying to log into Google, so that I can scrape & migrate a private google group.
It doesn't seem to log in over SSL. Any ideas appreciated. I'm using Mechanize and the code is below:
group_signin_url = "https://login page to goolge, with referrer url to a private group here"
user = ENV['GOOGLE_USER']
password = ENV['GOOGLE_PASSWORD']
scraper = Mechanize.new
scraper.user_agent = Mechanize::AGENT_ALIASES["Linux Firefox"]
scraper.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
page = scraper.get group_signin_url
google_form = page.form
google_form.Email = user
google_form.Passwd = password
group_page = scraper.submit(google_form, google_form.buttons.first)
pp group_page
I worked with Ian (the OP) on this problem and just felt we should close this thread with some answers based on what we found when we spent some more time on the problem.
1) You can't scrape a Google Group with Mechanize. We managed to get logged in abut the content of the Google Group pages is all rendered in-browser, meaning that HTTP requests, such as issued by Mechanize, are returned with a few links and no actual content.
We found that we could get page content by the use of Selenium (we used Selenium in Firefox, using the Ruby bindings).
2) the HTML element IDs/classes in Google Groups are obfuscated but we found that these Selenium commands will pull out the bits you need (until Google change them)
message snippets (click on them to expand messages)
find_elements(:class, 'GFP-UI5CCLB')
elements with name of author
find_elements(:class, 'GFP-UI5CA1B')
elements with content of post
find_elements(:class, 'GFP-UI5CCKB')
elements containing date
find_elements(:class, 'GFP-UI5CDKB') (and then use the attribute[:title] for a full length date string)
3) I have some Ruby code here which scrapes the content programmatically and uploads it into a Discourse forum (which is what we were trying to migrate to).
It's hacky but it kind of works. I recently migrated 2 commercially important Google Groups using this script. I'm up for taking on 'We Scrape Your Google Group' type work, please PM me.
Best to start by saying that I am very new to Ruby and Liquid. I have searched around looking for some resource on this issue, but as yet haven't been able to find anything of real use.
I have a Jekyll site, which utilises the HTML5 History API. I have a Jekyll generator plugin which creates a single JSON file which holds all the post and page content, ready for use with HTML5 PushState and PopState. This part is functioning properly and is tested.
My problem comes when I have a post/page on the site which has Liquid tags in it. I am guessing I need to parse these Liquid tags to get the template output before I create my JSON object for each post/page. Here is what I have for pages as an example:
# Iterate over all pages
site.pages.each do |page|
# Encode the page HTML content to JSON
link = page.url
#content = Liquid::Template.parse(page.content)
hash[link] = { "body_class" => page.data['body_class'], "content" => converter.convert(#content.render), "title" => '<h1>' + page.data["content_title"] + '</h1>' }
end
Now, this at the minute is basically removing all Liquid tags from the generated JSON file, leaving nothing in it's place.
Here is my full generator file on Github which is based very heavily on nice work by Jezen Thomas.
The output JSON file is also in that repo with the site, or can be accessed quickly here. The blog.html content is the last item in the JSON file and shows the empty h1 and div tags which should have content.