Skip to content

Commit

Permalink
Added feature_flags and new keyboard_tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin-Byrne committed Nov 17, 2023
1 parent 3a131bb commit 5bdb9c9
Show file tree
Hide file tree
Showing 11 changed files with 2,906 additions and 1,990 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
## Dump Folder
_dump/

## Extras
_extras/

## Special Files
*.sublime-build

Expand Down
195 changes: 150 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![issues](https://img.shields.io/github/issues/Justin-Byrne/DeviantIO?style=flat-square)
![license](https://img.shields.io/github/license/Justin-Byrne/DeviantIO?style=flat-square)
<img src="https://img.shields.io/badge/Version-0.0.2-green?style=flat-square" />
<img src="https://img.shields.io/badge/Version-0.0.3-green?style=flat-square" />
<img src="https://img.shields.io/github/languages/code-size/Justin-Byrne/DeviantIO?style=flat-square" />

Additional functionality for Deviant Art
Expand All @@ -14,7 +14,8 @@ Additional functionality for Deviant Art
- [Gist](#gist)
- [Usage](#usage)
- [Hotkeys](#hotkeys)
- [Configuration](#configuration)
- [Feature Flags](#feature-flags)
- [General Configuration](#general-configuration)
- [Documentation](#documentation)
- [Support](#support)
- [Structure](#structure)
Expand Down Expand Up @@ -54,33 +55,93 @@ There's always a live gist for this project, in case you want to import this scr

## Usage

### HotKeys
### Hotkeys

| Input | Task | Mode |
| :--------------------------------: | ---------------------------------------- | :-------: |
| <kbd>Space</kbd>, <kbd>Enter</kbd> | Add Portrait to Favorites | Gallery |
| <kbd>Shift</kbd> | Add Deviant User to Watch List | Gallery |
| <kbd>←</kbd> | Previous Portrait | Gallery |
| <kbd>→</kbd> | Next Portrait | Gallery |
| <kbd>↑</kbd> | Back to Home or Profile | Gallery |
| <kbd>↓</kbd> | Redirect to randomized URL in config | Global |
| Input | Task | Mode |
| :----------------------------------------------- | ---------------------------------------- | :------: |
| <kbd>a</kbd>, <kbd>←</kbd> | Previous Portrait | Portrait |
| <kbd>d</kbd>, <kbd>→</kbd> | Next Portrait | Portrait |
| <kbd>w</kbd>, <kbd>↑</kbd> | Back to Home or Profile | Portrait |
| <kbd>q</kbd>, <kbd>Space</kbd>, <kbd>Enter</kbd> | Add Portrait to Favorites | Portrait |
| <kbd>e</kbd>, <kbd>Shift</kbd> | Add Deviant User to Watch List | Portrait |
| <kbd>f</kbd>, <kbd>Alt</kbd> | Toggle Portrait Expanse Mode | Portrait |
| <kbd>c</kbd>, <kbd>/</kbd>, <kbd>Command</kbd> | Open Artist's Gallery in New Tab | Portrait |
| <kbd>s</kbd>, <kbd>↓</kbd> | Redirect to randomized URL in `config` | Gallery |

### Configuration
<details>

<summary><b>Note:</b> Hotkeys are assignable under <code>_config.input_hotkeys</code></summary>

```Javascript
let _config =
{
input_hotkeys:
{
previous: [ "a", "left" ], // [Portrait Mode] : Hotkey(s) to go to the previous portrait
next: [ "d", "right" ], // [Portrait Mode] : Hotkey(s) to go to the next portrait
home: [ "w", "up" ], // [Portrait Mode] : Hotkey(s) to go to the main gallery page
favourite: [ "q", "space", "enter" ], // [Portrait Mode] : Hotkey(s) to add picture to favourites
watch: [ "e", "shift" ], // [Portrait Mode] : Hotkey(s) to add user to watch list
expand: [ "f", "alt" ], // [Portrait Mode] : Hotkey(s) to toggle portrait expanse mode
user: [ "c", "/", "command" ], // [Portrait Mode] : Hotkey(s) to open current artist's gallery
redirect: [ "s", "down" ] // [All Modes] : Hotkey(s) to open a new window with a random redirect; @see _config.redirect_urls
},
...
}
```

</details>

### Feature Flags

| Feature | Description | Default |
| :-------------------------------- | ----------------------------------------------------------------- | :-----: |
| Favourite to Next | Favouriting portrait will also cycle to the next portrait | `true` |
| Show Notification Favourite | Shows favourite notifications | `true` |
| Show Notification Favourite Stage | Shows favourite notification stage background as `accent_colour` | `true` |
| Show Notification Watch | Shows watch notifications | `true` |
| Show Status Favourite | Shows favourite status of favourited portraits | `true` |
| Skip Favourite | Skips already favourited portraits | `false` |
| Skip Watch | Skips portraits that you are not already watching | `false` |
| Skip Tier | Skips tier programs while cycling through portraits | `true` |

<details>

<summary><b>Note:</b> Feature flags are assignable under <code>_config.feature_flags</code></summary>

```Javascript
let _config =
{
... ,
feature_flags:
{
favourite_to_next: true, // [Portrait Mode] : Favouriting portrait will also cycle to the next portrait
show_notification_favourite: true, // [Portrait Mode] : Shows favourite notifications
show_notification_favourite_stage: true, // [Portrait Mode] : Shows favourite notification stage background as accent_colour: @see _config.internal_data.accent_colour
show_notification_watch: true, // [Portrait Mode] : Shows watch notifications
show_status_favourite: true, // [Gallery Mode] : Shows favourite status of favourited portraits
skip_favourite: false, // [Portrait Mode] : Skips already favourited portraits
skip_watch: false, // [Portrait Mode] : Skips portraits that you are not already watching
skip_tier: true, // [Portrait Mode] : Skips tier programs while cycling through portraits
},
...
}
```
</details>

### General Configuration

Configuration settings are accessible through the `_config` object

> You can view the current configurations through `DeviantIO.config`; via the console log
| Name | Type | Description |
| ----------------------- | --------- | ------------------------------------ |
| _config | `Object` | Main configurations object |
| _config.accent_colour | `string` | Favourited accent colour |
| _config.mousetrap_cdn | `string` | Mousetrap CDN address |
| _config.favorite_next | `boolean` | Go to next portrait after favoriting |
| _config.time_interval | `number` | How often to update this script |
| _config.url_reference | `string` | Present Deviant Art URL |
| _config.deviantarturl | `string` | Base Deviant Art URL |
| _config.input_hotkeys | `string` | Hotkey(s) for each keyboard task |
| Name | Type | Description |
| -------------------- | --------- | -------------------------------------------- |
| config | `Object` | Main configurations object |
| config.input_hotkeys | `Object` | Hotkey(s) associated with each keyboard task |
| config.feature_flags | `Object` | Various flags for features |
| config.redirect_urls | `Array` | Redirect URLs |
| config.internal_data | `Object` | General abstract data for program |

<details>

Expand All @@ -89,33 +150,76 @@ Configuration settings are accessible through the `_config` object
```Javascript
/**
* Main configuration settings
* @global
* @constant {Object} _config Main configurations object
* @param {string} _config.accent_colour Favourited accent colour
* @param {string} _config.mousetrap_cdn Mousetrap CDN address
* @param {boolean} _config.favorite_next Go to next portrait after favoriting
* @param {number} _config.time_interval How often to update this script
* @param {string} _config.url_reference Present Deviant Art URL
* @param {string} _config.deviantarturl Base Deviant Art URL
* @param {string} _config.input_hotkeys Hotkey(s) associated with each keyboard task; @see _keyboard_tasks
* @private
* @constant {Object} _config Main configurations object
* @param {Object} _config.input_hotkeys Hotkey(s) associated with each keyboard task; @see _keyboard_tasks
* @param {Object} _config.feature_flags Various flags for features
* @param {Array} _config.redirect_urls Redirect URLs
* @param {Object} _config.internal_data General abstract data for program
*/
let _config =
{
accent_colour: 'rgba(118, 228, 177, 1)',
mousetrap_cdn: '//cdnjs.cloudflare.com/ajax/libs/mousetrap/1.4.6/mousetrap.min.js',
favorite_next: true,
time_interval: 500,
url_reference: undefined, // Note: defined at runtime
deviantarturl: 'https://www.deviantart.com',
input_hotkeys:
{
favorite: [ "space", "enter" ],
watch: [ "shift" ],
previous: [ "left" ],
next: [ "right" ],
home: [ "up" ],
redirect: [ "down" ],
user: [ "/" ]
previous: [ "a", "left" ], // [Portrait Mode] : Hotkey(s) to go to the previous portrait
next: [ "d", "right" ], // [Portrait Mode] : Hotkey(s) to go to the next portrait
home: [ "w", "up" ], // [Portrait Mode] : Hotkey(s) to go to the main gallery page
favourite: [ "q", "space", "enter" ], // [Portrait Mode] : Hotkey(s) to add picture to favourites
watch: [ "e", "shift" ], // [Portrait Mode] : Hotkey(s) to add user to watch list
expand: [ "f", "alt" ], // [Portrait Mode] : Hotkey(s) to toggle portrait expanse mode
user: [ "c", "/", "command" ], // [Portrait Mode] : Hotkey(s) to open current artist's gallery
redirect: [ "r", "down" ] // [All Modes] : Hotkey(s) to open a new window with a random redirect; @see _config.redirect_urls
},
feature_flags:
{
favourite_to_next: true, // [Portrait Mode] : Favouriting portrait will also cycle to the next portrait
show_notification_favourite: true, // [Portrait Mode] : Shows favourite notifications
show_notification_favourite_stage: true, // [Portrait Mode] : Shows favourite notification stage background as accent_colour: @see _config.internal_data.accent_colour
show_notification_watch: true, // [Portrait Mode] : Shows watch notifications
show_status_favourite: true, // [Gallery Mode] : Shows favourite status of favourited portraits
skip_favourite: false, // [Portrait Mode] : Skips already favourited portraits
skip_watch: false, // [Portrait Mode] : Skips portraits that you are not already watching
skip_tier: true, // [Portrait Mode] : Skips tier programs while cycling through portraits
},
redirect_urls:
[
"https://google.com",
"https://gmail.com",
"https://github.com",
"https://trello.com"
],
internal_data:
{
accent_colour: 'rgba(118, 228, 177, 1)', // Favourited accent colour
time_interval: 500, // How often to update this script
url_reference: undefined, // Present Deviant Art URL; defined at runtime
deviantarturl: 'https://www.deviantart.com', // Base Deviant Art URL
mousetrap_cdn: '//cdnjs.cloudflare.com/ajax/libs/mousetrap/1.4.6/mousetrap.min.js', // Mousetrap CDN address
ui_data_hooks:
{
watch: "[data-hook='user_watch_button']", // Data hook for watch button
favourite: "[data-hook='fave_button']", // Data hook for favourite button
stage: "[data-hook='art_stage']", // Data hook for background art stage of Portraits
thumbs: "[data-hook='deviation_std_thumb']", // Data hook for Portrait thumbnails
user: "[data-hook='user_link']", // Data hook for user link
action: "[data-hook='action_bar']", // Data hook for action bar
meta: "[data-hook='deviation_meta']" // Data hook for deviation meta data
},
picture_rules:
{
off: // Rules for non-favourited elements
{
border: 'none',
boxShadow: 'none',
opacity: 1
},
on: // Rules for favourited elements
{
border: `2px solid %ACCENT_COLOUR%`,
boxShadow: `0px 0px 5px 2px %ACCENT_COLOUR%`,
opacity: 0.5
}
}
}
}
```
Expand All @@ -140,6 +244,7 @@ Please [open an issue](https://github.com/Justin-Byrne/DeviantIO/issues/new) for
│   └── watch.sh
├── docs
│   ├── CHANGELOG.md
│   ├── FUNDING.yml
│   └── JSDoc.md
├── script
│   ├── DeviantIO-min.js
Expand All @@ -152,4 +257,4 @@ Please [open an issue](https://github.com/Justin-Byrne/DeviantIO/issues/new) for

![Byrne-Systems](https://github.com/Justin-Byrne/DeviantIO/blob/main/images/cube_sm.png)

== Byrne-Systems © 2023 - All rights reserved. ==
= Byrne-Systems © 2023 - All rights reserved. =
48 changes: 35 additions & 13 deletions build/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ declare OUTPUT=${OUTPUT_DIRECTORY}/DeviantIO.js

## CACHE #########################################################

declare HEADER
declare PREAMBLE

declare FILE

Expand Down Expand Up @@ -83,7 +83,7 @@ main ()

function compile_master ()
{
update_master_js_file $INPUT
update_master_js_version $INPUT

echo "${PROMPT} ${FG_PINK}${VC_PACKAGE}.js Compiling Complete \t${FG_BLUE}[${OUTPUT}]${NOCOLOR}\n"

Expand All @@ -103,7 +103,7 @@ function compile_minified ()
fi
fi

update_minified_js_file $FILE_MIN
update_minified_js_preamble $FILE_MIN
}

function compile_readme ()
Expand All @@ -121,7 +121,7 @@ function compile_jsdoc ()
if command -v jsdoc2md
then
if $(jsdoc2md ${OUTPUT} > $OUTPUT_JSDOC)
then echo "\n${PROMPT} ${FG_PINK}API Complete \t\t\t${FG_BLUE}[${OUTPUT_JSDOC}]${NOCOLOR}\n"
then echo "\n${PROMPT} ${FG_PINK}JSDoc Complete \t\t\t${FG_BLUE}[${OUTPUT_JSDOC}]${NOCOLOR}\n"
else
NO_ERRORS=false
fi
Expand All @@ -135,28 +135,50 @@ function compile_jsdocs ()
if command -v jsdoc
then
if (jsdoc --private $OUTPUT -d $OUTPUT_JSDOCS)
then echo "\n${PROMPT} ${FG_PINK}JSDoc Complete \t\t\t${FG_BLUE}[${OUTPUT_JSDOCS}]${NOCOLOR}\n"
then echo "\n${PROMPT} ${FG_PINK}JSDocs Complete \t\t\t${FG_BLUE}[${OUTPUT_JSDOCS}]${NOCOLOR}\n"
else
NO_ERRORS=false
fi
fi
}

function compile_preamble ()
{
PREAMBLE="\/** \\n"
PREAMBLE+=" * ${VC_PACKAGE} - ${VC_BRIEF} \\n"
PREAMBLE+=" * Copyright (C) 2023 Justin D. Byrne \\n"
PREAMBLE+=" * \\n"
PREAMBLE+=" * This library is free software; you can redistribute it and\/or \\n"
PREAMBLE+=" * modify it under the terms of the GNU Library General Public \\n"
PREAMBLE+=" * License as published by the Free Software Foundation; either \\n"
PREAMBLE+=" * version 2 of the License, or (at your option) any later version. \\n"
PREAMBLE+=" * \\n"
PREAMBLE+=" * This library is distributed in the hope that it will be useful, \\n"
PREAMBLE+=" * but WITHOUT ANY WARRANTY; without even the implied warranty of \\n"
PREAMBLE+=" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU \\n"
PREAMBLE+=" * Library General Public License for more details. \\n"
PREAMBLE+=" * \\n"
PREAMBLE+=" * You should have received a copy of the GNU Library General Public \\n"
PREAMBLE+=" * License along with this library; if not, write to the \\n"
PREAMBLE+=" * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, \\n"
PREAMBLE+=" * Boston, MA 02110-1301, USA. \\n"
PREAMBLE+=" * \\n"
PREAMBLE+=" * Byrne-Systems, hereby disclaims all copyright interest in \\n"
PREAMBLE+=" * the library '${VC_PACKAGE}' (${VC_BRIEF}) written \\n"
PREAMBLE+=" * by Justin D. Byrne. ([email protected]) \\n"
PREAMBLE+=" *\/ \\n\\n"
}

## UPDATE ########################################################

function update_master_js_file ()
function update_master_js_version ()
{
sed -r -i '' -e 's/@version:.+/@version: '${VERSION}'/' ${1}
}

function update_minified_js_file ()
function update_minified_js_preamble ()
{
PREAMBLE="\/** \\n"
PREAMBLE+=" * @program: \t\t${VC_PACKAGE} \\n"
PREAMBLE+=" * @author: \t\tJustin D. Byrne \\n"
PREAMBLE+=" * @version: \t\t${VERSION} \\n"
PREAMBLE+=" * @license: \t\tGPL-2.0\\n"
PREAMBLE+=" *\/\\n\\n"
compile_preamble

sed -r -i '' -e 's/"use strict"/'${PREAMBLE}'"use strict"/' ${1}
}
Expand Down
Loading

0 comments on commit 5bdb9c9

Please sign in to comment.