Opened 12 years ago

Closed 10 years ago

#7105 closed enhancement (fixed)

change search_doc and search_src so the links are opened in a new tab/window

Reported by: was Owned by: boothby
Priority: major Milestone: sage-4.7
Component: notebook Keywords:
Cc: Merged in: sage-4.7.alpha5
Authors: John Palmieri Reviewers: Karl-Dieter Crisman
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

One way would be to add target="_new" right before href="...".

The justification for this change is that currently after looking at the docs one hits the backbutton which results in a corrupted view of the worksheet (for now).

Attachments (1)

trac_7105-search.patch (2.3 KB) - added by jhpalmieri 10 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 12 years ago by jhpalmieri

I think another way would be to save the search results to a file -- format_search_as_html may already put things in the right format -- and open that file using

  from sage.misc.viewer import browser
  import os
  url = .. file name ...
  os.system(browser() + " " + url)

comment:2 Changed 12 years ago by was

Possibly good idea. I did something like this with "help(foo)", where it creates a link to a page that opens in a new browser.

comment:3 Changed 10 years ago by jhpalmieri

  • Authors set to John Palmieri
  • Report Upstream set to N/A
  • Status changed from new to needs_review

Here's a patch.

Changed 10 years ago by jhpalmieri

comment:4 Changed 10 years ago by jhpalmieri

By the way, according to this link, target="_blank" is preferable to target="_new". This fits with my experience, also.

comment:5 Changed 10 years ago by kcrisman

Oh, this is a great idea. I'll try to review it soon if no one else does.

comment:6 Changed 10 years ago by jhpalmieri

It only took a year and half to implement. Since the main part of the patch is the addition of 16 characters (the rest is modification to doctests), that's about one character per month...

comment:7 follow-up: Changed 10 years ago by kcrisman

  • Reviewers set to Karl-Dieter Crisman
  • Status changed from needs_review to positive_review

Okay, this looks okay and works. Definitely an improvement - I had never used the search much in the notebook because it just gave a list of files.

I have to say, I really don't like that it gives you the file. Getting the whole plot/plot.py isn't very useful! I mean, you can do a text search, but the command-line experience is much better than that.

comment:8 in reply to: ↑ 7 Changed 10 years ago by jhpalmieri

Replying to kcrisman:

I have to say, I really don't like that it gives you the file. Getting the whole plot/plot.py isn't very useful! I mean, you can do a text search, but the command-line experience is much better than that.

I'm trying to think of what else we could do. If you do "search_src", it opens up the source code, but there are no tags or any other way to navigate the resulting page. Maybe we could highlight the search terms somehow? This probably requires some javascript, about which I know basically nothing. If you do "search_doc", it opens up the html documentation, which has tags, and maybe we could jump to the tag nearest the first instance of the search terms. Another option for search_doc would be to defer to Sphinx's search, which highlights code and jumps to some instance (not necessarily the first, maybe the best match?).

comment:9 follow-up: Changed 10 years ago by kcrisman

I don't know why it can't literally return the output of search_src in the command line. Maybe because that's piped into less?

Well, in any case this is another ticket. No point turning this into the next ticket to nowhere.

comment:10 in reply to: ↑ 9 Changed 10 years ago by jhpalmieri

Replying to kcrisman:

I don't know why it can't literally return the output of search_src in the command line. Maybe because that's piped into less?

No, the command _format_search_as_html deliberately ignores multiple matches in the same file, along with the line numbers and the line containing each match -- it just uses the file name. The extra information is there, but it's discarded. I wonder if there's a good way to present it. Figure out a way to use javascript to open up a Python file to a specified line, and then give one link for each matching line? Also keep the current version as a more compact option?

Well, in any case this is another ticket. No point turning this into the next ticket to nowhere.

I agree, I'm just brainstorming.

comment:11 Changed 10 years ago by jdemeyer

  • Merged in set to sage-4.7.alpha5
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.