Skip to content

syntax highlighting & client-side querying #27

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

Closed
wants to merge 7 commits into from
Closed

syntax highlighting & client-side querying #27

wants to merge 7 commits into from

Conversation

doda-zz
Copy link

@doda-zz doda-zz commented Jul 20, 2012

this pushes all the work of requesting the Gist's contents, rendering them, applying the correct syntax highlighting and sanitizing the HTML to the client.

general thoughts reg. this approach

Advantages:

  • generally faster load times as there's no round-trip through the flask app
  • greatly simplifies hosting, no more worrying about github API limits
  • eliminates almost all dependencies on the server, basically all that is required is serving up the static files
  • no maintaining redis & worrying about abuse
  • freedom to implement whatever features we want, having gist contents + comments would castrate limit the web app to 2500 requests / hour (5000 / 2), if the client does the work of querying GitHub we can pull in however much information we want

Disadvantages:

  • on pages that would be cached, resolving the github DNS, and then client-side running the logic to turn it sanitized HTML might be a couple hundred ms slower
  • initial load is a couple dozen kB higher since sanitization happens on the client

In general I think it's a great improvement since it greatly simplifies everything that happens on the server and even though I prefer doing Python over JS, it's nicer to have everything in one place instead of having it split between python on the server and JS on the client and constantly making sure the 2 match up.

Dominik Dabrowski added 7 commits July 19, 2012 16:52
@doda-zz
Copy link
Author

doda-zz commented Jul 20, 2012

the <code> tags still have the huge regular font, although I don't feel qualified making design decisions on the BDesignFL's project :) it already has github style syntax highlighting courtesy of highlight.js. other than that it's probably best to mimic github's sideways scrolling instead of line breaking

@doda-zz doda-zz mentioned this pull request Jul 22, 2012
@idan
Copy link
Owner

idan commented Aug 6, 2012

@doda Any reason why you chose to use use showdown + santizier vs something like chjj/marked?

@idan
Copy link
Owner

idan commented Aug 6, 2012

@doda (asking for curiosity, not rhetorically)

@doda-zz
Copy link
Author

doda-zz commented Aug 6, 2012

looks good! i didnt know about it. what do you think about pushing the work to the client? i think i've detailed why i personally think it's preferable but i'd be curious to know what your opinions are.

@idan
Copy link
Owner

idan commented Aug 13, 2012

Has upsides and downsides, you hit them all.

With clientside, I can't easily cache rendered gists, and it is difficult to do private gists (but not impossible).

My hacking time is quite limited right now due to newborn, but I'm slowly working out a solution and pushing it.

@idan
Copy link
Owner

idan commented Aug 14, 2013

Syntax highlighting is implemented in a034ca1

Some changes coming up that make clientside not viable. Closing for now!

@idan idan closed this Aug 14, 2013
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.

2 participants