In Hugo documentation, what is meant by `⊢--^-⊣` and similar? - hugo

In the Hugo documentation, I sometimes see code blocks that look like this:
Organization docs
You can keep one _index.md for your homepage and one in each of your
content sections, taxonomies, and taxonomy terms. The following shows
typical placement of an _index.md that would contain content and front
matter for a posts section list page on a Hugo website:
. url
. ⊢--^-⊣
. path slug
. ⊢--^-⊣⊢---^---⊣
. filepath
. ⊢------^------⊣
content/posts/_index.md
What is being said, here? Is "the following" referring to a directory structure? Is that what a file (which file?) would actually look like? Is the url and path etc words some sort of variables, that are being "pointed to" by the |---^--|? Or is the dash caret syntax actual code, and ⊢--^-⊣ means "URL" in human-readable terms?
What does the -, |, ^, || syntax mean in the Hugo docs?

They are using the dash caret syntax as a attempt to explain(not clearly) the directory structure.
url = /posts/
slug = _index.md
filepath = /posts/_index.md
The -, |, ^, || are strictly used to illustrate the url structure and nothing more

Related

How to use the same layout in a different directory?

I have a site using the hugo-coder theme, which has a layouts/posts folder that specifies that anything in the "posts" folder will have a blog post format.
I would like to have two different blogs in two different subdirectories, using the same layout. Is there a way to tell Hugo that the content/blog1 directory should use the same settings and layout as the content/posts directory without copying themes/hugo-coder/layouts/posts into layouts/blog1? Ideally I would avoid using symlinks, because, while convenient, I've had a decent amount of software throw weird errors when I use symlinks, so I avoid them when it's possible.
You can set the layout or type field to posts in the frontmatter of your _index.md file in content/blog1.
See this docs page for more info.
Edit: Alternatively, you could create an archetype for blog1 that automatically sets the value to posts in the frontmatter of individual posts in that section, assuming you're using hugo new blog1/postname.md to create posts for that section.
Double edit: The first suggestion didn't work. You could also create subsections within content/posts/blog1 and set the permalinks of posts in that subsection to use the last section only. That should remove the need to explicitly set the type in post frontmatter every time because each post would already have a type of posts.
In config.toml:
[permalinks]
posts = "/:sections[last]/:slug/"
You can use a partial in your templates. If you do that you WILL need the single and list file in the layouts/blog directory, but it could be an empty file referencing the partial. The layouts/posts/single.html and the layouts/blog/single.html both will then look like this:
{{ partial "singleblog.html" . }}
Compeletely DRY... and without much complexity.

How can I insert an emoji on config.toml in Hugo rendered website?

I want to add a cloud emoji on my webpage's footer, but apparently the config.toml file doesn't support emojis
[params]
footerText = ":cloud: David Jorquera - 2020"
...is rendered as text.
How can this be done?
Why that doesn't work?
Hugo uses the emojify function to parse templates for emojis substitution. But it doesn't apply such functions to the configuration.
To do so, you would have needed to pass your variable to the function in the template using {{ .footerText | emojify }} as documented in this other question.
Use directly UTF-8 characters in configuration
Your TOML configuration file can be considered as an UTF-8 document.
As such, you can directly add the emoji in the config value:
[params]
footerText = "☁️ David Jorquera – 2020"
This sample uses an emoji and a dash between your name and the year.

AngularJS ng-pattern website pattern

/^[_a-z0-9]+(\.[_a-z0-9]+)*[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,7})$/
That's the pattern. It says "ok" when it's correct, and "not ok" when it's incorrect. So it says "ok" on www.google.com, but "not ok" when I type http://www.google.com
What I'd like is this pattern to allow http:// too, but it should never be a requirement.
You can use the following regular expression, which I lifted off borrowed from the documentation of the Perl module URI on CPAN (escaping of slashes mine).
/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/
It will give you all the different parts of the URI in capture groups.
Those parts are:
scheme (http:)
authority (not applicable here)
path (www.google.com)
query (q=querystring)
fragment (#anker)
See https://regex101.com/r/vS5qO1/1 to try it out.
Also note that this will parse all types of URIs, not only http(s). So stuff like ftp://anonymous#example.org will also work.
If you're looking to only allow http/https URL schemes (when the scheme is provided), the following modification to your regular expression will do the trick:
/^(http:\/\/|https:\/\/)?[_a-z0-9]+(\.[_a-z0-9]+)*[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,7})$/
You can use my answer as an example of how to add the url scheme group to your existing regex, but credit #simbabque, as he has a much more complete answer.

