Sign in
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

  • This topic has 7 replies, 3 voices, and was last updated 2 weeks, 5 days ago by .
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #11543
    Avatar photob0fh

    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 photocandidexmedia

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

    #11654
    Avatar photob0fh

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

    Perhaps it can help someone: P4P (wip)

    #11655
    Avatar photocandidexmedia
    b0fh wrote:

    Perhaps it can help someone: P4P (wip)

    Nice! Are you the one who made this?

    #11681
    Avatar photostoptouchingme

    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 photob0fh
    candidexmedia wrote:
    b0fh wrote:

    Perhaps it can help someone: P4P (wip)

    Nice! Are you the one who made this?

    Yes, I did.

    stoptouchingme 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 photocandidexmedia
    b0fh 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 photob0fh
    candidexmedia wrote:
    b0fh 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.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.