Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Enhancement/Remove Django template inheritance from annotation pages #159
This pull request is a follow-up to #148 and moves the annotation pages to Vue single-file components. This change also fully decouples the Vue frontend for the annotation from the Django server by removing all usage of Django block-based template inheritance.
In the future, a separate refactor could further simplify the approach and remove Pug in favor of splitting the Vue components into smaller independent pieces and using slots for the content composition. This would be cleaner overall solution, but it would also be a much more invasive refactoring. In any case, I believe Pug is a good step in the right direction and will make these future refactorings easier since now all the templating code is in Vue. Having all the templating code in Vue also makes other efforts such as component re-use or testing much simpler. Alternatively, if the project decides that Pug offers value on its own due to its improved terseness over plain HTML templates, other Vue components could also be converted to Pug in the future to make the codebase more uniform.
The Pug approach demonstrated in this pull request can also be extended to the admin pages in Doccano, for example to replace the Django template inheritance on the upload and download screens, but I haven't tackled this yet.
Unfortunately the pull request diff is somewhat large, so please don't hesitate to reach out with questions or comments. However, most of the changes made were very mechanical and so the overall pull request should be low risk. See below for an outline of the refactoring approach. Steps 1-3 below are in commit d5bc9e4. Step 4 is commit bcfaad4.
In order to ensure that all Pug templates remain high quality going forward, I've also added a linter for Pug in commit ab473e3.