Skip to content

ref T586 support any writefreely instance #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 65 commits into from
Sep 20, 2019
Merged

ref T586 support any writefreely instance #36

merged 65 commits into from
Sep 20, 2019

Conversation

ghost
Copy link

@ghost ghost commented Jun 11, 2019

This one is a bit huge.

First this creates a new binary wf which supports additional features not needed on write.as. Namely different hosts and multiple users, as many user accounts can be authenticated as you wish. Just pass a -u <username> global flag to select the one to use for an action. i.e. wf -u rob posts

This would be v1.0 for wf.

ref T592, T593, T594, T595, T597, T634, T635, T645

@ghost
Copy link
Author

ghost commented Jun 11, 2019

also will need to verify the change with global flags doesn't break anything
fixed

@ghost ghost marked this pull request as ready for review June 11, 2019 23:34
@ghost
Copy link
Author

ghost commented Jun 12, 2019

found a small bug I missed, unsynced posts are stored in one file at the root, not at each host level. fix incoming.

@ghost ghost changed the title ref T586 support any writefreely instance [WIP] ref T586 support any writefreely instance Jun 12, 2019
@ghost
Copy link
Author

ghost commented Jun 12, 2019

just waiting for writeas/go-writeas#18 to verify things work as expected

@ghost ghost changed the title [WIP] ref T586 support any writefreely instance ref T586 support any writefreely instance Jun 13, 2019
@ghost ghost requested a review from thebaer June 13, 2019 17:18
Rob Loranger added 20 commits June 18, 2019 14:56
this creates a second binary, wf, which will have additonal
functionality for hosts other than write.as.

also moves global flags into their own slice in new file

adds `host, H` global flag

inlcudes gitignore for binary
only if host flag supplied for writefreely binary, writeas unaffected
some changes resulted in the data directory initialization creating the
.writeas/.writefreely directory in the current working directory.
- adds new user/u flag to wf
- load and save user file based on username
- removed host flag from writeas
- adds hidden global flag for user to writeas to maintain
compatibility
- now allows authentication with more than one user per host, stored as
username.json inside the [host] directory.
- supports a default user and host in config.ini
- global flags will override the default
full support, auth and actions working by use of flags or defaults
maintains backwards compatibility with write.as
this get's the wf binary up to date with the writeas functionality
only on wf, writeas still stores in root user config directory
there was a bug where a default user at the config directory root was
not being used for calls not including a flag or host level config.ini
also update CmdClaim for new LoadUser signiture
I had changed the global flags variable to only be those that are global
this broke some compatibility with piping from stdout into the binary.

also:
- binary specific configuration details have moved into the same map but
in main.go. only the configDir is OS dependent.
- a new key in the map is for the version so each binary can have their
own
also CmdPost should return an exit error if there is one
for inclusion of collection in post parameters
new posts, when no flag is specified for blog or collection, will now
default to the user collection. that is the username.
@ghost ghost changed the base branch from version-two to develop June 18, 2019 21:57
if the user flag is provided auth should attempt to authenticate with
that user.
@ghost
Copy link
Author

ghost commented Aug 8, 2019

ready for final testing and review @thebaer

@thebaer
Copy link
Member

thebaer commented Sep 9, 2019

Okay, we're getting very close. This may be the last issue we need to solve. The situation is:

I'm logged in under multiple accounts, but don't have a default user set (I logged out of it, so it was removed from the config). Now when I run ./wf I get:

You must be authenticated to publish.
Log in first with: wf auth <username>

This is confusing, because I am authenticated -- wf just doesn't know what account to use, since there's no default and no flags given. So instead, I'd like it to say something like:

You are authenticated, but have no default user set. Supply -user and -host flags.

I started trying to implement this, but it looks like it's going to need a bit more work. It looks like we're getting very close to needing the accounts command. If that logic is needed to get this error message, then we should do it.

What do you think?

@ghost
Copy link
Author

ghost commented Sep 9, 2019

I'll take a look quick, we might be able to get this without adding the accounts command, then add that after. Unless you want it all in for the CLI release.

@thebaer
Copy link
Member

thebaer commented Sep 9, 2019

Let's try to go without it for this initial release and add it later.

@ghost
Copy link
Author

ghost commented Sep 9, 2019

ok got it, just going to clean up some redundancy quick

this adds a check for any logged in users on any host when neither the
user or host flag are passed and not default pair is configured
@ghost
Copy link
Author

ghost commented Sep 9, 2019

I didn't bother to refactor, it would only save three lines in two places.

@thebaer
Copy link
Member

thebaer commented Sep 9, 2019

Awesome, will test when I'm back at my computer.

@thebaer
Copy link
Member

thebaer commented Sep 9, 2019

Just tested latest changes and now I'm unable to post anything:

$ echo "hi" | ./wf -host team.write.as
Unable to post: Problem creating post: 401. Not logged in.
$ echo "hi" | ./wf -host team.write.as -user matt
Unable to post: Problem creating post: 401. Not logged in.

To be sure, I'm authenticated as matt on team.write.as. Is everything working for you?

@thebaer
Copy link
Member

thebaer commented Sep 9, 2019

Also some odd behavior when I do have a default account:

$ ./wf -host pencil.writefree.ly auth hello
Password: *******
Set hello on pencil.writefree.ly as default account.
$ echo "hi" | ./wf
Error creating data directory: mkdir /home/mattbaer/.writefreely/https:/pencil.writefree.ly: no such file or directory
You must be authenticated to publish.
Log in first with: wf auth <username>

Probably because we store the schema in the configuration. Which is probably correct, e.g. if someone logs in with the --insecure flag we should respect that. But then when loading the default from the config file, we shouldn't prepend any schema. Could you take a look at that?

@ghost ghost mentioned this pull request Sep 13, 2019
@thebaer
Copy link
Member

thebaer commented Sep 18, 2019

Looks really, really good!

I think the very last thing is that we should undo the change where wf automatically posts to the logged in user's default collection (i.e. the one that matches their username). It's convenient, but it makes publishing drafts impossible, so we should fix that.

I also fixed some weird language when trying to run commands while being unauthenticated.

@ghost
Copy link
Author

ghost commented Sep 18, 2019

Sure, I can revert the default collection thing.

@thebaer
Copy link
Member

thebaer commented Sep 18, 2019

Great. Though now I don't seem to be able to post at all:

Unable to post: Problem creating post: 401. Not logged in.

@ghost
Copy link
Author

ghost commented Sep 18, 2019

silly question, are you logged in? I tried with both wf and writeas with success. using the default command, and new. which sub command are you using?

@thebaer
Copy link
Member

thebaer commented Sep 18, 2019

Hmm yeah, I authenticated right after I pulled in those changes. But then I re-authenticated with the same exact account and now it's all working. Weird. But draft publishing works 👍

Doing one last run-through and then we'll merge!

@thebaer
Copy link
Member

thebaer commented Sep 20, 2019

There are still some very small places where we can improve the UX, but we can address them in the next update. Great work! Merging now.

@thebaer thebaer merged commit de2ec24 into develop Sep 20, 2019
@thebaer thebaer deleted the T586 branch September 20, 2019 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant