Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ nano users/foobar/.env
```
fairpost.js prepare-posts
```
Folders need to be `prepared` (iow turned into posts)
Sources need to be `prepared` (iow turned into posts)
before they can be published to a platform.
Each platform, as defined in src/platforms, will
handle the folder contents by itself. It may
Expand Down Expand Up @@ -139,21 +139,21 @@ fairpost: @userid refresh-platform --platform=xxx
fairpost: @userid refresh-platforms [--platforms=xxx,xxx]
fairpost: @userid get-platform --platform=xxx
fairpost: @userid get-platforms [--platforms=xxx,xxx]
fairpost: @userid get-folder --folder=xxx
fairpost: @userid get-folders [--folders=xxx,xxx]
fairpost: @userid get-source --source=xxx
fairpost: @userid get-sources [--sources=xxx,xxx]
fairpost: @userid get-post --post=xxx:xxx
fairpost: @userid get-posts [--status=xxx] [--folders=xxx,xxx] [--platforms=xxx,xxx]
fairpost: @userid get-posts [--status=xxx] [--sources=xxx,xxx] [--platforms=xxx,xxx]
fairpost: @userid prepare-post --post=xxx:xxx
fairpost: @userid schedule-post --post=xxx:xxx --date=xxxx-xx-xx
fairpost: @userid schedule-posts [--folders=xxx,xxx|--folder=xxx] [--platforms=xxx,xxx|--platform=xxx] --date=xxxx-xx-xx
fairpost: @userid schedule-posts [--sources=xxx,xxx|--source=xxx] [--platforms=xxx,xxx|--platform=xxx] --date=xxxx-xx-xx
fairpost: @userid schedule-next-post [--date=xxxx-xx-xx] [--platforms=xxx,xxx|--platform=xxx]
fairpost: @userid publish-post --post=xxx:xxx [--dry-run]
fairpost: @userid publish-posts [--folders=xxx,xxx|--folder=xxx] [--platforms=xxx,xxx|--platform=xxx]
fairpost: @userid publish-posts [--sources=xxx,xxx|--source=xxx] [--platforms=xxx,xxx|--platform=xxx]

# feed planning:
fairpost: @userid prepare-posts [--folders=xxx,xxx|--folder=xxx] [--platforms=xxx,xxx|--platform=xxx]
fairpost: @userid schedule-next-posts [--date=xxxx-xx-xx] [--folders=xxx,xxx] [--platforms=xxx,xxx]
fairpost: @userid publish-due-posts [--folders=xxx,xxx] [--platforms=xxx,xxx] [--dry-run]
fairpost: @userid prepare-posts [--sources=xxx,xxx|--source=xxx] [--platforms=xxx,xxx|--platform=xxx]
fairpost: @userid schedule-next-posts [--date=xxxx-xx-xx] [--sources=xxx,xxx] [--platforms=xxx,xxx]
fairpost: @userid publish-due-posts [--sources=xxx,xxx] [--platforms=xxx,xxx] [--dry-run]

# admin only:
fairpost: create-user --userid=xxx
Expand All @@ -177,7 +177,7 @@ fairpost.js [command] [arguments] --verbose

To add support for a new platform, add a class to `src/platforms`
extending `src/classes/Platform`. You want to override at least the
method `preparePost(folder)` and `publishPost(post,dryrun)`.
method `preparePost(source)` and `publishPost(post,dryrun)`.

Then import your class and add a `platformId` for your platform
in `src/platforms/index.ts` and enable your platformId in your `.env`.
Expand Down
6 changes: 3 additions & 3 deletions docs/NewPlatform.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ you can write your own code to support it.

To add support for a new platform, add a class to `src/platforms`
extending `src/classes/Platform`. You want to override at least the
method `preparePost(folder)` and `publishPost(post,dryrun)`.
method `preparePost(source)` and `publishPost(post,dryrun)`.

Make sure not to throw errors in or below publishPost; instead, just
return false and let the `Post.processResult()` itself.
Expand All @@ -30,8 +30,8 @@ export default class FooBar extends Platform {
}

/** @inheritdoc */
async preparePost(folder: Folder): Promise<Post> {
const post = await super.preparePost(folder);
async preparePost(source: Source): Promise<Post> {
const post = await super.preparePost(source);
if (post) {
// prepare your post here
post.save();
Expand Down
10 changes: 5 additions & 5 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ const USERID = (getOption("userid") as string) ?? "";
const OUTPUT = (getOption("output") as string) ?? "text";
const PLATFORMS =
((getOption("platforms") as string)?.split(",") as PlatformId[]) ?? undefined;
const FOLDERS = (getOption("folders") as string)?.split(",") ?? undefined;
const SOURCES = (getOption("sources") as string)?.split(",") ?? undefined;
const DATE = (getOption("date") as string) ?? undefined;
const STATUS = (getOption("status") as PostStatus) ?? undefined;

let PLATFORM = (getOption("platform") as string as PlatformId) ?? undefined;
let FOLDER = (getOption("folder") as string) ?? undefined;
let SOURCE = (getOption("source") as string) ?? undefined;
const POST = (getOption("post") as string) ?? undefined;
if (POST) {
[FOLDER, PLATFORM] = POST.split(":") as [string, PlatformId];
[SOURCE, PLATFORM] = POST.split(":") as [string, PlatformId];
}

// utilities
Expand All @@ -51,8 +51,8 @@ async function main() {
userid: USERID,
platforms: PLATFORMS,
platform: PLATFORM,
folders: FOLDERS,
folder: FOLDER,
sources: SOURCES,
source: SOURCE,
date: DATE ? new Date(DATE) : undefined,
status: STATUS,
});
Expand Down
Loading