Opened 13 years ago

Closed 8 years ago

#7441 closed enhancement (fixed)

notebook: make it possible to upload from the url of a published worksheet

Reported by: was Owned by: boothby
Priority: minor Milestone: sage-duplicate/invalid/wontfix
Component: notebook Keywords:
Cc: Merged in:
Authors: Reviewers: Karl-Dieter Crisman
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

>> I go to "upload", and try to upload a worksheet from url in a public
>> notebook --- so it's an https://... I guess that's why it fails (the
>> page itself is a published worksheet, so password is not required, but
>> I guess the upload can't pull a worksheet from an https url).
>
> Upload from a URL can't upload from a published worksheet that is
> published as http or https, actually.  It never occurred to me to
> implement that.  It's meant for uploading sws files, which might be
> sitting on the web somewhere.     Uploading from the URL of a
> published worksheet is an interesting idea.
>

+1 to this.  More than once, I've tried it, and found out again and
again that it didn't work.

 -- Jason

Attachments (2)

trac_7441_link_rel.patch (1.4 KB) - added by ddrake 12 years ago.
add <link rel="alternate"... stuff to published worksheets
trac_7441_upload.patch (6.6 KB) - added by ddrake 12 years ago.
add support to "upload a worksheet" page for parsing <link rel="alternate"... links

Download all attachments as: .zip

Change History (17)

comment:1 follow-up: Changed 12 years ago by ddrake

  • Report Upstream set to N/A

Let me add another +1 to this. It would make it much easier when teaching -- I write up a worksheet for an assignment, publish it, and then tell the students the URL. They log into their accounts, hit upload, paste in the URL, and they have the worksheet. As it stands, either I or my students needs to manually save the worksheet file somewhere and do something with it.

As a quick and dirty hack, I see that published worksheets have something like this in their html source:

  • Download.
  • ...so maybe, when given a url that does not end in .sws, the upload mechanism could just suck in the html source, look for the first hyperlink tag that resembles the above, and use that URL? I'm thinking a regex of <a href="download/.*\.sws"> or similar.

    Some kind of magic incantation in the html would also allow people to use random web pages as upload sources; imagine taking the URL of a blog post and putting into the upload box, and it automagically finds a .sws file to download. This could be the html version of the "embed a .sws file into a pdf" idea that has been discussed before.

    comment:2 in reply to: ↑ 1 Changed 12 years ago by ddrake

    Well, that's my "don't forget to use preview" lesson for today...

    Replying to ddrake:

    published worksheets have something like this in their html source:

    I meant to follow that with:

    <li><a href="download/blargle floomp.sws">Download.</a></li>
    

    comment:3 Changed 12 years ago by ddrake

    I think we can implement the "magic incantation" with something very simple, just like RSS autodiscovery. In the <head> of any HTML document that wishes to advertise a link to a related Sage worksheet, just put:

    <link rel="alternate" type="application/sage" title="the title of the worksheet"
          href="http://url.to.worksheet.sws">
    

    The "application/sage" mimics what the notebook server gives when downloading a worksheet from the "Download" link on a published worksheet. I don't know if that's a proper MIME type.

    More info: http://www.rssboard.org/rss-autodiscovery and http://www.w3schools.com/tags/tag_link.asp. The rel="alternate" specifies that the link is to an alternate version of the content, which is exactly what we want.

    We just need to put that link into published worksheets, and then get the "upload worksheet from URL" stuff to look for that link.

    RSS autodiscovery is well-established and works very well, so using the same mechanism for our own purposes seems like a good idea, and is very easy for anyone to use on any web page.

    Changed 12 years ago by ddrake

    add <link rel="alternate"... stuff to published worksheets

    Changed 12 years ago by ddrake

    add support to "upload a worksheet" page for parsing <link rel="alternate"... links

    comment:4 Changed 12 years ago by ddrake

    These two patches are a mostly-working implementation of these ideas. The "link_rel" patch simply adds the appropriate link into the head of published worksheets; the "upload" patch adds support to the "upload a worksheet" stuff so that it parses and downloads associated worksheets.

    Right now, however, it runs into a strange error that I don't understand. Try applying these patches, publishing a worksheet, and then using the worksheet's public URL in the upload box. You'll get a strange twisted error, the user's session will get messed up, but if you log back in, you'll see that the worksheet did get imported.

    (It's likely that it won't work at all with https URLs; we'll work on that later.)

    Any ideas?

    comment:5 follow-up: Changed 11 years ago by kcrisman

    • Status changed from new to needs_work

    #9875 turns out to be a dup of this request.

    It's not clear to me that the current patch deal with #9875, though. Dan, does the second patch also parse OLD published worksheets, and links in the form http://www.sagenb.org/home/pub/2423 (that is, the directory)? I assume that the first patch only will make it easier to upload html links on worksheets published *after* this patch is incorporated, not older published worksheets.

    Once you clarify that, we can probably close #9875 as a dup.

    comment:6 Changed 11 years ago by kcrisman

    • Authors set to Dan Drake

    comment:7 in reply to: ↑ 5 Changed 11 years ago by ddrake

    Replying to kcrisman:

    Dan, does the second patch also parse OLD published worksheets, and links in the form http://www.sagenb.org/home/pub/2423 (that is, the directory)? I assume that the first patch only will make it easier to upload html links on worksheets published *after* this patch is incorporated, not older published worksheets.

    That's correct. My intent here is to only affect worksheets published *after* these patches are put in. Users can always republish a worksheet to get the new stuff included in the published version.

    comment:8 Changed 11 years ago by ddrake

    Also, note that with the notebook rewrite, the bits that affect twist.py will have to be rewritten for the new Flask version of the notebook.

    comment:9 Changed 10 years ago by kcrisman

    Is this resolved by this github PR?

    comment:10 Changed 9 years ago by jdemeyer

    • Milestone changed from sage-5.11 to sage-5.12

    comment:11 Changed 8 years ago by vbraun_spam

    • Milestone changed from sage-6.1 to sage-6.2

    comment:12 Changed 8 years ago by vbraun_spam

    • Milestone changed from sage-6.2 to sage-6.3

    comment:13 Changed 8 years ago by vbraun_spam

    • Milestone changed from sage-6.3 to sage-6.4

    comment:14 Changed 8 years ago by kcrisman

    • Authors Dan Drake deleted
    • Milestone changed from sage-6.4 to sage-duplicate/invalid/wontfix
    • Reviewers set to Karl-Dieter Crisman
    • Status changed from needs_work to positive_review

    I can confirm this works now!

    comment:15 Changed 8 years ago by vbraun

    • Resolution set to fixed
    • Status changed from positive_review to closed
    Note: See TracTickets for help on using tickets.