site icon indicating copy to clipboard operation
site copied to clipboard

feat: Edit on GitHub button for content articles

Open hedyhli opened this issue 3 years ago • 4 comments

Please don't review this yet :grin:

PR body

Supersedes #623 and #506 Closes #459

This PR adds an 'Edit on GitHub' button on the top right of content articles which links to the corresponding page source URL on the site repository on GitHub. This only shows up on articles (and those with sub-articles) and not categories. Apart from that this differs to the original implementation (in #506) in that it uses the relative path URL, and replaces the prefix (/pages/ part) with the GitHub repository source URL link and adds an .md. The hardcoded file name extension might be fixed when the source URL is grabbed when adding template context in pages.

I'll add a screenshot here soonish

PR status

  • Does it work? yup, just that it shows up in the guides list too. It should only show on articles, not categories, and ^ that is the only category that doesn't work from what I tested.
  • In terms of UI: can and should be improved
  • Tests: will add some soon:tm:

todo

  • [ ] Put src_url in page template context instead of using template filter
  • [ ] ...which would fix the button showing up in guides
  • [ ] Fix GitHub icon
  • [ ] Sizing and position
  • [ ] Maybe add some tests
  • [ ] Maybe not hardcoded GitHub prefix URL

hedyhli avatar Nov 19 '21 04:11 hedyhli

Deploy Preview for pydis-static ready!

Name Link
Latest commit a700e8b0df74cd7134069d9dc8902a0624f213af
Latest deploy log https://app.netlify.com/sites/pydis-static/deploys/635c93d9f6c060000707a5ed
Deploy Preview https://deploy-preview-626--pydis-static.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Nov 19 '21 04:11 netlify[bot]

Coverage Status

Coverage remained the same at 100.0% when pulling a700e8b0df74cd7134069d9dc8902a0624f213af on hedyhli:feat/edit-gh into 5c23e35dfe4f934722fe680298b7a3bdd3bc5447 on python-discord:main.

coveralls avatar Nov 19 '21 04:11 coveralls

@hedyhli Greetings. What's the status of this PR? Thanks!

Xithrius avatar Mar 23 '22 00:03 Xithrius

Hi Xithrius! Unfortunately I've been pretty busy with school lately. I'd love to continue working on it though but I can't guarantee when I'll have time for it, hopefully before the end of April by the latest.

hedyhli avatar Mar 26 '22 00:03 hedyhli

@hedyhli Greetings. What is your status on this PR?

Thanks!

Xithrius avatar Oct 12 '22 19:10 Xithrius

Finally found some free time which fingers crossed might last until as much as the end of the year! So I'll be working on this for the coming weeks. Actually I have already resumed on this, but I have to set up my dev environment all over again and had some problems with docker the last time I tried (honestly I can't even remember if I used the docker setup last year).

hedyhli avatar Oct 28 '22 11:10 hedyhli

Marking this as ready for review, feedback welcome!

hedyhli avatar Oct 29 '22 03:10 hedyhli

Very good.

Xithrius avatar Oct 29 '22 03:10 Xithrius

Any thoughts on how the behaviour on mobile could be improved?

It should wrap so the whole thing is to the next line, like I mentioned in the description. Either same line as sub-articles or each one their own line.

At the moment sub-articles seems to be wrapping to fit on the same line as the title. I doubt this works when title is longer (for pages other than the contributing index page) even before adding the edit on github like, so it would probably be best to have them both take their own line before the title.

I’ll experiment with what can be done, thanks!

hedyhli avatar Feb 18 '23 05:02 hedyhli

Hi @hedyhli, were you able to find some possible fix for mobile? If it's too much of a hassle I believe we should also just be able to skip adding the edit button on mobile outright, as it's probably much less used than on desktop.

jchristgit avatar Mar 21 '23 20:03 jchristgit

I have opened a PR at https://github.com/python-discord/site/pull/626 that has your commits to allow maintainer edits to get the final changes in to merge it.

jchristgit avatar Apr 21 '23 19:04 jchristgit

Sad I didn’t get time to work on this, but thanks a lot for continuing on my progress!

hedyhli avatar Apr 22 '23 04:04 hedyhli

Thanks for laying the foundation with your work! I am looking forward to having this on the live site.

jchristgit avatar Apr 22 '23 09:04 jchristgit