Extension talk:SimpleBatchUpload

About this board

Feature request: warning when navigating away from a page during file upload

1
Ammcgillivray (talkcontribs)

Large files can take a while to upload. It would be nice if there was an option to alert the user before leaving the page when in the middle of a file upload.

Thanks!!

Reply to "Feature request: warning when navigating away from a page during file upload"
Anrake (talkcontribs)

Thank you for the great extension.I have been using it with some templates for several years. Would it be possible to configure somewhere to resize images on upload? Thanks.

Reply to "resize on upload"

Not working with MW 1.38.4 and PHP 8.1.12

1
Summary by Kghbln

Tracked on GitHub with issue 51

91.11.113.131 (talkcontribs)

With the software mentioned above activating this extension only produces a blank wiki page.

Are there plans to update this extension?

Reply to "Not working with MW 1.38.4 and PHP 8.1.12"
Summary by Kghbln

Tracked on GitHub with issue 51

SSupur4555 (talkcontribs)

Fatal error: Uncaught Error: SimpleBatchUpload\SimpleBatchUpload::registerEarlyConfiguration(): Argument #1 ($targetConfiguration) cannot be passed by reference in C:\xampp\htdocs\wiki\extensions\SimpleBatchUpload\src\SimpleBatchUpload.php:42 Stack trace: #0 C:\xampp\htdocs\wiki\includes\registration\ExtensionRegistry.php(574): SimpleBatchUpload\SimpleBatchUpload::initCallback(Array) #1 C:\xampp\htdocs\wiki\includes\registration\ExtensionRegistry.php(258): ExtensionRegistry->exportExtractedData(Array) #2 C:\xampp\htdocs\wiki\includes\Setup.php(252): ExtensionRegistry->loadFromQueue() #3 C:\xampp\htdocs\wiki\includes\WebStart.php(93): require_once('C:\\xampp\\htdocs...') #4 C:\xampp\htdocs\wiki\index.php(44): require('C:\\xampp\\htdocs...') #5 {main} thrown in C:\xampp\htdocs\wiki\extensions\SimpleBatchUpload\src\SimpleBatchUpload.php on line 42

Reply to "Error"

Error in mediawiki 1.38

1
Christharp (talkcontribs)

addModules with non-array argument was deprecated in Mediawiki 1.38

Reply to "Error in mediawiki 1.38"

Notes on how to emulate file folders or upload files as "attachments" to pages

4
Revansx (talkcontribs)

It is common to want to document multiple projects that contain supporting files with very general filenames (like "readme.txt" or "image1.jpg", etc..). Most people use local file systems to organize and store their files using folders. This allows the file system to hold multiple versions of files with common filenames (like "readme.txt" or "image1.jpg", etc..) in different folders. The problem arises when one wishes to migrate these project file stores to a Mediawiki server. As Mediawiki uses a "flat" file system (meaning that all file names in the wiki must be unique), this means that there can be only one uploaded file named "readme.txt". This is problematic for sites that wish to use the wiki to store files from multiple project and multiple users.

The solution presented here is one that uses SimpleBatchUpload (and some other supporting extensions) to achieve the following goals:

  1. Enable users to upload files as "attachments" to a specific wiki article (i.e. Foo)
  2. Enable pages where files have been uploaded to query those files and display them in the page as the set of files that are "attached" to the page.

This effectively allows each wiki page to function as a traditional "file folder" might in a local file system.

Extension Used: We are using SimpleBatchUpload to provide "in-page" uploading of files with options for altering the filenames of upload files as well as creating new file pages with default text, but here are some other essential extensions need to make this all possible:

  • SMW - enables the use of semantics to store data in pages and provides the ability to queries the semantic data anywhere else in the wiki with inline queries
  • SRF - Adds additional types of SMW result formats providing a very wide range of display possibilities
  • SESP - makes intrinsic properties available to SMW
  • Variables - allows users to define and display variables in pages
  • MediaFunctions - provide access to file properties and file metadata of various media files

Here's how we do it:

First define a page variable called "PagePrefix" that is a concatenation of the wiki ID and the Page ID

