Git Product home page Git Product logo

metaboutique's Introduction

La méta-boutique

This website is generated from data taken in this twitter thread.

Note: It's a (single-)week-end project, where I did NOT code with cleanliness in mind, so don't judge my way of writing code based on this :) It's not horrible, but if I thought there was to be serious maintenance, I'd change a lot of things :)

So how does it work:

  • The site is static (it's generated dynamically, but once the HTML is generated, it's the same for everyone, not recomputed per-request).
  • The front end uses Bulma, organized from their very nice starter kit and modified here and there.
  • The "back end" is a pure Python script that uses jinja2 and requests for the twitter API
  • In order to not do hundreds of API calls each time, and given most of the tweet data is immutable, a JSON file is kept, as a make-do-database

The script does the following

  • Load the JSON database in memory
  • Call the twitter API to know if new tweets should be added
  • Save it all in the database
  • Write the database back
  • Iterate on all tweets in the database
  • Extract meaningful data from those tweets. In particular, save the images locally.
  • Render the jinja template based on those pages

CI

When running in the CI, GitHub actions will then add the new database & image files to git and push it back to master, and publish the generated site to github pages.

Twitter API

A few words on "Call the twitter API to know if new tweets should be added". Twitter does not support getting replies of a tweet. The only thing it supports is:

  • Getting all the tweets linked to a thread from the last 7 days
  • Getting the parent tweet of a tweet.

The algorithm will recursively add the parent of a tweet until there is no parent. For now it only considers tweets from the original thread author. The initial DB was generated by providing a single tweet down the thread. As long as the CI runs more often than the 1 week API cutoff, all new tweets should be added here.

Patches

Some data comes out wrong from the algorithm, and rather than writing the perfect algrotihm, it's easier to just fix the data, so that's what we do. There's a function that manually fixes the DB.

Possible evolutions

  • Add a JS-based sort (by +-date, by random, ...)
  • Add tweets by other people when the original thread author has replied to them
  • Handle quote-tweets better

Legalese

  • License
  • All the data in data is public data taken from Twitter, and belongs to their respecive authors. If anything infringes on your rights, please contact me

metaboutique's People

Contributors

ewjoachim avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.