Skip to content
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

add 'Edit Page' feature to doc pages #278

Merged
merged 3 commits into from
Oct 9, 2018

Conversation

britneywright
Copy link
Contributor

for #96

I added a configuration setting named micrositeEditButtonText. By default it's set to None and the button is not visible. If it's set to Some with a string a button will appear at the bottom of pages with the DocsLayout. The button will have the text of the given string and link to the edit view of the page in the project repository.

For example for the page https://www.vinyldns.io/api/create-zone.html the button would link to https://github.com/VinylDNS/vinyldns/edit/master/modules/docs/src/main/tut/api/create-zone.md

Desktop view:
screen shot 2018-10-05 at 12 03 09 pm

Mobile view.
screen shot 2018-10-05 at 12 03 23 pm

juanpedromoreno
juanpedromoreno previously approved these changes Oct 6, 2018
Copy link
Member

@juanpedromoreno juanpedromoreno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great contribution @britneywright , thanks for doing this!

cls := "edit-button",
a(
href := config.gitSiteUrl,
href := "/edit/master/modules/docs/src/main/tut/{{ page.path }}",
Copy link
Member

@juanpedromoreno juanpedromoreno Oct 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can set up this "baseUrl" (the modules/docs/src/main/tut piece) to a new setting, for example, in the sbt-microsites case, this would be something like this:

/edit/master/docs/src/main/tut/docs/{{ page.path }}

Hence, my suggestion would be creating a product (EditButtonSettings) for the new sbt setting:

micrositeEditButton: SettingKey[Option[EditButtonSettings]]

// ... and

case class EditButtonSettings(text: String, baseDocsPath: String)

Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's a good idea. i was debating if I should make that go to the edit view of the page or not, this way users could decide for themselves.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah and yes I realized I was basing my path off a project with modules, so the path could vary depending on that as well.

@juanpedromoreno juanpedromoreno dismissed their stale review October 6, 2018 17:47

Added a suggestion to improve the new setting

@britneywright
Copy link
Contributor Author

@juanpedromoreno Let me know what you think of this update. So now in a project the setting would be something micrositeEditButton := Some(MicrositeEditButton("Improve this Page", "/edit/master/modules/docs/src/main/tut/{{ page.path }}"))

@juanpedromoreno
Copy link
Member

Thanks @britneywright , great contribution!

I think there are some minor failures in the unit tests, but the code and docs look good to me. Once fixed, I'll merge it and I'll release a new patch version :)

@juanpedromoreno juanpedromoreno merged commit ad5a20a into 47degrees:master Oct 9, 2018
@juanpedromoreno
Copy link
Member

LGTM, thanks!

@sritchie
Copy link
Contributor

sritchie commented Sep 2, 2019

I think this double-href introduces a space after the config.gitSiteUrl, which means the URL doesn't resolve. Have any of you seen that behavior?

@sritchie
Copy link
Contributor

sritchie commented Sep 2, 2019

Actually, yes... this is what I'm seeing generated:

<a href="https://github.com/sritchie/scala-rl /edit/develop/docs/src/main/tut/course/tabular/bandits.md" class="btn-sm btn-info">Improve this Page</a>

@britneywright
Copy link
Contributor Author

@sritchie Not seeing what you're seeing.

Here's what's generated in the project I work on: https://github.com/vinyldns/vinyldns/blob/gh-pages/api/approve-batchchange.html#L195

And here's our config setting: https://github.com/vinyldns/vinyldns/blob/master/build.sbt#L413-L415

Do you have a link to your project if you want some help?

@sritchie
Copy link
Contributor

sritchie commented Sep 3, 2019

Hey @britneywright, the issue only appeared in 0.9.3 with some version upgrades. Looks like I chose the lucky version.

Some guesses about the cause showed up here: #323

And I can confirm that this fixed it: #324

Thanks!

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.

3 participants