Skip to content

Added line numbers in file detail view with ids for future styling.#157

Merged
k10blogger merged 5 commits intowebsvnphp:masterfrom
k10blogger:master
Feb 7, 2022
Merged

Added line numbers in file detail view with ids for future styling.#157
k10blogger merged 5 commits intowebsvnphp:masterfrom
k10blogger:master

Conversation

@k10blogger
Copy link
Copy Markdown
Member

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

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:
image

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.

@michael-o
Copy link
Copy Markdown
Member

This is fantastatic, I will happily review this next week.

Comment thread include/svnlook.php
Copy link
Copy Markdown
Member

@michael-o michael-o left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see two problems:

  1. Anchors aren't clickable, means hard to share
  2. 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?

@k10blogger
Copy link
Copy Markdown
Member Author

k10blogger commented Feb 6, 2022

I was wondering how to change the overall ids. Thanks for pointing that out.
Yes anchors are not clickable but we can jump to anchors as follows(example link):

http://localhost/websvn/filedetails.php?repname=Test+Group+1.Common+Model&path=%2Ftrunk%2FCFiles%2Fasm08.c#line-135

Using line-{line_number}

Comment thread include/svnlook.php Outdated
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');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attention, this does not only apply to the line, but to the entire geshi rendering.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
Yes this applies to all lines...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay... Changed to geshi.

Comment thread include/svnlook.php Outdated
$this->geshi->set_tab_width($this->repConfig->getExpandTabsBy());

if ($highlight == 'file') {
$this->geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS,1);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 1 doesn't add any benefit. It will just make every line bold.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

@michael-o michael-o Feb 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh okay. Anyways That is a topic for another PR. Completely dropped the 2nd argument.

Comment thread include/svnlook.php Outdated
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');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Comment thread include/svnlook.php
if ($highlight == 'file') {
$this->geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS,1);
$this->geshi->set_overall_id('line');
$this->geshi->enable_ids(true);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true is default value, you can drop it and use zero args.

Reanmed the id to match overall class 'geshi'
Comment thread include/svnlook.php
$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');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

@michael-o michael-o left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash

@k10blogger k10blogger merged commit 0bcd697 into websvnphp:master Feb 7, 2022
k10blogger added a commit that referenced this pull request Feb 7, 2022
@k10blogger
Copy link
Copy Markdown
Member Author

@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.

@michael-o
Copy link
Copy Markdown
Member

@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.

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.

3 participants