Page MenuHomePhabricator

Feature to download code block as text file
Open, LowPublic

Assigned To
None
Authored By
MarkTraceur
Aug 1 2012, 9:50 PM
Referenced Files
None
Tokens
"Like" token, awarded by scfc."Mountain of Wealth" token, awarded by Ricordisamoa.

Description

DokuWiki [0] has downloadable code blocks as a matter of course. It would be cool to have that in SyntaxHighlight.

My inkling is that there's very little work to do, since it would basically just be offering a link that would open a new window or so, and put in the new content (the content of the code block). I don't think there's anything complicated that needs to happen.

I'll look into this later this week maybe, but if anyone else wants to whack at it for a while, be my guest!

[0] https://www.dokuwiki.org/syntax#downloadable_code_blocks

Details

Reference
bz38932

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:50 AM
bzimport set Reference to bz38932.
bzimport added a subscriber: Unknown Object (MLST).

Note for later: This is for people on #octave, and the person who asked for it was carandraug+dev@gmail.com (no BZ account)

The DokuWiki link changed to https://www.dokuwiki.org/wiki:syntax#downloadable_code_blocks; for the use of Gists on blogs, cf. http://www.sandywalsh.com/2011/06/effective-units-tests-and-integration.html.

Some thoughts:

  • Some code blocks should be downloadable, some (snippets?) maybe not. I'd prefer the default to be downloadable.
  • There's always lots of drama with user-specified filenames on insecure browsers that MediaWiki fosters, so this needs to be checked.
  • Gists are saved server-side, DokuWiki seems to parse the page on every call which also means that the link may lead to updated (= different) content than shown. I haven't tried it, but data URIs should be performant, stable and supported by enough browsers.

Otherwise: Really cool! :-) In many cases, I just want to copy and paste bits of the code block, but often enough I'd like to save the lot and so far have to carefully maneuver the mouse pointer twice and then still face whitespace issues & Co.

(In reply to Tim Landscheidt from comment #2)

[...]

  • Gists are saved server-side, DokuWiki seems to parse the page on every

call which also means that the link may lead to updated (= different)
content than shown. I haven't tried it, but data URIs should be performant,
stable and supported by enough browsers.
[...]

data URIs work fine, but unfortunately do not bear a "filename", so for example Google Chrome wants to save all data URIs as "Download". So it's probably necessary to imitate Dokuwiki and parse the page again, probably cached.

Krinkle renamed this task from Downloadable code blocks (suggestion from IRC) to Feature to download code block as text file.Jan 5 2015, 1:00 PM
Krinkle updated the task description. (Show Details)
Krinkle removed a project: good first task.
Krinkle set Security to None.
Krinkle removed a subscriber: Unknown Object (MLST).

Mediawiki.org now has JS to copy code fragments. For example on https://www.mediawiki.org/wiki/Local_development_quickstart
using the gadget tpl-copy. https://www.mediawiki.org/wiki/MediaWiki:Gadget-site-tpl-copy.js

site[ResourceLoader|default|peers=site-styles|dependencies=mediawiki.util,ext.gadget.site-styles]|site.js|site-tpl-copy.js|site-tpl-copy.css

We could consider adding this into core