js thoughts widget
I wanted to have a way to post thoughts that were too short to merit their own posts (see here for examples).
I'm including two things here: the main script that goes on my site and the Python I use to update the script.
The HTML is simple: <div id="recentThoughts"></div>
on the page where I want the most recent thoughts and <div id="thoughtsIndex"></div>
on the page where I want the full thoughts index. Any HTML file including either will need a <script>
tag that calls the script.
Since I'm the only one who can modify it, I don't have to worry about anything complicated, like sanitizing inputs. Definitely don't use this code (or, at least, not only this code) for something to which other people, especially people you don't know, can contribute. Look, my guestbook is run off Google Sheets; I am not exactly killing it with the whole HTML user inputs thing.
javascript
python
This handles the date thing, so that adding a thought is as easy as running the Python script and answering the prompt with whatever text I want. It does the date/time for me and updates the Javascript file.
I have a longer update automation script of which this is only one part, but I think I've included all the bits it requires to run independently.
- tags
- projects