You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -231,6 +231,12 @@ For every public Leaf template, a `pageInformation` parameter will be passed in
231
231
*`currentPageURL`: The URL of the current page
232
232
*`currentPageEncodedURL`: An URL encoded representation of the current page
233
233
234
+
For admin pages, the `pageInformation` parameter has the following information:
235
+
236
+
*`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.
237
+
*`websiteURL`: The URL for the website
238
+
*`currentPageURL`: The URL of the current page
239
+
234
240
The basic structure of your `Resources/View` directory should be:
235
241
236
242
*`blog`
@@ -254,83 +260,87 @@ The basic structure of your `Resources/View` directory should be:
254
260
255
261
This is the index page of the blog. The parameters it will receive are:
256
262
257
-
*`posts` - a Node containing data about the posts and metadata for the paginator. You can access the posts by calling the `.data` object on it, which is an array of blog posts if there are any, in date descending order. The posts will be made with a `longSnippet` context (see below)
258
-
*`tags` - an array of tags if there are any
263
+
*`posts` - an array containing `ViewBlogPost`s. This contains all the post information and extra stuff that's useful, such as other date formats and snippets.
264
+
*`tags` - an array of `ViewBlogTag`s if there are any
259
265
*`authors` - an array of the authors if there are any
260
-
*`disqus_name` - the name of your Disqus site if configured
261
-
*`blog_index_page` - a boolean saying we are on the index page of the blog - useful for navbars
262
-
*`site_twitter_handle` - the Twitter handle for the site if configured
263
-
*`uri` - the URI of the page - useful for Open Graph
264
-
*`google_analytics_identifier` - your Google Analytics identifier if configured
265
-
266
+
*`pageInformation` - general page information (see above)
267
+
*`title` - the title for the page
268
+
*`blogIndexPage` - a boolean saying we are on the index page of the blog - useful for navbars
269
+
*`paginationTagInformation` - information for enabling pagination on the page. See `PaginationTagInformation` for more details.
266
270
267
271
### `blogpost.leaf`
268
272
269
273
This is the page for viewing a single entire blog post. The parameters set are:
270
274
271
-
*`post` - the full current post, with the `all` context
275
+
*`title` - the title of the blog post
276
+
*`post` - the blog post as a `ViewBlogPost`
272
277
*`author` - the author of the post
273
-
*`blog_post_page` - a boolean saying we are on the blog post page
274
-
*`disqus_name` - the name of your Disqus site if configured
275
-
*`post_uri` - The URI of the post
276
-
*`post_uri_encoded` - A URL-query encoded for of the URI for passing to Share buttons
277
-
*`site_uri`: The URI of the root site - this is useful for creating links to author pages for `article:author` Open Graph support (has a trailing slash)
278
-
*`post_description` - The HTML of the short snippet of the post on a single line with all HTML tags stripped out for the `description` tags
279
-
*`post_image` - The first image in the blog post if one is there. Useful for OpenGraph and Twitter Cards
280
-
*`post_image_alt` - The alt text of the first image if it exists. Useful for Twitter Cards
281
-
*`site_twitter_handle` - the Twitter handle for the site if configured
282
-
*`google_analytics_identifier` - your Google Analytics identifier if configured
278
+
*`blogPostPage` - a boolean saying we are on the blog post page
279
+
*`pageInformation` - general page information (see above)
280
+
*`postImage` - The first image in the blog post if one is there. Useful for OpenGraph and Twitter Cards
281
+
*`postImageAlt` - The alt text of the first image if it exists. Useful for Twitter Cards
282
+
*`shortSnippet`: The HTML of the short snippet of the post on a single line with all HTML tags stripped out for the `description` tags
283
283
284
284
### `tag.leaf`
285
285
286
286
This is the page for a tag. A blog post can be tagged with many tags and a tag can be tagged on many blog posts. This page is generally used for viewing all posts under that tag. The parameters are:
287
287
288
288
*`tag` - the tag
289
-
*`posts` - a Node containing data about the posts and metadata for the paginator. You can access the posts by calling the `.data` object on it, which is an array of blog posts if there are any, in date descending order. The posts will be made with a `longSnippet` context (see below)
290
-
*`tag_page` - a boolean saying we are on the tag page
291
-
*`disqus_name` - the name of your Disqus site if configured
292
-
*`site_twitter_handle` - the Twitter handle for the site if configured
293
-
*`uri` - the URI of the page - useful for Open Graph
294
-
*`google_analytics_identifier` - your Google Analytics identifier if configured
289
+
*`posts` - an array of `ViewBlogPost`s that have been tagged with this tag. Note that this may not be all the posts due to pagination
290
+
*`tagPage` - a boolean saying we are on the tag page
291
+
*`postCount` - the number of posts in total that have this tag
292
+
*`pageInformation` - general page information (see above)
293
+
*`paginationTagInformation` - information for enabling pagination on the page. See `PaginationTagInformation` for more details.
295
294
296
295
### `profile.leaf`
297
296
298
297
This is the page for viewing a profile of a user. This is generally used for viewing all posts written by a user, as well as some information about them. The parameters it can have set are:
299
298
300
299
*`author` - the user the page is for
301
-
*`profile_page` - a boolean set to to true if we are viewing the profile page
302
-
*`posts` - all the posts the user has written if they have written any in `shortSnippet` form
303
-
*`disqus_name` - the name of your Disqus site if configured
304
-
*`site_twitter_handle` - the Twitter handle for the site if configured
305
-
*`uri` - the URI of the page - useful for Open Graph
306
-
*`google_analytics_identifier` - your Google Analytics identifier if configured
300
+
*`posts` - an array of `ViewBlogPost`s that have been written by this user. Note that this may not be .all the posts due to pagination
301
+
*`profilePage` - a boolean set to to true if we are viewing the profile page
302
+
*`myProfile` - a boolean set if the currently logged in user is viewing their own profile page
303
+
*`postCount` - the number of posts in total that have this tag
304
+
*`pageInformation` - general page information (see above)
305
+
*`paginationTagInformation` - information for enabling pagination on the page. See `PaginationTagInformation` for more details.
307
306
308
307
### `tags.leaf`
309
308
310
309
This is the page for viewing all of the tags on the blog. This provides some more navigation points for the blog as well as providing a page in case the user strips off the tag from the Tag's URL. The parameters that can be passed to it are:
311
310
312
-
*`tags` - an array of all the tags on the blog, in `withPostCount` context (see below) sorted by post count
313
-
*`site_twitter_handle` - the Twitter handle for the site if configured
314
-
*`uri` - the URI of the page - useful for Open Graph
315
-
*`google_analytics_identifier` - your Google Analytics identifier if configured
311
+
*`title` - a title for the page
312
+
*`tags` - an array of `BlogTagWithPostCount`s. This is the tags with the number of posts tagged with that tag
313
+
*`pageInformation` - general page information (see above)
316
314
317
315
### `authors.leaf`
318
316
319
317
This is the page for viewing all of the authors on the blog. It provides a useful page for user's to see everyone who has contributed to the site.
320
318
321
-
*`authors` - an array of all the `BlogUser`s on the blog, in `withPostCount` context (see below) sorted by post count
322
-
*`site_twitter_handle` - the Twitter handle for the site if configured
323
-
*`uri` - the URI of the page - useful for Open Graph
324
-
*`google_analytics_identifier` - your Google Analytics identifier if configured
319
+
*`authors` - an array of all the `ViewBlogAuthor`s on the blog
320
+
*`pageInformation` - general page information (see above)
325
321
326
322
### `search.leaf`
327
323
328
324
This is the page that will display search results. It has a number of parameters on it on top of the standard parameters:
329
325
330
-
*`emptySearch` - returned if no search term of an empty search term was received
326
+
*`title` - a title for the page
331
327
*`searchTerm` - the search term if provided
332
-
*`searchCount` - the number of results returned from the search
333
-
*`posts` - the posts found from the search, paginated, in `longSnippet` form
328
+
*`totalResults` - the number of results returned from the search
329
+
*`posts` - an array of `ViewBlogPost`s returned in the search. Note that this may not be all the posts due to pagination.
330
+
*`pageInformation` - general page information (see above)
331
+
*`paginationTagInformation` - information for enabling pagination on the page. See `PaginationTagInformation` for more details.
332
+
333
+
### `login.leaf`
334
+
335
+
This is the page for logging in to the admin section of the blog. The parameters are:
336
+
*`title` - a title for the page
337
+
*`errors` - an array of error messages if there were any errors logging in
338
+
*`loginWarning` - a flag set if the user tried to access a protected page and was redirected to the login page
339
+
*`username` - the username supplied (if any) when originally submitting the login for and there (useful for pre-populating the form)
340
+
*`usernameError` - a boolean set if there was an issue with the username
341
+
*`passwordError` - a boolean set if there was an error with the password (note that we do not pass any password submitted back to any pages if there was an error for security reasons)
342
+
*`rememberMe` - set if the remember me checkbox was checked and there was an error, useful for pre-populating
343
+
*`pageInformation` - general page information (see above)
334
344
335
345
## Admin Site
336
346
@@ -339,109 +349,69 @@ This is the page that will display search results. It has a number of parameters
339
349
This is the main Admin page for the blog where you can create and edit users and posts. The parameters for this page are:
340
350
341
351
*`users` - all the users for the site
342
-
*`published_posts` - all the posts that have been published if there are any, with the `all` Context
343
-
*`draft_posts` - all the draft posts that have been saved but not published, if there are any, with the `all` Context
352
+
*`publishedPosts` - all the posts that have been published if there are any, , as `ViewBlogPostWithoutTags`
353
+
*`draftPosts` - all the draft posts that have been saved but not published, if there are any, as `ViewBlogPostWithoutTags`
344
354
*`errors` - any error messages for errors that have occurred when trying to delete posts or users (for instance trying to delete yourself or the last user)
345
-
*`blog_admin_page` - a boolean set to true, useful for navigation
346
-
347
-
### `login.leaf`
348
-
349
-
This is the page for logging in to the admin section of the blog. The parameters are:
350
-
351
-
*`username_error` - a boolean set if there was an issue with the username
352
-
*`password_error` - a boolean set if there was an error with the password (note that we do not pass any password submitted back to any pages if there was an error for security reasons)
353
-
*`username_supplied` - the username supplied (if any) when originally submitting the login for and there (useful for pre-populating the form)
354
-
*`errors` - an array of error messages if there were any errors logging in
355
+
*`blogAdminPage` - a boolean set to true, useful for navigation
356
+
*`title` - the title for the page
357
+
*`pageInformation` - general page information as `BlogAdminPageInformation` - see above
355
358
356
359
### `resetPassword.leaf`
357
360
358
361
This is the page you will be redirected to if you need to reset your password. The parameters are:
359
362
360
363
*`errors` - an array of errors if there were any errors resetting your password
361
-
*`password_error` - a boolean set if there was an error with the password (for instance it was blank)
362
-
*`confirm_password_error` - a boolean set if there was an error with the password confirm (for instance it was blank)
364
+
*`passwordError` - a boolean set if there was an error with the password (for instance it was blank)
365
+
*`confirmPasswordError` - a boolean set if there was an error with the password confirm (for instance it was blank)
366
+
*`pageInformation` - general page information as `BlogAdminPageInformation` - see above
363
367
364
368
### `createPost.leaf`
365
369
366
370
This is the page for creating a new blog post, or editing an existing one. The parameters for this page are:
367
371
368
-
*`title_error` - a boolean set to true if there was an error with the title
369
-
*`contents_error` - a boolean set to true if there was an error with the blog contents
370
-
*`errors` - an array of error messages if there were any errors creating or editing the blog post
371
-
*`title_supplied` - the title of the blog post to edit, or the post that failed to be created
372
-
*`contents_supplied` - the contents of the blog post to edit, or the post that failed to be created
373
-
*`tags_supplied` - an array of all of the tags that have been specified for the blog post
372
+
*`title` - the title for the page
374
373
*`editing` - a boolean set to true if we are currently editing the a blog post rather than creating a new one
375
374
*`post` - the post object we are currently editing
376
-
*`create_blog_post_page` - a boolean set to true, useful for the navbar etc
377
-
378
-
### `createLogin.leaf`
375
+
*`draft` - a flag that's set when the post has been saved as a draft
376
+
*`errors` - an array of error messages if there were any errors creating or editing the blog post
377
+
*`titleSupplied` - the title of the blog post to edit, or the post that failed to be created
378
+
*`contentsSupplied` - the contents of the blog post to edit, or the post that failed to be created
379
+
*`tagsSupplied` - an array of all of the tags that have been specified for the blog post
380
+
*`slugURLSupplied` - the slug URL of the blog post to edit, or the post that failed to be created
381
+
*`titleError` - a boolean set to true if there was an error with the title
382
+
*`contentsError` - a boolean set to true if there was an error with the blog contents
383
+
let postPathPrefix: String
384
+
*`postPathPrefix` - the path to the post page that would be created or we are editing
385
+
*`pageInformation` - general page information as `BlogAdminPageInformation` - see above
386
+
387
+
### `createUser.leaf`
379
388
380
389
This is the page for creating a new user, or editing an existing one. The parameters are:
381
390
382
-
*`name_error` - a boolean set if there was an error with the name
383
-
*`username_error` - a boolean set if there was an error with the username
384
-
*`errors` - an array of error messages if there were any errors editing or creating the user
385
-
*`name_supplied` - the name of the user we are editing or that we failed to create
386
-
*`username_supplied` - the username of the user we are editing or that we failed to create
387
-
*`password_error` - a boolean set to true if there was an error with the password
388
-
*`confirm_password_error` - a boolean set to true if there was an error with the password confirm
389
-
*`reset_password_on_login_supplied` - a boolean set to true if the edit/create submission was asked to reset the users password on next login (this is only supplied in an error so you can pre-populate the form for a user to correct without losing any information)
391
+
*`title` - the title for the page
390
392
*`editing` - a boolean set to true if we are editing a user
391
-
*`user_id` - this is the ID of the user if we are editing one. This allows you to send the edit user `POST` back to the correct route
392
-
393
+
*`errors` - an array of error messages if there were any errors editing or creating the user
394
+
*`nameSupplied` - the name of the user we are editing or that we failed to create
395
+
*`nameError` - a boolean set if there was an error with the name
396
+
*`usernameSupplied` - the username of the user we are editing or that we failed to create
397
+
*`usernameError` - a boolean set if there was an error with the username
398
+
*`passwordError` - a boolean set to true if there was an error with the password
399
+
*`confirmPasswordError` - a boolean set to true if there was an error with the password confirm
400
+
*`resetPasswordOnLoginSupplied` - a boolean set to true if the edit/create submission was asked to reset the users password on next login (this is only supplied in an error so you can pre-populate the form for a user to correct without losing any information)
401
+
*`userID` - this is the ID of the user if we are editing one. This allows you to send the edit user `POST` back to the correct route
402
+
*`twitterHandleSupplied` - the twitter handle of the user we are editing or that we failed to create
403
+
*`profilePictureSupplied` - the URL of the profile picture of the user we are editing or that we failed to create
404
+
*`biographySupplied` - the biography of the user we are editing or that we failed to create
405
+
*`taglineSupplied` - the tagline of the user we are editing or that we failed to create
406
+
*`pageInformation` - general page information as `BlogAdminPageInformation` - see above
393
407
394
408
## `POST` Routes
395
409
396
410
There are a number of `POST` routes to the Admin site for creating and editing user etc that are required otherwise you will receive errors.
397
411
398
412
This section needs to be filled out, but you can view the Controllers in the code to work out what they should be, or see the [Example Site](https://github.com/brokenhandsio/SteamPressExample).
399
413
400
-
# Contexts
401
-
402
-
## Blog Post
403
-
404
-
The blog post has a number of `Context`s you can pass to the `makeNode()` function to provide more information when getting a `BlogPost`. Currently there are three contexts supported:
405
-
406
-
*`.shortSnippet` - this will return the post with an `id`, `title`, `author_name`, `author_username`, `slug_url`, `created_date` (Human readable) and `short_snippet`
407
-
*`.longSnippet` - this will return the post with an `id`, `title`, `author_name`, `author_username`, `slug_url`, `created_date` (Human readable) and `long_snippet`. It will also include all of the tags in a `tags` object if there are any associated with that post
408
-
*`.all` - this returns the post with all information, including both snippet lengths, including author names and human readable dates, as well as both dates in ISO 8601 format under the parameter names `created_date_iso8601` and `last_edited_date_iso8601`.
409
-
410
-
If no `Context` is supplied to the `makeNode()` call you will get:
411
-
412
-
*`id`
413
-
*`title`
414
-
*`contents`
415
-
*`bloguser_id` - The ID of the Author of the post
416
-
*`created` - The time the post was created as a `Double`
417
-
*`slug_url`
418
-
*`published` - Whether the post has been published or not
419
-
420
-
## Blog User
421
-
422
-
The blog user has a `withPostCount``BlogUserContext` available to pass into the `makeNode()` function that provides an extra `post_count` parameter to the user node, which contains the number of posts that author has written.
423
-
424
-
## Blog Tag
425
-
426
-
The blog user has a `withPostCount``BlogTagContext` available to pass into the `makeNode()` function that provides an extra `post_count` parameter to the tag node, which contains the number of posts tagged with that tag.
427
-
428
-
# Snippets
429
-
430
-
SteamPress supports two type of snippets for blog posts - short and long. Short snippets will provide the first paragraph or so of the blog post, whereas long snippets will show several paragraphs (such as for use on the main blog page, when listing all of the posts)
431
-
432
-
## Usage
433
-
434
-
You can pass in a `BlogPostContext` to the `makeNode()` call to provide more information when getting `BlogPost` objects, as shown above.
435
-
436
-
You can also call them directly on a `BlogPost` object (such as from a `Query()`):
437
-
438
-
```swift
439
-
// These both return the some of the contents of a blog post (as a String)
440
-
let shortSnippet = post.shortSnippet()
441
-
let longSnippet = post.longSnippet()
442
-
```
443
-
444
-
# Markdown Tag
414
+
## Markdown Tag
445
415
446
416
The Markdown Tag allows you to render markdown as HTML in your Leaf files. To use, just simply use:
0 commit comments