Added line numbers in file detail view with ids for future styling.#157
Added line numbers in file detail view with ids for future styling.#157k10blogger merged 5 commits intowebsvnphp:masterfrom
Conversation
|
This is fantastatic, I will happily review this next week. |
michael-o
left a comment
There was a problem hiding this comment.
I see two problems:
- Anchors aren't clickable, means hard to share
- Generated ID unusable since it changes constantly, see https://www.wikiparques.com/extensions/SyntaxHighlight_GeSHi/geshi/docs/geshi-doc.html#adding-ids-to-each-line. I guess we need
$geshi->set_overall_id('...')as well?
|
I was wondering how to change the overall ids. Thanks for pointing that out. Using |
| if ($highlight == 'file') { | ||
| $this->geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); | ||
| $this->geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS,1); | ||
| $this->geshi->set_overall_id('line'); |
There was a problem hiding this comment.
Attention, this does not only apply to the line, but to the entire geshi rendering.
There was a problem hiding this comment.
line- is too naive. It will apply to all elements of the Geshi rending, not just lines. Lets make it geshi just like the set_overall_class()
There was a problem hiding this comment.
Are you sure?? making geshi would mean if we have to get a url for say line number 110 we have to use anchor as #geshi-110. I am thinking line would be more intuitive. like #line-110 knowing we are trying to jump to line 110. or should we use l instead, like done in blame.php ??
Here is the url in case of blame http://localhost/websvn/blame.php?repname=Test+Group+1.Common+Model&path=%2Ftrunk%2FCFiles%2Fasm08.c&rev=23#l110
There was a problem hiding this comment.
Yes, I am sure. Look into geshi.php and usage of overall_id. It does not only apply to numbers. It is all or nothing. As far I can see l110 is not possible because the template is {id}-{number}. The hyphen remains.
There was a problem hiding this comment.
Okay... Changed to geshi.
| $this->geshi->set_tab_width($this->repConfig->getExpandTabsBy()); | ||
|
|
||
| if ($highlight == 'file') { | ||
| $this->geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS,1); |
There was a problem hiding this comment.
The 1 doesn't add any benefit. It will just make every line bold.
There was a problem hiding this comment.
By default fancy line numbers are normal line numbers. Adding 1 as an argument makes them "fancy" or "bold". Initially i had not passed any arguments as i was hoping maybe in future we can somehow pass the line number in the url here. So only those line numbers would be marked as bold. Link in case i pass #line-135 then only line 135 will be marked rest will be normal.
There was a problem hiding this comment.
By default fancy line numbers are normal line numbers. Adding 1 as an argument makes them "fancy" or "bold". Initially i had not passed any arguments as i was hoping maybe in future we can somehow pass the line number in the url here. So only those line numbers would be marked as bold. Link in case i pass
#line-135then only line 135 will be marked rest will be normal.
This is not what I see. The number means in what step numbers will be bold. I don't see a reavery to make every number bold. There is no JS magic behind.
There was a problem hiding this comment.
ahh okay. Anyways That is a topic for another PR. Completely dropped the 2nd argument.
| if ($highlight == 'file') { | ||
| $this->geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); | ||
| $this->geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS,1); | ||
| $this->geshi->set_overall_id('line'); |
There was a problem hiding this comment.
line- is too naive. It will apply to all elements of the Geshi rending, not just lines. Lets make it geshi just like the set_overall_class()
| if ($highlight == 'file') { | ||
| $this->geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS,1); | ||
| $this->geshi->set_overall_id('line'); | ||
| $this->geshi->enable_ids(true); |
There was a problem hiding this comment.
true is default value, you can drop it and use zero args.
Reanmed the id to match overall class 'geshi'
| $this->geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS,1); | ||
| $this->geshi->set_overall_id('line'); | ||
| $this->geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS); | ||
| $this->geshi->set_overall_id('geshi'); |
There was a problem hiding this comment.
I don't see a better way without fixing geshi first. The issue that Geshi can be used multiple times in a PHP script, mean you would produce clashing its. That is why you need an overall id.
Bascially, they need to introduce a line number override and we make sure that only a single instance of geshi is used per svnlook. Which is.
|
@michael-o Unfortunately i did a squash in web view which merged all the commits and changes to the base branch. Please have a look here. If needed i can revert and add changes again. |
Not necessary, take it as lessons learned. |

This is a minor enhancement. Previously the view looked like the following:

There were no line numbers in the file details view.
The change in the PR adds the line number and provides a basic default styling looks like the following:

The change uses the in-built line number system provided by geshi. So viewable only if geshi is used. Same can be done for enscript but I have to read up on it.
Further added an argument highlight to the applyGeshi function to identify file and line highlighting.
The line highlighting number is taken care internally it is only during file highlighting that the line numbers are missing.