(!) Please read the toplevel page and this page completely before commenting.

Some users want to directly start the target item download when clicking on a link.

This will likely be possible, but it won't be the default, but needing some link parameter like [[target|label|&do=get]].

[Note: I had this problem (two step download of attachments, especially pdf, is confusing) and it took a lot of effort to find the &do=get solution, which is OK for me. There must be a better way to advertise this issue - I will put a question up pointing to here as a first step -- BoydBlackwell 2009-06-12 07:24:49]

Please improve HelpOnLinking e.g. add the example. A starting point is to read EditingOnMoinMaster. And finally remove the note from this page. -- ReimarBauer 2009-06-12 08:56:13

Reasons why &do=get can not be the default after we unified pages and attachments to items:

For a target item of type text/x-moin-wiki (wiki page), we obviously don't want to trigger the download of the page text, but get a rendered view of it as usual. Same thing applies for quite some other target mimetypes for which we have parsers (other markups, programming languages, diffs, CSV, etc.).

For some other target mimetypes, a direct download could make sense (like some word document for example, it is unlikely that we can ever render this). BUT: When rendering a page, we encounter quite some links (in navibar, in page content) and as we want to be rather fast, we have to be a bit careful about not needing to read too many target item metadata to do that.

Thus, if we would make the link target URL dependant on the link target mimetype, we would have to find out the mimetype of the target.

There are 2 ways to find out a target item mimetype:

  1. use the file name extension. Fast, but has many problems like:
    • some files don't have an extension: e.g. Makefile, or README or hosts or ...

      • you maybe don't want to add a .txt extension just to get the handling of these right

    • some extensions have multiple mimetypes using this extension (like .dot is used by Graphviz files as well as by MS Word).
    • on some systems, the system's mimetype map (e.g. /etc/mimes.type) is far from perfect. Can give headaches if there is no way for a wiki user to fix the mimetype if the magic goes wrong.

  2. we just store the mimetype of the item in its metadata (code for doing this is already implemented in new storage backend)
    • it can be either given on upload or autodetected once from extension if not given
    • in can be changed in case autodetection chose the wrong type
    • it is slow as we need to read item metadata to get this information
      • this doesn't matter for choosing the correct renderer for an item based on its mimetype [1 access and likely you need more/other metadata anyway]
      • but it does matter if you need it for rendering links to items [>20 accesses depending on page size])

Thus, we better avoid to need to know the target item mimetype for link rendering.

Thus, we can't do magic - all links need to be made in the same way.

Thus, this feature can't be implemented.

Assuming we get above "direct link / performance" stuff solved somehow, the next problem would be to decide what targets are linked to using the "show" url and what targets are linked to using "raw" url.

Problem: this depends on user agent's (browser's) capability and on what the user wants to do.

Note: it not necessarily depends on what wiki admin wants or page author wants.

Also, even if wiki admin or page author assumes that user just wants to download those file types, how do you rename, delete, revert a file?

If you just have a link that immediately starts a download, there is no way to show the user interface offering those actions for the target item.

Note: we likely won't have AttachFile-like managing code because attachments won't be contained in a page any more - thus the only "listing operation" we can do is "list all sub-items" (looking at their names). This operation will output "sub pages" as well as "sub files" (both are just sub items of different mimetypes).

Not wanted: directly serve files by the webserver

We had that already (until it was removed after years of deprecation in 1.7 or so).

It doesn't solve any problem, but creates some:

Maybe the theme code can solve this dilemma by having a "Link box" that has links for every link target used on that page:

       vvvvvvvvvvv link text, linked to rendering of target item
+---------------------+
| [DL] [OtherPage]    |
| [DL] [/SubPage]     |
| [DL] [/foo.doc]     |
| ...                 |
+---------------------+
  ^^^^ download/raw icon, linked to raw download of target item

??: subitems box

Similar to above, just listing all sub items.

We currently decorate all non-intrawiki links with a link item (globe icon for http links, disk icon for ftp links, terminal icon for ssh, interwiki icon for interwiki links, etc.).

We do no use decoration for intra-wiki links, but we could:

               vvvvvvvvvv linked to rendering of target item
This is a [DL] [LinkText] example.
          ^^^^ download/raw icon, linked to raw download of target item

User Expectations

