Skip to content

📆 Sigarra Tools | An extension that makes the information system of the University of Porto slightly better.

License

Notifications You must be signed in to change notification settings

msramalho/SigTools

Repository files navigation

SigTools - Sigarra Tools

Sigarra on Steroids: export calendar events (timetables, events, book renewal, payments, ...); infinite scroll; export, filter and sort data-tables; statistical analysis on grades; library book renewal; configurable behaviour and more. SigToCa's heir

Install via:

Features

Most features are customizable and can be turned off in the options page.

Timetable Extractor

  • Personal schedule
  • Teacher schedule, try ... Ademar
  • Subject schedule, try ... RCOM
  • Any other schedule (from sigarra, not just feup) that respects the major formats found

Exams Extractor

  • Exams page, try ... MIEIC
  • Any other exams page (from sigarra, not just feup) that respects the major formats found

Moodle Extractor

  • Hover over a moodle event on the calendar and an option to add to Google Calendar (with One click) becomes available
  • Moodle already has functionality to export events in the iCal format here
- -

Datatables

Any Sigarra data-table is now:

  • exportable (copy-paste, csv, excel, pdf)
  • sortable by any column
  • searchable by a query box

Infinite Scroll

  • Any page that has paginated tables now has infinite scroll (example: search for MIEIC students)

Grades

  • Every time a teacher releases grades for a subject, you can go to that page and check statistics over your grades and how they compare with the rest of the students.

Bills

  • If you are fast enough, you can go to your 🏃running 💸account (Conta Corrente) and add those debts with their deadline to your calendar, so you don't forget to pay what you own (pagar o que deves)

Book Renewal

  • Never forget to return books again, by going to catalogo.up.pt and checking that you are not late on those, as it costs 0.50€ per day...

Exporting Calendar Events

SigTools exports to iCalendar .ics format which means most applications handle it pretty well, namely

Compatible Calendar Apps

  • Google Calendar
  • Apple Calendar
  • IBM Lotus Notes
  • Yahoo! Calendar
  • Evolution (software)
  • eM Client
  • Lightning extension for Mozilla Thunderbird and SeaMonkey
  • [partially] by Microsoft Outlook and Novell GroupWise

Performance

It was developed to be as non-intrusive as possible, requires minimal permissions, only executes processes when it needs to, and all the scripts are loaded after the pages are ready so as to minimize any interface performance impact!

Contribute to SigTools

You can contribute by:

  • Identifying and reporting issues
  • Fixing bugs - fork + branch + pull request
  • Adding more modules/extractors each module should address a different calendar need
  • Sharing this Extension
Contribution guide

Developing with gulp.js and npm

  1. fork project
  2. run npm install
  3. run npm run chrome-watch or npm run firefox-watch or npm run opera-watch during development
    1. the way to upload development extensions will vary depending on the browser see below
    2. point it to the correct folder that is maintained with live-reload inside the build/ folder
  4. run npm run build when ready for final tests followed by npm run zip to create all the zip files (this step is optional in PRs)
  5. pull-request once ready (do not include /build or /dist)
Load the extension in Chrome & Opera
  1. Open Chrome/Opera browser and navigate to chrome://extensions
  2. Select "Developer Mode" and then click "Load unpacked extension..."
  3. From the file browser, choose to my-slack-workspaces/build/chrome or (my-slack-workspaces/build/opera)
Load the extension in Firefox
  1. Open Firefox browser and navigate to about:debugging
  2. Click "Load Temporary Add-on" and from the file browser, choose my-slack-workspaces/build/firefox/manifest.json

Packaging

Run npm run build + npm run zip to create a zipped, production-ready extension for each browser (atm there seems to be a strange issue with npm run dist).

Code structure

  • extractors for all the scripts that extract information from a page and act accordingly
  • lib for external scripts
  • scripts for the JS scripts that are atomic or that are used for an html page
  • utils for functions that are reused among the extractors and other scripts

In the manifest.json file, in the content_scripts section, there is an initial match to load all the global scripts and then, for each page, each extractor is loaded.

Extractors code

class NewExtractor extends Extractor{
    constructor() {
        super();
        ...
        this.ready(); // this will trigger init and then attachIfPossible
    }
    //must implement: structure, attachIfPossible
    structure() { return {...} }
    attachIfPossible() {...}
    ...
}
// All the functions that are used by this script but do not
// belong to the class definition should follow the above line
...

By default, each extractor that inherits from Extractor already has the storage.boolean.apply and storage.text.exclude_urls_csv options.

The structure() method should return an object that describes the extractor, following this stub:

{
    extractor: "the name of the extractor", // must be unique among extractors
    description: "a simple description of what it does",
    parameters: [{//a list of the parameters that can be used ny users
            name: "name of the parameter",
            description: "either describe or exemplify"
        }
        //... other parameters
    ],
    storage: { // the variables to save for this extractor (in the local storage)
        text: [ //variables that should be displayed and edited in <input type="text">
            {
                name: "the name of the variable, eg: title",
                default: "The default value, eg: [${acronym}] - ${room.name}"
            }
        ],
        textarea: [ //variables that should be displayed and edited in <textarea></textarea>
            {
                name: "description",
                default: "another description - can have <strong>HTML</strong> inside"
            }
        ],
        boolean: [ //variables that should be displayed and edited in <input type="checkbox">
            {
                name: "isHTML",
                default: true
            }
        ]
    }
}

After developing a new extractor, it should be added to the options.html page as <script src="js/extractors/NAME.js"></script> next to the ones already there.

