valberg / djangit

A git repo browser written in django and dulwich
http://djang.it
9 stars 1 forks source link

Find a good sourcecode viewer #2

Open valberg opened 10 years ago

valberg commented 10 years ago

Djangit needs a good sourcecode viewer that has highlighting and linenumbers.

valberg commented 10 years ago

We can just have a template tag that uses pygments to do the highlighting and does something to add linenumbers.

halfd commented 10 years ago

Should it be frontend or backend or a combination?

benjaoming commented 10 years ago

You could go for server-side where the highlighting is generated and cached upon the first request.

Problem: When to clean up the cache.

If you don't do caching, then server-side generation seems futile, since the client has the advantage of being much more versatile and flexible to suit user needs.

valberg commented 10 years ago

@halfd Good question! As I see it both have pros and cons:

Frontend:

Backend:

@benjaoming Doing caching on the highlighting might be a good idea. But I can foresee that it becomes quite a cache. You would have to cache every blob and diff. But maybe that's not so bad?

benjaoming commented 10 years ago

Holistically, if you make the same expensive computation twice, it's a bad idea... so caching stuff like that is a really good thing. However, you can use the django cache proxy functions which allows people to have various cache backends.

valberg commented 10 years ago

I'm beginning to think that doing the highlighting on the frontend is a better solution.

Just found this: https://github.com/isagalaev/highlight.js

benjaoming commented 10 years ago

Cool, do you know what the numbers in the parathesis on this page mean? http://softwaremaniacs.org/media/soft/highlight/test.html

On 24 October 2013 20:05, valberg notifications@github.com wrote:

I'm beginning to think that doing the highlighting on the frontend is a better solution.

Just found this: https://github.com/isagalaev/highlight.js

— Reply to this email directly or view it on GitHubhttps://github.com/valberg/djangit/issues/2#issuecomment-27015565 .

halfd commented 10 years ago

Here is some reading:

http://stackoverflow.com/questions/160694/syntax-highlighting-code-with-javascript

http://craig.is/making/rainbows

http://prismjs.com/

http://softwaremaniacs.org/soft/highlight/en/