Angular ui-router - Curly brackets etc in url

I have been searching for a way to have curly brackets{} and slashes / in the URL. But the URL looks like this:
URL appearance now:
http://localhost/#/?ph=tes:testes%2Ftest%7Blb0%7D
URL wanted appearance:
http://localhost/#/?ph=tes:tests/test{lb0}
How do I get an URL without the %2f etc?
Thanks in advance!
All valid characters that can be used in a URI (a URL is a type of URI) are defined in RFC 3986.
All other characters can be used in a URL provided that they are "URL Encoded" first. This involves changing the invalid character for specific "codes" (usually in the form of the percent symbol (%) followed by a hexadecimal number).
This link, HTML URL Encoding Reference, contains a list of the encodings for invalid characters.
Happy Helping!
These (%2F, %7B) are escape sequences. They represent the special characters that are in your URL, as a URL cannot contain these character directly.
Where do you want exactly to process this URL?
You can use Javascript's unescape(url) to get the escaped URL string back to the original one if you're going to process it in Javascript itself.

Jackrabbit XPath Issue

I'm relatively new to Jackrabbit. In our application we never turned on SearchIndex section within repository.xml (so as workspace.xml) files because we always go directly to a given document using the JCR UUID reference. We are using Jackrabbit v2.2.1 and Oracle as the repository. Now our requirements are getting expanded as we would like to use the document metadata feature to store contextual info about a document so that we can use the metadata to retrieve a selected set of documents.
As the first step, I added the default SearchIndex section in workspace.xml file and restarted the JCR.
I saw a bunch of lines like this in my log file - then I saw it created the index folder under workspace area.
2011-07-05 15:04:01.724 INFO [WebContainer : 0] MultiIndex.java:1204 indexing... /vfs:metaData/21ee130e-978e-415f-bfd1-7aa03d91608c/vfs:attributes (3500)
I have the folder structure like this. When I create a document in JCR, I specify the metadata info as part of the document which is by a complex XSD type with tags like docType, uploadedBy, contextValue, etc.
/ (root)
/MyApp (sub-folder)
/documents/ (sub-folder)
/document-1.pdf (file)
/document-2.pdf (file)
/accounts/ (sub-folder)
/account.txt (file)
etc...
The following XPath expression works.
//jcr:root/vfs:metaData//*[vfs:attributes/vfs:docType='TAX_DOCS']
If I give wrong value, for example instead of 'TAX_DOCS', 'TAX', it returns no documents as expected which is great. This proves that the metadata is correctly stored as expected and it is used in the filter process correctly.
The problem with this query is that it starts searching from the root folder but I want to search from /MyApp/documents sub-folder only. So I tried this:
//jcr:root/MyApp/documents//vfs:metaData//*[vfs:attributes/vfs:docType='TAX_DOCS']
It returns nothing. Then I tried this too but no success.
//jcr:root/MyApp/documents//*[vfs:metaData/vfs:attributes/vfs:docType='TAX_DOCS']
So what am I doing wrong? Is anything in workspace.xml configuration that we need to set or missing?
Any help is appreciated.
Thanks, Jack
Drop the double slashed from anything but the last path component and use the # notation for the attribute value, resulting in:
/jcr:root/MyApp/documents//*[vfs:attributes/#vfs:docType='TAX_DOCS']
The // construct looks for the whole subtree instead of just the immediate children like / does. The JCR specification only requires implementations to support the // construct as the last step of the XPath query.

Resources