pedroborges / kirby-autogit

⬢ Saves every change made via Kirby Panel to a Git repository
149 stars 23 forks source link

Edge case: mp3 files deleted outside the panel #29

Closed fitzage closed 7 years ago

fitzage commented 7 years ago

Note: While I was in the midst of writing this, I answered my own question. I decided to file this issue anyway, though, in case someone else has a similar issue and wants a solution.

Solution: Added *.mp3 to my .gitignore file. Since I don't want the mp3 files in my repo at all, this is the perfect solution.


I have a bit of a unique situation and I'm trying to figure out how to make it work better with autogit.

Due to the fact that keeping all the mp3 files in the git repo made my church website repo unmanageably large (too big for github, couldn't easily push it to a new server because git couldn't handle pushing all of it at once), I have an upload script that runs in the background and pushes my mp3s to object storage after I upload them, then deletes them.

The problem is that now that I've enabled autogit, this ends up with an undesirable result:

  1. I upload the files in the panel, because I have a panel hook that renames them according to the page date and slug, making it easy to call the correct mp3 files from the template without having to store the name separately.
  2. Because I'm doing this in the panel, autogit picks up on them and adds them to the repo.
  3. Because an outside script deletes the files, autogit doesn't pick up on that (even if I then make other changes).
pedroborges commented 7 years ago

I laughing out loud because I did exactly that for my church website also. What a coincidence! Yes, adding *.mp3 to .gitignore was my solution as well. I'm glad you figure that out!

My workflow goes like, I fill in the basic sermon info on the panel: title, preacher, and scripture. Upload the MP3, a panel.file.upload hook checks if the file extension is *.mp3 then call a script that uses getID3 to set ID3 tags _(title, artist, album, year, genre, comment, copyright, and attachedpicture) on the audio file before uploading it to AWS S3. It finishes by removing the local audio file.

If you are interested I can share this script with you, Brother!

pedroborges commented 7 years ago

There's also a note about that on the Installation section on the readme:

In case there's anything inside the content that you don't want to commit, make sure to add it to .gitignore.

fitzage commented 7 years ago

Yeah, I saw that note and that's what maybe me realize "duh, I'm an idiot." Haha

fitzage commented 7 years ago

Ooh, adding ID3 tags is even cooler. Please share the script!

I'm using Joyent's manta service, which is why I ended up using an outside script instead of the upload hook to upload the files. I couldn't get it working otherwise. Now that I think about it, part of the reason I couldn't get it working was maybe not having the correct ssh keys in the apache user, but I don't know.

pedroborges commented 7 years ago

Here you go: https://gist.github.com/pedroborges/3364f7415684410e815ef74d8c2f6e8c

I did that almost two years ago so I hope I'm not forgetting any piece out. Feel free to ask any question 😉

fitzage commented 7 years ago

Very cool, thanks. Hopefully when I get to the S3 part I can pick that apart a bit and see how to implement Manta upload. There is a Composer-based PHP plugin for it, which I haven't yet figured out how to implement. Since that's what you're using, I might finally figure it out. :-)

fitzage commented 7 years ago

Where does the composer.json file go? Plugins folder?

fitzage commented 7 years ago

[I'm starting to think I might actually have to know something about Composer and how it interacts with Kirby to accomplish this, which may be too much.]

pedroborges commented 7 years ago

At first this was not a plugin made to be distributed so I just added the composer.json file to the project root (same level as index.php). After adding it you will need to run composer install.

fitzage commented 7 years ago

OK, wish me luck. :-)

pedroborges commented 7 years ago

If you need any help, let me know 😉

When I get some free time I want to make a plugin out of it including the podcast RSS generator part.

fitzage commented 7 years ago

I'm looking at the examples in the php-manta repo and thinking I just need to switch to S3. But so far, my manta usage is free so that's a nice thing.

https://github.com/joyent/php-manta

fitzage commented 7 years ago

I think I'll just switch to s3. I don't really need the fancy features from Manta, and it won't cost more than a couple bucks a month anyway.

pedroborges commented 7 years ago

I can't help with Manta.

S3 is really cheap, we have over 210 sermons added (with 3 new ones added each week) and pay < $1.50/month. Just make sure to apply good compression to your audio files.

fitzage commented 7 years ago

When I set up a download of all the files I currently have in Manta, it said 756. We have ~weekly sermons going back to 2006, as well as recordings of Sunday school classes. That all currently takes up 8.3 GB. Still, shouldn't be too expensive. We don't get that much traffic.

fitzage commented 7 years ago

Made a few tweaks to fit my specific needs, and it appears to be working perfectly.

I had an issue at first, and then realized I forgot to update the composer file again for S3 vs Manta.