Closed heldinz closed 8 years ago
I agree that this plugin is the right home for this feature, and I'd be delighted to get a PR on this.
Yeah, we should do this with an INI file. There are some pretty brief docs at https://www.getlektor.com/docs/plugins/howto/#configure-plugins
; it looks like if we ask the user to have a config/s3.ini
file like you describe, then the S3Plugin
object can access the config just through self.get_config()
, which will be pretty tidy. I like that route. We'll have to document it loudly in the README.
I am not 100% sold on the layout for the config file that you have there; it uses the section headers of the INI format as data, which seems like it confuses things slightly and will make it hard to extend (like if people want to specify things with regular expressions, or something).
Here's another idea:
[rule-1]
extension=css
cache_control=public,max-age=259200
[rule-2]
extension=js
cache_control=public,max-age=259200
The downside is that this gives totally meaningless section headers, like 'rule-1', 'rule-2'. Eh. I'm not too thrilled with either way, but neither is, like, terrible; pick whichever you like (or choose a third, if you think of one that you prefer).
Ok, great. I'm working on a PR for this which should be ready start of next week due to some other commitments.
The plugin works great -- thanks! -- but we need a way to set Cache-Control headers on the files when (or immediately after) they're uploaded. I looked into a few different ways of doing this, for example as another plugin triggered from a custom event emitted from this plugin once the files are uploaded, but since the plugin itself doesn't do anything other than register the publisher, which is where all the logic is, that doesn't seem possible. And another plugin just to set the headers after upload via this project would end up duplicating a lot of code from here (for connecting to S3, listing the remote files etc.)
I'd be happy to make a PR if this was something you'd be willing to incorporate into this project. If so, how would you prefer to configure it? I was thinking of using a
.ini
file (s3.ini
?) with a section for each file extension I'm interested in, and then a setting for each header I want to set, e.g.