Skip to content

Commit 96dccb6

Browse files
committed
More updates
1 parent c8cce33 commit 96dccb6

File tree

1 file changed

+43
-114
lines changed

1 file changed

+43
-114
lines changed

README.md

Lines changed: 43 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -141,141 +141,72 @@ services.register(middlewares)
141141

142142
**Note:** This must be registered before you register the `SessionsMiddleware`.
143143

144-
## Configuration
145-
146-
147-
148-
149-
## Setup
150-
151-
Next import it in the file where you are setting up your `Droplet` with:
152-
153-
```swift
154-
import SteamPress
155-
```
156-
157-
Finally, add the provider!
158-
159-
```swift
160-
try config.addProvider(SteamPress.Provider.self)
161-
```
162-
163-
This will look for a config file called `steampress.json` that looks like:
164-
165-
```json
166-
{
167-
"postsPerPage": 5,
168-
"blogPath": "blog"
169-
}
170-
```
171-
172-
The `blogPath` line is optional, if you want your blog to be at the root path of your site, just remove that line.
173-
174-
**Note:** you should add the SteamPress Provider before you add the `FluentProvider` to ensure that the password for the admin account is logged out correctly.
175-
176-
### Manual initialisation
177-
178-
You can also initialise the Provider manually, by creating it as so:
144+
SteamPress uses a `PasswordVerifier` protocol to check passwords. Vapor doesn't provide a default BCrypt implementation for this, so you must register this yourself:
179145

180146
```swift
181-
let steampress = SteamPress.Provider(postsPerPage: 5)
182-
config.addProvider(steampress)
147+
config.prefer(BCryptDigest.self, for: PasswordVerifier.self)
183148
```
184149

185-
This will initialise it as the root path of your site. If you wish to have it in a subdirectory, initialise it with:
150+
Finally, if you wish to use the `#markdown()` tag with your blog Leaf templates, you must register this. There's also a paginator tag, to make pagination easy:
186151

187152
```swift
188-
let steampress = SteamPress.Provider(postsPerPage: 5, blogPath: "blog")
189-
config.addProvider(steampress)
153+
var tags = LeafTagConfig.default()
154+
tags.use(Markdown(), as: "markdown")
155+
let paginatorTag = PaginatorTag(paginationLabel: "Blog Posts")
156+
tags.use(paginatorTag, as: PaginatorTag.name)
157+
services.register(tags)
190158
```
191159

192-
### Bootstrap Versions
160+
## Configuration
193161

194-
By default, the paginator used by SteamPress is expecting to use Bootstrap 4. You can configure it to use Bootstrap 3 by either adding it to the configuration file or the manual initialisation. To add to a config file, in your `steampress.json`, add:
162+
There are a number of configuration options you can pass to the provider to configure SteamPress:
195163

196-
```json
197-
{
198-
"postsPerPage": 5,
199-
"blogPath": "blog",
200-
"paginator": {
201-
"useBootstrap4": false
202-
}
203-
}
204-
```
164+
* `blogPath`: the path to add the blog to. By default the blog routes will be registered to the root of your site, but you may want to register the blog at `/blog`. So if you pass in `"blog"` the blog will be available at `https://www.mysite.com/blog`.
165+
* `feedInformation`: Information to vend to the RSS and Atom feeds.
166+
* `postsPerPage`: The number of posts to show per page on the main index page of the blog. Defaults to 10.
167+
* `enableAuthorsPages`: Flag used to determine whether to publicly expose the authors endpoints or not. Defaults to true.
168+
* `enableTagsPages`: Flag used to determine whether to publicy expose the tags endpoints or not. Defaults to true.
205169

206-
To manually iniatialise, set up the Provider like so:
170+
To configure these, you can pass them to the provider. E.g.:
207171

208172
```swift
209-
let steampress = SteamPress.Provider(postsPerPage: 5, blogPath: "blog", useBootstrap4: false)
173+
let feedInformation = FeedInformation(
174+
title: "The SteamPress Blog",
175+
description: "SteamPress is an open-source blogging engine written for Vapor in Swift",
176+
copyright: "Released under the MIT licence",
177+
imageURL: "https://user-images.githubusercontent.com/9938337/29742058-ed41dcc0-8a6f-11e7-9cfc-680501cdfb97.png")
178+
try services.register(SteamPressFluentPostgresProvider(blogPath: "blog", feedInformation: feedInformation, postsPerPage: 5))
210179
```
211180

