Download
We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

Allow plugins to download assets

  • #11543
    Avatar photo[anonymous]

    Hello,

    I’m writing some plugins for Publii and I would like to give users the choice to either download the assets being used or include them from a CDN.

    Within beforeRender I successfully used https.get to download some files, but I couldn’t manage that the files would then be reliably copied by copyPluginFiles? (Promise, filehandle.sync, etc)

    Would it be possible to extend the plugin API to include an asset download function? I would be very grateful for that.

    /**
    * Download file to input/media/PLUGIN_NAME/
    */
    downloadFile (fileUrl, fileName, pluginInstance) // returns true or false

    #11643
    Avatar photo[anonymous]

    Out of curiosity: Are you referencing particular docs for plugin development?

    #11654
    Avatar photo[anonymous]

    As far as I know, there was no (official) documentation until just now.

    Perhaps it can help someone: P4P (wip)

    #11655
    Avatar photo[anonymous]
    [anonymous] wrote:

    Perhaps it can help someone: P4P (wip)

    Nice! Are you the one who made this?

    #11681
    Avatar photo[anonymous]

    off topic, but i just wanted to thank you @b0fh for respecting peoples privacy by not forcing a data-slurping CDN – i wish more developers did this

    #11683
    Avatar photo[anonymous]
    [anonymous] wrote:
    [anonymous] wrote:

    Perhaps it can help someone: P4P (wip)

    Nice! Are you the one who made this?

    Yes, I did.

    [anonymous] wrote:

    off topic, but i just wanted to thank you @b0fh for respecting peoples privacy by not forcing a data-slurping CDN – i wish more developers did this

    Thank you very much for your kind words.

    Will submit an issue later, so feel free to chat here.

    I wrote something, but unfortunately I can no longer find the request: Map view for tags (Example).
    No API key required and completely free (leaftletjs, osm, nominatim). 🤓

    I’m running out of time now, but I’ll rewrite the instructions later so that the assets are downloaded to the override directory.

    #11717
    Avatar photo[anonymous]
    [anonymous] wrote:

    I wrote something, but unfortunately I can no longer find the request: Map view for tags (Example).

    Oh, this is brilliant! Looking forward to seeing more of your work with Publii 🙂

    #11734
    Avatar photo[anonymous]
    [anonymous] wrote:
    [anonymous] wrote:

    I wrote something, but unfortunately I can no longer find the request: Map view for tags (Example).

    Oh, this is brilliant! Looking forward to seeing more of your work with Publii 🙂

    @candidexmedia

    Small update: I added the content before consent in the template, as shown in the example on P4P.