Skip to content

Commit

Permalink
Update README for Vapor 4
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTim committed Apr 14, 2020
1 parent f7aed38 commit 4ca3b12
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ There is an example of how it can work in a site (and what it requires in terms

## Add as a dependency

**TODO** Update

SteamPress is easy to integrate with your application. There are two providers that provide implementations for [PostgreSQL](https://github.com/brokenhandsio/steampress-fluent-postgres) or [MySQL](https://github.com/brokenhandsio/steampress-fluent-mysql). You are also free to write your own integrations. Normally you'd choose one of the implementations as that provides repository integrations for the database. In this example, we're using Postgres.

First, add the provider to your `Package.swift` dependencies:
Expand Down Expand Up @@ -115,42 +117,29 @@ And then as a dependency to your target:
This will register the routes for you. You must provide implementations for the different repository types to your services:

```swift
services.register(MyTagRepository(), as: BlogTagRepository.self)
services.register(MyUserRepository(), as: BlogUserRepository.self)
services.register(MyPostRepository(), as: BlogPostRepository.self)
app.steampress.blogRepositories.use { application in
MyRepository(application: application)
}
```

You can then register the SteamPress provider with your services:

```swift
let steampressProvider = SteamPress.Provider()
try services.register(steampressProvider)
```
SteamPress will be automatically registered, depending on the configuration provided (see below).

## Integration

SteamPress offers a 'Remember Me' functionality when logging in to extend the duration of the session. In order for this to work, you must register the middleware:

```swift
var middlewares = MiddlewareConfig()
// ...
middlewares.use(BlogRememberMeMiddleware.self)
middlewares.use(SessionsMiddleware.self)
services.register(middlewares)
application.middlewares.use(BlogRememberMeMiddleware())
```

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

SteamPress uses a `PasswordVerifier` protocol to check passwords. Vapor doesn't provide a default BCrypt implementation for this, so you must register this yourself:

```swift
config.prefer(BCryptDigest.self, for: PasswordVerifier.self)
```
**TODO: Update**

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:

```swift
var tags = LeafTagConfig.default()
var tags = LeafTagConfig.default()
tags.use(Markdown(), as: "markdown")
let paginatorTag = PaginatorTag(paginationLabel: "Blog Posts")
tags.use(paginatorTag, as: PaginatorTag.name)
Expand All @@ -175,7 +164,7 @@ let feedInformation = FeedInformation(
description: "SteamPress is an open-source blogging engine written for Vapor in Swift",
copyright: "Released under the MIT licence",
imageURL: "https://user-images.githubusercontent.com/9938337/29742058-ed41dcc0-8a6f-11e7-9cfc-680501cdfb97.png")
try services.register(SteamPressFluentPostgresProvider(blogPath: "blog", feedInformation: feedInformation, postsPerPage: 5))
application.steampress.configuration = SteamPressConfiguration(blogPath: "blog", feedInformation: feedInformation, postsPerPage: 5)
```

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.
Expand Down

0 comments on commit 4ca3b12

Please sign in to comment.