Page MenuHomewrite.as

Support any WriteFreely instance
Open, Medium-HighPublic

Description

Overview

Users should be able to use the CLI with any WriteFreely instance -- not just Write.as.

This should involve a rebranding of the Write.as CLI to make it clear to users that the client works with any instance -- perhaps create a new writefreely executable in the cmd/ directory that shares code with the writeas CLI and only includes functionality that works on WF.

Implementation

  • Create a new .writefreely directory in the user's home directory
  • Add a -host or -h flag that allows user to specify which instance to interact with
  • When they successfully perform an action on an instance, save that information to a folder in ~/.writefreely:
    • instance directory: ~/.writefreely/[host]
    • posts: ~/.writefreely/[host]/[username]/posts.json
    • user data: ~/.writefreely/[host]/[username]/user.json
  • Future interactions with that instance should load the corresponding data from the instance's data directory

posts.json

Should contain the JSON array of posts returned in the data property from the /api/me/posts endpoint.

user.json

Should contain the full JSON object returned in the data property from the /api/auth/login endpoint (as currently happens when running writeas auth). This includes the access_token needed for all authenticated requests.

Questions

We should probably provide a way to indicate the default instance and username for CLI operations, so users don't have to include them every time.

Details

Commits
Restricted Diffusion Commit
Restricted Diffusion Commit
Restricted Diffusion Commit
Restricted Diffusion Commit
Restricted Diffusion Commit
Restricted Diffusion Commit

Event Timeline

matt created this task.May 26 2019, 7:53 PM
matt moved this task from Backlog to Next Up on the Write.as CLI board.
matt triaged this task as Medium-High priority.
matt updated the task description. (Show Details)May 26 2019, 7:56 PM
matt updated the task description. (Show Details)May 27 2019, 1:49 PM
robjloranger added a comment.EditedMay 27 2019, 5:11 PM

re: question about default

I'm thinking just something like ~/.writefreely/config.json, or config.ini, which could even be created during a setup sub command as well as edited manually.

This could also later store the preferences for font, ltr etc T585

Paying attention to this, since I'm likely to wind up using these config files in T571 as well. Let me know if I can contribute.

I will ping you if I need some help for sure. We may be able to share some code now that I'm moving most of the cli into a package separate from the binary.

matt edited projects, added WriteFreely CLI; removed Write.as CLI.Jun 5 2019, 7:55 PM

Created WriteFreely CLI, so it's easier to track features that should be in only one client (or both). In this case, this is a WF CLI feature only.

robjloranger moved this task from Backlog to Soon on the WriteFreely CLI board.Jun 6 2019, 3:16 AM
robjloranger moved this task from Soon to Next Up on the WriteFreely CLI board.Jun 7 2019, 6:48 PM

I don't think we should store the posts.json and use it for subsequent requests. For example, when would it expire? There may be more posts on the remote or something may have changed.

matt added a comment.Jun 10 2019, 5:16 PM

I agree, storing posts.json comes with challenges. But, a few things:

  • The /api/me/posts call is expensive. Caching this data, even for 5 - 15 minutes, would go a long way to making the CLI more responsive.
  • We're going to need to figure out how to sync that information for {T584} no matter what.

But for this particular task, we shouldn't worry about storing it.

TODO: break this up into its own task.

I've got a weird issue, maybe it is by design.

I can not create a new anonymous post against my single user instance using wf. Which would be writeas in the other. The default Post command.

I've got a weird issue, maybe it is by design.
I can not create a new anonymous post against my single user instance using wf. Which would be writeas in the other. The default Post command.

I must be tired.. that is of course the obvious behavior as you wouldn't want strangers just posting stuff of a single user blog.

matt added a comment.Mon, Jul 22, 6:08 PM

Just a heads up @robjloranger: noticed a bug in WriteFreely when testing this, and fixed it in #144. Basically the full collection URL wasn't getting sent back, so after publishing I'd see /matt/new-post instead of https://team.write.as/matt/new-post

matt added a commit: Restricted Diffusion Commit.Mon, Jul 22, 7:45 PM
matt added a commit: Restricted Diffusion Commit.
matt added a commit: Restricted Diffusion Commit.
matt added a commit: Restricted Diffusion Commit.
matt added a commit: Restricted Diffusion Commit.
matt added a commit: Restricted Diffusion Commit.Tue, Jul 30, 4:30 PM