joeyespo / grip

Preview GitHub README.md files locally before committing them.
MIT License
6.48k stars 424 forks source link

Not seeing any styles? #265

Closed eriknelson closed 6 years ago

eriknelson commented 6 years ago

Using grip 4.4.0 and a personal access token: grip --pass=<token> file.md, I'm not seeing any styles in my any of my browsers. I do see octicons.css as loaded, but the content basically looks like raw html. Am I missing something?

joeyespo commented 6 years ago

Interesting. Yeah sounds like something's not right.

Could you try running grip --clear, then running your command again? And if it's still not working, copy/paste the output from the terminal in a comment here. Should look something like:

$ grip --pass=<token> file.md
 * Using personal access token
 * Running on http://localhost:6419/ (Press CTRL+C to quit)
 * Downloading style https://assets-cdn.github.com/assets/frameworks-a4bf54bef6fb.css
 * Downloading style https://assets-cdn.github.com/assets/github-d5aa84dde2d5.css
 * Downloading style https://assets-cdn.github.com/assets/site-5ebe68400bf4.css
 * Cached all downloads in <path>/.grip/cache-4.4.0
mrkale commented 6 years ago

I have the same issue. It seems like Grip is not downloading CSS files from Github.

* Running on http://localhost:6419/ (Press CTRL+C to quit)
127.0.0.1 - - [13/Mar/2018 23:22:15] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [13/Mar/2018 23:22:15] "GET /__/grip/static/octicons/octicons.css HTTP/1.1" 200 -
127.0.0.1 - - [13/Mar/2018 23:22:15] "GET /__/grip/static/octicons/octicons.woff2?ef21c39f0ca9b1b5116e5eb7ac5eabe6 HTTP/1.1" 200 -
127.0.0.1 - - [13/Mar/2018 23:22:15] "GET /__/grip/static/favicon.ico HTTP/1.1" 200 -
joeyespo commented 6 years ago

@mrkale Interesting. Looks that way, yeah.

So grip --clear didn't help? What does your ~/.grip directory look like? Have a settings.py?

spiritphyz commented 6 years ago

@joeyespo I have the same issue. I did grip --clear and the problem still exists. My settings.py just has my Github access token in it. My ~/.grip directory is empty except for settings.py.

$ grip --clear
Cache cleared.
$ rm ~/.grip/settings.py
$ grip
 * Running on http://localhost:6419/ (Press CTRL+C to quit)
127.0.0.1 - - [15/Mar/2018 15:05:29] "GET / HTTP/1.1" 200 -
^C * Shutting down...
$ cp ~/.grip/settings.py.bak ~/.grip/settings.py
$ grip
 * Using personal access token
 * Running on http://localhost:6419/ (Press CTRL+C to quit)
^C * Shutting down...
zsk425 commented 6 years ago

Same issue.

* Using personal access token
* Running on http://localhost:6419/ (Press CTRL+C to quit)
127.0.0.1 - - [16/Mar/2018 18:48:10] "GET / HTTP/1.1" 200 -
^C * Shutting down...

The ~/.grip doesn't exist.

armintoepfer commented 6 years ago

Same issue here on a mac. Had to switch to python3 since homebrew shuffled versions around. Since then, no style.

ukclivecox commented 6 years ago

Same here. Only difference seems to be using python 3.

joeyespo commented 6 years ago

Interesting. Looking more into it.

I switched to Python 3.6 myself a while back. My only first thought is that perhaps it's still using some Python 2 libraries. Can anyone here try uninstalling grip completely then using pip3 to reinstall?

ukclivecox commented 6 years ago

I installed via anaconda3 pip

joeyespo commented 6 years ago

I was able to reproduce after installing Python 2.7, so I'll report back here after I find out what's missing.

While I'm at it, can anyone here with both 2.7 and 3.x and experiencing the problem uninstall Python 2.7 and see if that fixes it?

bperrybap commented 6 years ago

Not sure if its related, but I'm not seeing the styles on a freshly installed 64 bit linux mint 17.3 I'm not using anything but the default command execution on a local readme (no pass token) It works fine on a 32bit linux mint 13 and 32 bit mint 17.3 after doing lots of pip updates. I'm still in the process of trying to track it down on the new 64 bit mint install. (Not sure if I've done all the pip updates I did on the other machines as lots were needed and I stupidly didn't not write down all of them) The only thing I've noticed so far is that the 32 bit machines only have python 2.7 whereas the 64 bit mint has both python 2.7 and 3.4.3 along with python-six compatibility library package. I'm going to fire up a VM to play with things as I seem to recall the removing python 2.x kills linux mint.

joeyespo commented 6 years ago

Ok, found the issue!

Looks like crossorigin="anonymous" was added to the stylesheet links on GitHub. This is one of the big downsides of using regular expressions instead of true HTML parsing.

I updated the internal STYLE_URLS_RE constant to reflect this (6882ef4bc72a6272d33211a661edc7dfec8311f6). I also made it more flexible by removing the media="all" check and allowing rel="stylesheet" to appear before or after href. It's a bit hacky vs using a single RE, but I wanted to be absolutely sure the implementation limitation described here wasn't going to break this fix.

While I was at it, I added a warning that'll point back here in case the "download styles" part ever fails to find styles again (6b6cfcb7ed9d3bad78e7e146af4018aea52bf8bf). If something like this happens again, I'll strongly consider switching to HTML parsing instead of another quick fix.

Will release and report back here in a bit! You can test it now by installing master.

eriknelson commented 6 years ago

Awesome! I'll try to confirm the fix. Thanks!

On Mar 18, 2018 6:39 PM, "Joe Esposito" notifications@github.com wrote:

Ok, found the issue!

Looks like crossorigin="anonymous" was added to the stylesheet links on GitHub. This is one of those big downside of using regular expressions instead of true HTML parsing.

I updated the internal STYLE_URLS_RE constant to reflect this (6882ef4 https://github.com/joeyespo/grip/commit/6882ef4bc72a6272d33211a661edc7dfec8311f6). I also made it more flexible by removing the media="all" check and allowing rel="stylesheet" to appear before or after href. It's a bit hacky vs using a single RE, but I wanted to be absolutely sure the implementation limitation described here https://docs.python.org/3/library/re.html#re.findall wasn't going to break this fix.

While I was at it, I added a warning that'll point back here in case the "download styles" part ever fails to find styles again (6b6cfcb https://github.com/joeyespo/grip/commit/6b6cfcb7ed9d3bad78e7e146af4018aea52bf8bf). If something like this happens again, I'll strongly consider switching to HTML parsing instead of another quick fix.

Will release and report back here in a bit!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/joeyespo/grip/issues/265#issuecomment-374059883, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZFNYXdgwoM3vYLWXXWq3YF2nVizLCoks5tfuICgaJpZM4SjGt9 .

joeyespo commented 6 years ago

Ok. 4.5.0 is out! Closing this now. Feel free to reopen if the problem persists for anyone after upgrading with pip install --upgrade grip.

Thanks for the issue, @eriknelson, and for all the help diagnosing, everyone 👍

bperrybap commented 6 years ago

The latest update fixed the issues I was having. If it was do to a github change, not sure why it was still working on my older installations.

joeyespo commented 6 years ago

The latest update fixed the issues I was having

Awesome!

not sure why it was still working on my older installations

Probably because the styles were already cached at that point.

eivindml commented 6 years ago

I have the same issue. I just installed it, but through brew. I see that the newest version on brew is 4.4.0. How long until brew is updated with newest version?

SuperZombi commented 3 years ago

Failed to load resource octicons.css Error 304