Category: Uncategorized

  • Rebuilding LWT’s API, part 1

    Rebuilding LWT’s API, part 1

    Hey everyone, for the next release of LWT I have been working on a complete refactor of the AJAX API that will enhance both security and the development for the future versions of LWT!

    The Issue

    All AJAX files in LWT
    A glance at all the different AJAX files composing LWT before unification.

    As LWT was growing, so were the AJAX calls and without any control. In the end, LWT as of 2.8.0 harbored a collection of PHP files with different formats and standards, making the API difficult the expand and to understand.

    Architecture Design

    The first step to tackle the API proliferation was to understand the needs. To do so I had to force in some format standard, and I ended up with a list of all my endpoints:

    It features the following interaction:
      * On GET, ``action_type`` can be:
        * ``version``: the API version and release date.
        * ``test_next_word``: next word to test.
        * ``tomorrow_tests_number``: number of tests for the next day.
        * ``phonetic_reading``: phonetic reading of a text.
        * ``theme_path``: theming path for a file.
        * ``texts_statistics``: various words statistics for each text.
        * ``media_paths``: paths of files and folders in the ``/media`` folder.
        * ``example_sentences``: list of sentences containing a word.
        * ``imported_terms``: list of imported terms through terms upload.
        * ``similar_terms``: similar terms to a given term.
        * ``term_translations``: get the list of term translations to edit it's
        annotation.
      * On POST, ``action`` can be:
        * ``reading_position``: ``action_type`` set to ``text`` of ``audio`` change
        the reading position for a text or its audio.
        * ``change_translation``, with values for ``action_type`` set to:
          * ``add``: add a translation for a new word.
          * ``update``: edit the translation of an existing word.
        * ``term_status``, with values for ``action_type`` set to:
          * ``increment``: increment or decrement the status of a term by one unit.
          * ``set``: set the status of a term.
        * For any other value, set ``action_type`` to:
          * ``regexp``: test if the regular expression is correctly recognized
          (no more usage in code base?).
          * ``set_annotation``: change the annotation value for a term.
          * ``save_setting``: save a setting.

    On server side, I had moved from a file-by-file approach to a name-by-name query format. Still better, since I can now access all queries from one file, but not perfect. Moreover, all interactions are now in JSON and I now which script is accessing what.

    First returns

    Even if not finished, the new API had the following impacts:

    • During term test, the music can play fully and the page does not reload.
    • Less dubious content is send, now everything is JSON. The feeds feature were sending raw HTML and JS code, potentially armful for the user.
    • I have a list of the endpoints

    Now, the system was good, but I needed something more robust and standard. I opted for the REST standard, easy to implement and well documented. I will describe that in a later post, so stay tuned!

  • Maintaining LWT

    Maintaining LWT

    Hi there!

    In this post I’ll delve into a project which has taken a big part of my time for the last few months, the maintenance of an open-source language learning app: LWT.

    Original LWT logo

    LWT, standing for Learning With Texts, is a wonderful tool to learn text in your web browser, but it was quite abandoned 10 years ago, and it has not reached a larger audience since it was a bit difficult to use. So, I decided to blow the dust out of it, and started working on the GitHub community-maintained version. For those interested, the original project was posted at SourceForge.net.

    Basically, the target was to give the tool the audience it deserved. The main targets were:

    • Easy installation
    • Mobile compatibility
    • More secure

    Of course, many subquests came along the way, and I finished by doing much more than expected. In the end, it was a good introduction to full-stack development and project management as many things were to be done in a very short time. Now, I think that the project is much easier to maintain, so that independent developers can figure out how to do their own stuff without having a hard time understanding the code.

    Let’s talk a bit about the reason for which I started maintaining LWT. After I discovered LingQ, I found the tool very good, but also very expensive as many language learners are children. So, I decided to work on his open-source alter ego, LWT. Moreover, after spending time studying Japanese, I needed a robust tool to master the writing system, and reading books can turn out to be a pain if you cannot read words, let alone get the meaning.

    Another motivation was a personal challenge. I mostly did front-side development, and this was a much more ambitious full-stack project. I had no previous experience in PHP, or more generally, how a server internally works, so it was a good introduction to the domain. I could also try a new set of tools and utilities, which is why in my first commits things were a bit confused.

    Finally, I have been working on this project for almost a year now, and things are much better. I think I could tackle most of the urgent problems, and for the rest of the work, it will diverge from what LWT originally was and is much more related to where I want to go next. So stay tuned, as I may start on a successor for LWT from now on!

  • Launching the Display Cabinet!

    The purpose of this blog is to showcase some projects that can be of any interest to someone. I started doing it since I enjoyed starting new stuff, but when it was done it was falling to oblivion. Moreover, I do not have a lot of options for advertising GitHub projects for instance, so here is this blog to improve referencing.

    So, I hope you will enjoy going across the random projects of the Display Cabinet, and may you find something useful!

    Important Projects

    Here is a brief recap of the projects I present, or the one I would like to talk about:

    • LWT, standing for Learning With Texts. A web-based application to learn foreign languages based on reading.
    • LWT successor: not yet published, so can’t say much, see the GitHub post.
    • pylinkage: a linkage designer and simulator written in Python. View on PyPi and GitHub.
    • leggedsnake: A walking linkage (or “leg mechanism“) optimizer based on pylinkage. PyPi/GitHub.