This module is used to display Dilbert comics from www.dilbert.com created by the great Scott Adams (@ScottAdamsSays). Despite limited functionality, the module has considerable configurability and comes with an autocorrect feature to ensure that the module can overcome any temporary networking hiccups that would otherwise require the mirror to be restarted to overcome.
Just an installation of Magic Mirror2 and a working internet connection.
- Run
git clone https://github.com/kjb085/MMM-Dilbert.git
in the directory~/MagicMirror/modules
- Run
npm install --production
to install the required dependencies - Add MMM-Dilbert to your config file
~/MagicMirror/config/config.js
{
module: "MMM-Dilbert",
position: "top_right",
config: {
...
}
}
config: {
headerType: 'title',
showTitleBelowImage: false,
}
Option | Default | Description |
---|---|---|
type |
'today' |
What day's Dilbert comic to display Options today , random |
headerType |
default |
Header display content defaulting "Daily Dilbert" or the comics title Note: If comic does not have a title, default will be displayed Options: default , title |
showHeader |
true |
Whether or not to display the hader |
showTitleBelowImage |
true |
Whether or not to display the comic's title below the comic Note: Not all comics have a title |
showRating |
true |
Show the star rating of the comic |
customStyles |
{} |
Custom CSS to be applied to elements of the module with style name written in camel case. Applicable elements: container , title , stars Example: { container: { maxHeight: 25vh }, title: { fontSize: 1em, color: '#af2f27' } } |
Option | Default | Description |
---|---|---|
updateHour |
3 |
At what hour the module should request a new comic from www.dilbert.com NOTE: New comics do not appear to be released at midnight EST, so I've set this default to 3am, which should be safe for most users to ensure the current day's comic is always displayed |
Option | Default | Description |
---|---|---|
updateInterval |
1 |
How frequently to update the comic displayed by the module in hours |
Option | Default | Description |
---|---|---|
autoCorrect |
true |
When this is set to true, the module will attempt to update more frequently if there's an error retrieving comic data from www.dilbert.com |
refreshPeriod |
2 |
How frequently to attempt to request valid comic data from the site in minutes |
autoCorrectAttemptLimit |
5 |
How many attempts to make before aborting auto correction and falling back to a default update state |
If you plan on modifying the existing code, these tools will be helpful as the the css was created using sass. Once you have npm installed, simply run npm install
for the subsequent npm packages to be installed.
- node-sass
- nodemon
Note: To make use of the installed packages run the below commands:
npm run build-css
to compile scss to css and runningnpm run watch-css
will watch the scss file for changes and compile on savenpm run compile-hb
to compile changes made to the html templatenpm run view-complete
to compile handlebars and build css from scss
There is no timeline or guarantee than any of these will be accomplished. Willing to review pull requests if anyone else wants to take these on.
- Write tests
- Add ability to cycle through user defined comics
- Explore taking this concept and create a generic web scraper module that allows complete configurability via a config