Tests

Testing a browser extension is hard. Nonetheless, we try. Tests are located in the test folder and we use mocha and chai along with some improvised magic.

To run tests open the tests.html file on the browser (we advise Live Server for VSCode), this was the only way as chrome extensions cannot be fully developed as ES6 modules, as of now. This system works fairly well.

To create a new test, check the previous ones. If you need to load html as the current jquery context (you will for every test with jquery selectors) you can do:

describe('what the test is about', function() {
    it('should return some results', function(done) {
        updatejQueryContext("new_context.html").then(() => {
            // your tests
            done()
        }).catch(done)
    })
})

or, for the context to be global:

describe('what the test is about', function() {
    before(() => {
        return new Promise((resolve)=>{
            updatejQueryContext("new_context.html").then(resolve)
        })
    })
    it('should return some results', function(done) {
        // your tests
    })
})
describe(...

After developing a new test, it should be added to the options.html page as <script src="test/extractors/NAME.js"></script> next to the ones already there.

Credits

A thanks to... ics.js | FileSaver.js | Blob.js | mustache | chart.js | math.js for saving us a lot of time!

Credits to Paomedia for the flat calendar icon!

Credits to Icons8 for services icons such as Office 365, Outlook, Google and Yahoo.

Changelog

  • V1.0
    • MVP, timetable + exams + mooodle
  • V1.1
    • Multiple exam tables on the same page support
  • V1.2
    • Fixed exam pages with wrong exam dates. Thanks to @G-Pereira
  • V1.3
    • Fixed problem in the encoding of html (both on the download and direct links). Thanks to @G-Pereira
  • V1.4
    • Fixed Timetable bug in the first occurrence of a subject that does not start at 8h30. Thanks to @sergioalmeida13
    • Fixed GMT problems in chrome import - by using ZULU time
    • Noticed that moodle extractor only has information on the day (and not time) of the event
  • V1.5
    • Adapted to sigarra's (fuzzy) way of using classes in tables for the exam extractor
    • Only display exam tables if they have at least one event
    • Make one-click link (for the timetable extractor) obey recurrence of events specified in the page (previously the event was non-recurring even if it actually was). Thanks to @sergioalmeida13
    • Icons have been properly defined in the manifest
  • V1.6
  • V1.7
    • Detection for overlapping classes in the timetable extractor. Thanks to @Dannyps
  • V1.8
    • Minor updates on the overlapping classes
    • One-click Outlook.com integration for all extractors 🎉 (only for non-beta Outlook). All props go to @fabiodrg666
    • .1 - bug fix in overlapping classes
  • V2.0
    • SigToCa -> SigTools
    • Complete refactor
    • Each extractor describes itself
    • Options page is dynamic and varies according to extractors
    • Simplified manifest
    • Better organization of scripts into folders
    • Started using mustache templates
    • Options page
    • Changelog page when installed or updated
  • V3.0
    • Improved Readme and contribution instructions
    • Started Unit Testing
    • Fixed UI bugs
    • Fixed non-minified JS files for mozilla chrome extension
    • Moodle 2019 is alive
    • Erasmus Datatables are working
    • Every extractor has "exclude pages" for custom pages where you don't want it
    • Every extractor has "apply" setting by default (boolean defaults to true)
    • Improved Contribution guidelines (extractors, tests, ...)
    • Mozilla problem with minified files
  • V3.1
    • Minimalist changelog page
    • Fixed exclude_urls_csv bug that disabled all extractors
    • Updates to satisfy Firefox's restrictions
  • V3.1.1
  • V3.1.2
    • Fixed Broken Grades #62
    • Fixed Bad Exam Acronym parsing #59
    • Handled Firefox Add-ons problems with 3rd party libraries...
  • V3.1.3
    • Fixed UI problem in "Conta corrente" page
  • V4.0.0
    • Revamp the way the extension is designed, introducing faster development and deployments with gulp.js
    • Fix issues that led the extension to be blocked on Firefox
  • V4.1.0
    • Documentation
    • Handle weird Microsoft encoding problem #83
    • Update the link for Outlook.com events #84
    • Fix URI encoding bug #85
  • V4.2.0
    • Improve the development environment
      • Disable the changelog so that the page is not shown everytime the extension is reloaded #87
      • Fix some bugs in gulp.js configuration #76, #87
      • Fix browsers blocking HTTP requests due to CORS in unit tests #93
      • Adding a logging mechanism that only works in development mode #102
      • Better mocking for extensions Storage API in unit tests
      • Add document mocking in unit tests #90
    • Fixes Outlook 'one-click' URLs (again) #111
    • Fixes custom recurring periods not affecting the event's start date #110
    • Enhance the DataTable extractor
      • Fix missing sorting arrows #79
      • Fix duplicated table headers #78
      • Support more tables by fixing their layout conservatively #93
    • New email extractor #99
      • It adds 'one-click' mailto links near all profiles find within current page
      • Supports 'batch email', where you can select multiple recipients
    • New extractor for exam supervisions #104
    • New extractor for pending bills with ATM details #118
    • Improve calendar events generation
      • Recurrence rules now also apply to 'one-click' events
      • Support custom locations (WIP) #51, #48
      • Support calendar status, i.e., show as Free vs Busy, in .ics #113
        • Deadline related extractors create events that show as Free by default (customisable!)
      • Support 'All Day' events on .ics and 'one-click'
        • Also useful for deadline/reminder events with no specific time
    • Revamp options page
      • Human readable extractors names
      • Add icons
      • Fix UI glitches