UNPKG

7.12 kBMarkdownView Raw
1# apostrophe-blog-2: a better blog for Apostrophe
2
3This 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.
4
5Each 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.
6
7A 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).
8
9There is also a widget available for displaying blog posts anywhere on the site.
10
11## Configuration Options
12
13Blog 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.
14
15## Subclassing
16
17For 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:
18
19```JavaScript
20'handbook': {
21 extend: 'apostrophe-blog-2',
22 name: 'handbooks',
23 pieceName: 'policy',
24 pieceLabel: 'Policy',
25 indexName: 'handbook',
26 indexLabel: 'Handbook',
27 pieces: {
28 pluralLabel: 'Policies',
29 }
30 }
31```
32
33## Do you like dates in slugs?
34
35By default, the date is part of the slug of each post:
36
37```
38/my/blog/2014/11/12/wednesday-update
39```
40
41If this doesn't suit your needs, just set the `dateInSlug` option to `false`.
42
43If you are reading this late and already have content with dates, you can remove them:
44
45```
46node app apostrophe:remove-dates-from-blog-posts
47```
48
49(Note: if you are subclassing, the name of the task depends on your `pieceName` setting. Type `node app apostrophe:help` to list available tasks.)
50
51If you change your mind and want to add dates back, just run:
52
53```
54node app apostrophe:add-dates-to-blog-posts
55```
56
57Either way, be sure to set the `dateInSlug` option correctly in your module configuration to ensure future posts behave as you expect.
58
59## Limiting Choices in the Widget
60
61Sometimes 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.
62
63You can do that with the `sources` option when inserting the widget:
64
65```markup
66{{ aposSingleton(page, 'articles', 'blog', { sources: [ 'title' ] }) }}
67```
68
69The `sources` option may contain `title`, `tag` and/or `page` in any order. The first option given becomes the default choice.
70
71If you limit the editor to only one source, the dropdown menu is automatically hidden.
72
73## Wordpress Import
74
75You can import content from Wordpress blogs into `apostrophe-blog-2`:
76
77```
78node app apostrophe:import-wordpress-stories wordpress-export-file.xml /my-blog
79```
80
81The 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.
82
83You can generate a Wordpress export file easily:
84
851. Log into your wordpress site as an admin.
862. Click "tools."
873. Click "export."
884. Select "posts" or "all." NOTE: only blog posts and associated images and video will be imported. Pages are NOT imported.
895. Save the resulting export file.
90
91### Preserving author credit
92
93The 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.
94
95### Additional options
96
97### Specifying the base URL for relative links
98
99Usually 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.
100
101However 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:
102
103`--base=http://magazine.example.com`
104
105#### Ignoring tags
106
107By default Wordpress tags are imported as A2 tags. To prevent this, use the `--ignore-tags` option.
108
109#### Ignoring categories
110
111Wordpress categories are also imported as A2 tags. You can prevent this with the `--ignore-categories` option.
112
113#### Importing only posts with a specific tag
114
115Just use:
116
117`--with-tag="Zamfir Pipes"`
118
119Yes, you may use this option and `--ignore-tags` at the same time.
120
121#### Importing only posts with a specific category
122
123I bet you can guess:
124
125`--with-category="French Press"`
126
127Yes, it is safe to combine this with `--ignore-categories`.
128
129#### Importing only posts that do not have certain tags
130
131`--without-tags="tag1,tag2,tag3"`
132
133Useful if you need to export a "misc" blog with all the content you didn't export to other blogs via `--with-tag`.
134
135This option does not currently work with tags that contain
136commas in their names.
137
138#### Importing only posts that do not have certain categories
139
140Useful if you need to export a "misc" blog with all the content you didn't export to other blogs via `--with-category`.
141
142`--without-categories="cat1,cat2,cat3"
143
144This option does not currently work with categories that contain
145commas in their names.
146
147#### Changing the body area name
148
149By 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.
150
151#### Mapping [caption] shortcodes to descriptions
152
153By default, a [caption] shortcode becomes the title of the file, and the "showTitles" flag is set on the slideshow.
154
155If you prefer it be treated as a description, pass the `--caption-as-description` option.
156
157#### Newline-to-line-break conversion
158
159By 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.
160
161By default, during the import, we convert these to a simple pair of `br` tags.
162
163If your particular Wordpress blog has this feature disabled, specify `--no-autop` during import to prevent this conversion, which is redundant for you.
164
165#### Converting creator names
166
167The `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:
168
169`--creator-to-credit=filename.csv`
170
171#### Doing it faster
172
173To 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.