{{#vardefine:PagePrefix|{{MediaWiki:SitePrefix}}{{PAGEID}}-}}

where {{MediaWiki:SitePrefix}} is a very short string like "MyWiki" (this just gives a reference to the wiki database that the page ID is in reference to)


Then add the batchupload function into a page with the "rename" option as follows:

{{#batchupload:Uploads|+rename= !^({{#var:PagePrefix}}[./+]*)?!iu -->{{#var:PagePrefix}}}}

The !^(@@@@@@@[./+]*)?!iu is a regex string the looks for files that already begin with "@@@@@@@" so that it does not prepend the same prefix again and again when uploading newer versions of an existing file.

When using the rename option, SimpleBatchUpload provides a textarea input box that allows the user to tailor the expression. For the way we are using this feature We personally don't like giving the users the opportunity to mess with regex and upload page text so we hide it from the users by including the following in our Mediawiki:Common.css

textarea#wfUploadDescription { display: none; visibility: hidden; }
label[for="wfUploadDescription"] { display: none; visibility: hidden; } 

We look forward to a day when the extension is updated to make it an option to display the SimpleBatchUpload parameters

Next note the "Uploads" parameter in the batchupload command, this adds the text {{Uploads}} to the uploaded files wiki page. You can develop the "Uploads" template to do lots of interesting things with Semantic Mediawiki or Cargo that will allow the file page to be querried elsewhere in the wiki (including the page where the file was uploaded).

In the page that includes the batchupload function we also add the following:

Page Has File Folder Size

{{#vardefine:HasFileFolderSize|{{#ask:[[Category:Uploads]][[~*{{#var:PagePrefix}}*]]|?Has file size#-|format=sum}}}}

Page Has Num Of Files

{{#vardefine:HasNumOfFiles|{{#ask:[[Category:Uploads]][[~*{{#var:PagePrefix}}*]]|format=count}}}}

Page has the following files:

{{#ask:[[Category:Uploads]][[~*{{#var:PagePrefix}}*]]
|?Has file size
|?Creation date
|?Modification date
|?Page author
|?MIME Type
|?Page creator
|?Has Description
|?Number of revisions
|?Has file ext
|format=template
|template=PagePrefix - Result Row
|introtemplate=PagePrefix - Result Top
|outrotemplate=PagePrefix - Result Bot
|userparam={{#var:PagePrefix}}
|link=none
|limit=200
|default=no files
}}

We often include the following note to the users:

To avoid filename duplications, files uploaded here will be given the prefix "{{#var:PagePrefix}}"

In the end, you can develop a very nice "file folder" system or "page attachment" system for your wiki that will make adoption of the wiki MUCH more intuitive and friendly for non-wiki minded people.

GregRundlett (talkcontribs)

This is a great write-up, and use-case thank you!

Revansx (talkcontribs)

@GregRundlett - Thanks! .. we're working on a MW File Folder Project page that documents the whole thing and include a link to an XML file of wiki pages that one can use to import all our pages at once and have the system running quickly. I'll link that page here when it's made.

InnerCitadel (talkcontribs)

Thanks for sharing. I've tried to replicate (unsuccessfully), would you mind sharing a few more details to make it fully work? What is in you Template:Uploads template. Do you put [[Category:Uploads]] ? What is in your other templates (page prefex templates)?

Reply to "Notes on how to emulate file folders or upload files as "attachments" to pages"

Could the description textarea / label be optional based on an argument?

1
Ammcgillivray (talkcontribs)

We have a system for uploading files that requires rigid control and do not want users to be able to change this. Can we have an argument to show / hide the display?

Thank you Ammcgillivray (talk) 20:12, 30 July 2021 (UTC)

Reply to "Could the description textarea / label be optional based on an argument?"

Feature request: Limit upload quantity for single upload button

2
Yochie92 (talkcontribs)

I would love to see a parameter similar to $wgSimpleBatchUploadMaxFilesPerBatch but for a specific instance of {{#batchupload:}} (e.g. "{{#batchupload:...|limit=5}}"). I know the extension is called SimpleBATCHUpload, but it would help for instances where we only expect a single file but still want the other (great) features of this extension like not having to name files, drag drop, no form to fill, template insertion, etc.

F.trott (talkcontribs)
Reply to "Feature request: Limit upload quantity for single upload button"
Regis May (talkcontribs)

I was quite surprised to learn that files are uploaded immediately as soon as you drag&drop files. This was all the more surprising as my first two uploads failed because of a CSRF token error (as the token has timed out already).

If this immediate upload behavior is intended, I'd expect it at least to be ...

  • documented on the MediaWiki extension description page and
  • even more important: documented on the special page <tt>Spezial:BatchUpload</tt> itself.

It is a good extension - thank you very much for that! But please explain the behavior so that users know what will happen if they use this extension.

Every single upload normally would be implemented with first providing the files, then submitting them. That's what users would expect. That's what they assume in the first place. It's okay if this extension differs from this expected behavior, but then please document it/explain it! ;-)

Nevertheless: Thank you again, nice extension!

F.trott (talkcontribs)

Well, it is called Simple for a reason. :)

But you may have a point. Could you add a note to the Extension's wiki page?

For adding the note to Spezial:BatchUpload you could raise an issue (or even a pull request) at https://github.com/ProfessionalWiki/SimpleBatchUpload

As a stop-gap measure, maybe you could customize the button text by changing the MediaWiki:Simplebatchupload-buttonlabel page in your wiki. Something like "Drop files for immediate upload". See Help:System message#Overriding messages on-wiki

Reply to "This is irritating"

id attribute on textarea makes the HTML invalid with multiple batch upload forms

1
Joeytje50 (talkcontribs)

With the change that implemented a textarea that allows you to customise the description for uploads, without needing to edit the page, the simple batch upload currently features an element with a non-unique id attribute. This makes the HTML invalid, which may cause unexpected behaviour when trying to run JavaScript applicable to #wfUploadDescription, since that id will be reused for every batch upload textarea.

The solution would be to simply remove the id attribute from the textarea, or to give the id a unique number, for example by keeping track of a counter variable within the extension.

Reply to "id attribute on textarea makes the HTML invalid with multiple batch upload forms"