Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
apostrophe-blog-2
Advanced tools
A next-generation blog for A2. Blogs and blog posts are ordinary pages with a few fancy features, so that blog posts have a natural and obvious permanent URL on the site but aggreation and blog-style browsing are still possible.
This module is for the 0.5.x version of Apostrophe. The apostrophe-blog module has been updated for Apostrophe 2.x.
Some of the use cases of this module are not yet available as a pre-packaged module for 2.x, however you can recreate them using apostrophe-custom-pages
, a built-in module of 2.x.
This new implementation is based on the idea that blog posts have more in common with pages than with snippets. It simplifies permissions and makes the whole experience more contextual.
Each blog post is a child of its parent blog. This allows permissions to work just like page permissions in Apostrophe. However, the pagination of posts works as you would expect it to in a post, and the posts don't clutter up the "reorganize" modal.
A blog can still choose to display content from other blogs on the site. This is easy to do via the page settings of the blog (see the "and these blogs" field).
There is also a widget available for displaying blog posts anywhere on the site.
Blog posts cannot have subpages. And, by default, index pages can't have subpages other than blog posts. But you can enable the latter by setting the allowSubpagesOfIndex
option to true
when configuring the module. It's not forbidden, it's just confusing for users who don't need it.
For now, subclassing of blog-2 is fairly simple, though it requires some configuration in your app.js file. Here's a sample of what you'll need to successfully subclass and create your own distinct instance of a blog-like thing:
'handbook': {
extend: 'apostrophe-blog-2',
name: 'handbooks',
pieceName: 'policy',
pieceLabel: 'Policy',
indexName: 'handbook',
indexLabel: 'Handbook',
pieces: {
pluralLabel: 'Policies',
}
}
By default, the date is part of the slug of each post:
/my/blog/2014/11/12/wednesday-update
If this doesn't suit your needs, just set the dateInSlug
option to false
.
If you are reading this late and already have content with dates, you can remove them:
node app apostrophe:remove-dates-from-blog-posts
(Note: if you are subclassing, the name of the task depends on your pieceName
setting. Type node app apostrophe:help
to list available tasks.)
If you change your mind and want to add dates back, just run:
node app apostrophe:add-dates-to-blog-posts
Either way, be sure to set the dateInSlug
option correctly in your module configuration to ensure future posts behave as you expect.
Sometimes you won't want the editor to have their pick of title, tag and particular blogs as sources for a particular widget. For instance, you might want to restrict to title only for simplicity.
You can do that with the sources
option when inserting the widget:
{{ aposSingleton(page, 'articles', 'blog', { sources: [ 'title' ] }) }}
The sources
option may contain title
, tag
and/or page
in any order. The first option given becomes the default choice.
If you limit the editor to only one source, the dropdown menu is automatically hidden.
You can import content from Wordpress blogs into apostrophe-blog-2
:
node app apostrophe:import-wordpress-stories wordpress-export-file.xml /my-blog
The first argument must be a Wordpress XML export file. The second argument must be the slug of an existing blog page on your A2 site.
You can generate a Wordpress export file easily:
The Wordpress import task will migrate in the author's name for each blog post via the dc:creator
setting found in the XML export file. This field is assigned to the credit
property of each post in A2. You can add that field to your pieces
schema as a string field to make it editable on your A2 site.
Usually the wp:base_blog_url
found in the XML export file is good enough to resolve relative URLs to image files if any are encountered in the XML.
However some sites are too tricky with redirects and subdomains for their own good, and you'll need to tell the import task what the real URL of the original Wordpress site is:
--base=http://magazine.example.com
By default Wordpress tags are imported as A2 tags. To prevent this, use the --ignore-tags
option.
Wordpress categories are also imported as A2 tags. You can prevent this with the --ignore-categories
option.
Just use:
--with-tag="Zamfir Pipes"
Yes, you may use this option and --ignore-tags
at the same time.
I bet you can guess:
--with-category="French Press"
Yes, it is safe to combine this with --ignore-categories
.
--without-tags="tag1,tag2,tag3"
Useful if you need to export a "misc" blog with all the content you didn't export to other blogs via --with-tag
.
This option does not currently work with tags that contain commas in their names.
Useful if you need to export a "misc" blog with all the content you didn't export to other blogs via --with-category
.
`--without-categories="cat1,cat2,cat3"
This option does not currently work with categories that contain commas in their names.
By default, the importer assumes the main content area of your blog posts is named body
. This might not be the case in your templates. If not, specify --body-area=content1
, or whatever your area name is.
By default, a [caption] shortcode becomes the title of the file, and the "showTitles" flag is set on the slideshow.
If you prefer it be treated as a description, pass the --caption-as-description
option.
By default, Wordpress blogs convert double newlines to paragraph breaks. They do it on the fly, all the time, with a hideously complex function. Yes, it's pretty terrible.
By default, during the import, we convert these to a simple pair of br
tags.
If your particular Wordpress blog has this feature disabled, specify --no-autop
during import to prevent this conversion, which is redundant for you.
The dc:creator
setting from Wordpress is normally imported directly into the credit
field in A2. If you wish, you can specify a CSV file in which the first column is the dc:creator
value (the Wordpress username) and the second column is the credit
property to store in A2. Just use:
--creator-to-credit=filename.csv
To import the blog faster, processing four blog posts at once, specify --parallel=4
. Be aware this can require much more memory when importing images. It may also impose an unacceptable load on the Wordpress site at some point. 4
is a good limit, and only on a laptop or a VPS with plenty of memory.
FAQs
A next-generation blog for A2. Blogs and blog posts are ordinary pages with a few fancy features, so that blog posts have a natural and obvious permanent URL on the site but aggreation and blog-style browsing are still possible.
The npm package apostrophe-blog-2 receives a total of 32 weekly downloads. As such, apostrophe-blog-2 popularity was classified as not popular.
We found that apostrophe-blog-2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.