212-
### Disabling Routes
213-
214-
You can disable the routes for authors pages and tags pages (both individual and all) by adding the option in your configuration file. To disable all of the authors pages, in your `steampress.json` add:
215-
216-
```json
217-
{
218-
"enableAuthorsPages": false
219-
}
220-
```
221-
222-
To disable all of the tags pages, set:
223-
224-
```json
225-
{
226-
"enableTagsPages": false
227-
}
228-
```
229-
230-
Both of these settings can also be configured if manually setting up the Provider:
231-
232-
```swift
233-
let steampress = SteamPress.Provider(postsPerPage:5, enableAuthorsPages: true, enableTagsPages: true)
234-
```
181+
Additionally, you should set the `WEBSITE_URL` environment variable to the root address of your website, e.g. `https://www.steampress.io`. This is used to set various parameters throughout SteamPress.
235182

236183
## Logging In
237184

238-
When you first launch SteamPress a preparation runs that seeds the database with an admin user. The username is `admin` and the password will be printined out to your app's logs. You will be required to reset your password when you first login. It is recommended you do this as soon as your site is up and running.
185+
When you first launch SteamPress, if you've enabled the `BlogAdminUser` migration, an admin user is created in the database. The username is `admin` and the password will be printined out to your app's logs. It is recommended that you reset your password when you first login as soon as your site is up and running.
239186

240187
## Comments
241188