Generally, when users see a link to something that looks like a file name, they expect to be able to use "standard" (ie, whatever their browser does) download functionality - click to download, right click and "save as" are common cases. The default behaviour proposed breaks this expectation (if I link to, say, a Python script, right click and "save as" won't download it, but rather a HTML page with a highlighted version).

Even if the default [[MyScript.py]] link points to the rendered page (I see the technical arguments in favour of this, but I'm not convinced yet that they outweigh the UI issues), then there needs to be a very simple and discoverable format for links which do go to the raw content ([[MyScript.py|MyScript.py|&do=get]] is neither intuitive nor discoverable). At the very least, a standard macro <<Download(MyScript.py)>> which renders exactly the same as [[MyScript.py|MyScript.py|&do=get]] would, should be provided. -- -- PaulMoore 2008-10-01 14:18:43

One other usability issue is that the URL used for the link should end in the filename to be downloaded. When doing a "save-as" operation, most browsers will use that as the default filename for the save. On one site I manage, I have lots of files that I need to publish URLs to externally. The current URL syntax is awkward, and makes downloading files difficult. -- Tim

Comments

Just some notes about some ideas I got last night about how to solve that dilemma.

Currently we talk always about the rendered view. May be we can think about to change the link behaviour in edit mode. If it is rendered we can have a download link and in edit mode it changes to the view link. For the gui editor this is I think not too complicated for the text editor we will need some kind of other ui to manage new subitems and the already used subitems.

We can also have an action which changes all the links on the given page. Doing this it does not matter if we have on default get behaviour for the one who likes to download only. Someone who wants to change versions of the items has to enter an action beforehand. That action can be nicely integrated into the theme.

e.g. a stupid one like this

   1 # -*- coding: iso-8859-1 -*-
   2 """
   3     ChangeLink
   4     renames virtual [[attachment:file.ext||&do=get]] to [[attachment:file.ext||&do=view]]
   5 
   6     @copyright: 2008 MoinMoin:ReimarBauer
   7     @license: GNU GPL, see COPYING for details.
   8 """
   9 from MoinMoin import config, wikiutil
  10 from MoinMoin.Page import Page
  11 from MoinMoin.parser.text_moin_wiki import Parser as WikiParser
  12 
  13 def execute(pagename, request):
  14     _ = request.getText
  15     msg = None
  16 
  17     if not request.user.may.read(pagename):
  18         msg = _("You are not allowed to view this page!")
  19 
  20     if msg:
  21         request.theme.add_msg(msg, state)
  22         Page(request, pagename).send_page()
  23         return
  24 
  25     request.formatter.page = Page(request, pagename)
  26     raw = Page(request, pagename).get_raw_body()
  27     # of course we need some regex from the parser here to handle attachment markup
  28     # that is just to show the idea
  29     raw = raw.replace('&do=get', '&do=view')
  30 
  31     html = wikiutil.renderText(request, WikiParser, raw)
  32 
  33     mimetype = "text/html"
  34     request.emit_http_headers(["Content-Type: %s; charset=%s" % (mimetype, config.charset)])
  35 
  36     request.theme.send_title(pagename,
  37                              pagename=pagename,
  38                              )
  39 
  40     request.write(request.formatter.startContent("content"))
  41 
  42     request.write(request.formatter.rawHTML(html))
  43     request.write(request.formatter.endContent())
  44     request.write(request.theme.send_footer(pagename))
  45     request.theme.send_closing_html()
ChangeLink.py

We have to think also how to get the item pages if every attachment on a wiki gets added the non default &get attribute.

-- ReimarBauer 2008-10-01 20:21:13

A further thought - if the link to a non-existent page (item) always goes to the same place, does that mean that the current "Create New Page" and attachment management pages will be merged somehow? I'm not sure what such a merged page will look like, but that needs to be very carefully thought out if it's to look sensible to a naive user ("Why am I being asked to upload a file? I just wanted to create a new page"). -- PaulMoore 2008-10-02 14:01:19

Paul: good comment! Yes, it will be about creating a new item then.

Because the item does not exist before, we don't know what it will be.

Currently (1.7) we offer to load the page editor with some template page. Looking at the generalization, that would mean for the future to load some template item somehow (not necessarily into some editor).

There has been some troubles/limitations with templates / the editor in the past:

So maybe we can solve this by not putting the template content into the editor, but into the initial item revision.

Using template items in this generalized way could be an easy way to initialize content and metadata without demanding too much from the user (we will likely have much more metadata than we have now).

Thus for nonexisting items, we could show:

For advanced users (beginners just use those templates):

(!) Item creation could be decoupled from the first edit / the upload - because it is good to know beforehand what type of thing we want to edit before we try to invoke some editor. Once the item is created, its mimetype metadata will likely have some reasonable value. If we render that (possibly empty) item, the user interface will adapt to that mimetype and offer appropriate actions for that item (like calling text or gui editor for wiki pages, only the text editor for text/creole pages [gui editor does not work for them yet!), and not offer any editor at all for application/zip, but just a upload button).

-- ThomasWaldmann 2008-10-02 16:40:10

Seems like every user of wiki which I administer is mad about this additional page and that it's not possible to do Save As. That's because we store a lot of .exe and .doc files. Got an idea of the following work-around: store somewhere (on some page or in config) a list of file extentions that should be downloaded directly. Then check this list of exceptions when rendering a page and replace 'view' with 'get'. This should do the trick... at least for my use case. -- AlexanderAgibalov 2008-11-18 14:22:02


With the next storage api everything in moin becomes an item.

items are stored dependent on their mimetype For further details see UnifyPagesAndAttachments

ReimarBauer: Thinks about browsers and items.

Browsers can't display every mimetype item. A user wants items to be displayed and not only downloaded. It is not expected that 3rd party browser plugins will solve this on any browser. The item needs to be displayed in the right context and not in an external tool. moin is a wiki software and not a file serving application. There are only a few builtin types for browsers e.g. some image types (png, gif, jpg) and markup (html) and plain (text) and since short time Scalable Vector Graphics (SVG). 3rd party browser plugins were written for various other mimetypes, If you look at /etc/mime-types "that" is a long list. And some of these are used also on the web.

ReimarBauer: Thinks about "What can we do?"

looks like we have to decide which type could be displayed in the context of the page. Only these can be used by transclusion syntax. All others can be only downloaded. Can we currently force users to choose the right mimetype if they want it used in the context of their wiki page without downloading it first? Currently we don't. I am not sure if we can at all. May be rather not. Only a few will get that we are between the devil and the deep blue sea. Sure we can, but did they like it?

ReimarBauer: "So what can we do?"

separate mimetypes into viewable (for translusion) and downloadable? converting downloadable mimetypes into viewable ones (snapshots) ? adding a placeholder (snapshot) into the page where the downloadable mimetype would be expected to be viewable ?

ReimarBauer: "Where can we look for converting?"

see also ConvertibleFormats

inkscape can convert a bunch of vector graphics format including pdf to svg.

Others?

(!) My thoughts about this:

-- ThomasWaldmann 2009-05-17 10:40:02

MoinMoin: UnifyPagesAndAttachments/Discussion (last edited 2009-06-12 08:56:13 by ReimarBauer)