242-
SteamPress currently supports using [Disqus](https://disqus.com) for the comments engine. To use Disqus, just add a config file `disqus.json` to your site that looks like:
243-
244-
```json
245-
{
246-
"disqusName": "NAME_OF_YOUR_DISQUS_SITE"
247-
}
248-
```
249-
250-
(You can get the name of your Disqus site from your Disqus admin panel)
189+
SteamPress currently supports using [Disqus](https://disqus.com) for the comments engine. To use Disqus, start the app with the environment variable `BLOG_DISQUS_NAME` set to the name of your disqus sute. (You can get the name of your Disqus site from your Disqus admin panel)
251190

252-
This will pass it through to the Leaf templates for the Blog index (`blog.leaf`), blog posts (`blogpost.leaf`), author page (`profile.leaf`) and tag page (`tag.leaf`) so you can include it if needs be. If you want to manually set up comments you can do this yourself and just include the necessary files for your provider. This is mainly to provide easy configuration for the [Platform site](https://github.com/brokenhandsio/SteamPressExample).
191+
This will pass it through to the Leaf templates for the Blog index (`blog.leaf`), blog posts (`blogpost.leaf`), author page (`profile.leaf`) and tag page (`tag.leaf`) so you can include it if needs be. If you want to manually set up comments you can do this yourself and just include the necessary files for your provider. This is mainly to provide easy configuration for the [example site](https://github.com/brokenhandsio/SteamPressExample).
253192

254193
## Open Graph Twitter Card Support
255194

256-
SteamPress supports both Open Graph and Twitter Cards. The Blog Post `all` Context (see below) will pass in the created date and last edited date (if applicable) in ISO 8601 format for Open Graph article support, under the parameters `create_date_iso8601` and `last_edited_date_iso8601`.
195+
SteamPress supports both Open Graph and Twitter Cards. The blog post page context will pass in the created date and last edited date (if applicable) in ISO 8601 format for Open Graph article support, under the parameters `createdDateNumeric` and `lastEditedDateNumeric`.
257196

258197
The Blog Post page will also be passed a number of other useful parameters for Open Graph and Twitter Cards. See the `blogpost.leaf` section below.
259198

260-
The Twitter handle of the site can be configured with a `twitter.json` config file (or injected in) with a property `siteHandle` (the site's twitter handle without the `@`). If set, this will be injected into the public pages as described below. This is for the `twitter:site` tag for Twitter Cards
199+
The Twitter handle of the site can be configured with a `BLOG_SITE_TWITTER_HANDLE` environment variable (the site's twitter handle without the `@`). If set, this will be injected into the public pages as described below. This is for the `twitter:site` tag for Twitter Cards
261200

262201
## Google Analytics Support
263202

264-
SteamPress makes it easy to integrate Google Analytics into your blog. If you create a `googleAnalytics.json` config file that looks like:
265-
266-
```json
267-
{
268-
"identifier": "YOUR_IDENTIFIER"
269-
}
270-
```
271-
272-
(You can get your identifier from the Google Analytics console, it will look something like UA-12345678-1)
203+
SteamPress makes it easy to integrate Google Analytics into your blog. Just start the application with the `BLOG_GOOGLE_ANALYTICS_IDENTIFIER` environment variable set to you Google Analytics identifier. (You can get your identifier from the Google Analytics console, it will look something like UA-12345678-1)
273204

274-
This will pass a `google_analytics_identifier` parameter through to all of the public pages which you can include and then use the [Example Site's javascript](https://github.com/brokenhandsio/SteamPressExample/blob/master/Public/static/js/analytics.js) to integrate with.
205+
This will pass a `googleAnalyticsIdentifier` parameter through to all of the public pages in the `pageInformation` variable, which you can include and then use the [Example Site's javascript](https://github.com/brokenhandsio/SteamPressExample/blob/master/Public/static/js/analytics.js) to integrate with.
275206

276207
## Atom/RSS Support
277208

278-
SteamPress automatically provides endpoints for registering RSS readers, either using RSS 2.0 or Atom 1.0. These endpoints can be found at the blog's `atom.xml` and `rss.xml` paths; e.g. if you blog is at `https://www.example.com/blog` then the atom feed will appear at `https://wwww.example.com/blog/atom.xml`. These will work by default, but you will probably want to configure some of fields. These can be added to your `steampress.json` config file, with the following values:
209+
SteamPress automatically provides endpoints for registering RSS readers, either using RSS 2.0 or Atom 1.0. These endpoints can be found at the blog's `atom.xml` and `rss.xml` paths; e.g. if you blog is at `https://www.example.com/blog` then the atom feed will appear at `https://wwww.example.com/blog/atom.xml`. These will work by default, but you will probably want to configure some of fields. These are configured with the `FeedInformation` parameter passed to the provider. The configuration options are:
279210

280211
* `title` - the title of the blog - a default "SteamPress Blog" will be provided otherwise
281212
* `description` - the description of the blog (or subtitle in atom) - a default "SteamPress is an open-source blogging engine written for Vapor in Swift" will be provided otherwise
@@ -286,12 +217,19 @@ SteamPress automatically provides endpoints for registering RSS readers, either
286217

287218
SteamPress has a built in blog search. It will register a route, `/search`, under your blog path which you can send a query through to, with a key of `term` to search the blog.
288219

289-
290220
# Expected Leaf Templates
291221

292222
SteamPress expects there to be a number of Leaf template files in the correct location in `Resources/Views`. All these files should be in a `blog` directory, with the admin template files being in an `admin` directory. For an example of how it SteamPress works with the leaf templates, see the [Example SteamPress site](https://github.com/brokenhandsio/SteamPressExample).
293223

294-
For every Leaf template, a `user` parameter will be passed in for the currently logged in user, if there is a user currently logged in. This is useful for displaying a 'Create Post' link throughout the site when logged in etc.
224+
For every public Leaf template, a `pageInformation` parameter will be passed in with the following information:
225+
226+
* `disqusName`: The site Disqus name, as discussed above
227+
* `siteTwitterHandle`: The site twitter handle, as discussed above
228+
* `googleAnalyticsIdentifier`: The Google Analytics identifer as discussed above
229+
* `loggedInUser`: The currently logged in user, if a user is logged in. This is useful for displaying a 'Create Post' link throughout the site when logged in etc.
230+
* `websiteURL`: The URL for the website
231+
* `currentPageURL`: The URL of the current page
232+
* `currentPageEncodedURL`: An URL encoded representation of the current page
295233

296234
The basic structure of your `Resources/View` directory should be:
297235

@@ -503,27 +441,18 @@ let shortSnippet = post.shortSnippet()
503441
let longSnippet = post.longSnippet()
504442
```
505443

506-
# Markdown Provider
444+
# Markdown Tag
507445

508-
The Markdown Provider allows you to render markdown as HTML in your Leaf files. To use, just simply use:
446+
The Markdown Tag allows you to render markdown as HTML in your Leaf files. To use, just simply use:
509447

510448
```
511449
#markdown(myObject.markdownContent)
512450
```
513451

514-
This will convert the `Node` object `myObject`'s `markdownContent` to HTML (you pass in `myObject` as a parameter to your Leaf view). It uses CommonMark under the hood, but for more details, see the [Markdown Provider repo](https://github.com/vapor-community/markdown-provider).
452+
This will convert the object `myObject`'s `markdownContent` to HTML (you pass in `myObject` as a parameter to your Leaf view). It uses Github Flavoured Markdown under the hood, but for more details, see the [Leaf Markdown repo](https://github.com/vapor-community/leaf-markdown).
515453

516454
# API
517455

518456
SteamPress also contains an API for accessing certain things that may be useful. The current endpoints are:
519457

520458
* `/<blog-path>/api/tags/` - returns all the tags that have been saved in JSON
521-
522-
# Roadmap
523-
524-
I anticipate SteamPress staying on a version 0 for some time, whilst some of the biggest features are implemented. Semantic versioning makes life a little difficult for this as any new endpoints will require a breaking change for you to add Leaf templates! However, I will aim to stabilise this as quickly as possible, and any breaking changes will be announced in the [releases](https://github.com/brokenhandsio/SteamPress/releases) page.
525-
526-
On the roadmap we have:
527-
528-
* AMP/Facebook instant articles endpoints for posts
529-
* Saving state when logging in - if you go to a page (e.g. edit post) but need to be logged in, it would be great if you could head back to that page once logged in. Also, if you have edited a post and your session expires before you post it, wouldn't it be great if it remembered everything!

0 commit comments

Comments
 (0)