├── db └── .gitkeep ├── wsgi.py ├── cards-empty.db ├── .gitignore ├── cards-jwasham.db ├── config.txt ├── cards-jwasham-extreme.db ├── data ├── handle_old_schema.sql └── schema.sql ├── screenshots ├── cards_ui-1467754141259.png ├── memorize_ui-1467754306971.png └── memorize_code-1467754962142.png ├── entrypoint.sh ├── flash_cards.ini ├── docker-compose.yml ├── Dockerfile ├── flash_cards.service ├── requirements.txt ├── templates ├── createDb.html ├── listDb.html ├── editTag.html ├── login.html ├── cards.html ├── tags.html ├── show.html ├── edit.html ├── layout.html ├── memorize_known.html └── memorize.html ├── static ├── style.css ├── highlight-theme-github.css ├── general.js ├── fastclick.min.js └── highlight.pack.js ├── README.md ├── flash_cards.py └── license.md /db/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /wsgi.py: -------------------------------------------------------------------------------- 1 | from flash_cards import app 2 | 3 | if __name__ == "__main__": 4 | app.run() 5 | 6 | -------------------------------------------------------------------------------- /cards-empty.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localnerve/computer-science-flash-cards/main/cards-empty.db -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | py3env/ 3 | __pycache__/ 4 | *.pyc 5 | config-personal.txt 6 | cards.db 7 | env 8 | -------------------------------------------------------------------------------- /cards-jwasham.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localnerve/computer-science-flash-cards/main/cards-jwasham.db -------------------------------------------------------------------------------- /config.txt: -------------------------------------------------------------------------------- 1 | SECRET_KEY='some very long key here' 2 | USERNAME='username-test' 3 | PASSWORD='password-test' -------------------------------------------------------------------------------- /cards-jwasham-extreme.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localnerve/computer-science-flash-cards/main/cards-jwasham-extreme.db -------------------------------------------------------------------------------- /data/handle_old_schema.sql: -------------------------------------------------------------------------------- 1 | create table if not exists tags ( 2 | id integer primary key autoincrement, 3 | tagName text not null 4 | ); -------------------------------------------------------------------------------- /screenshots/cards_ui-1467754141259.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localnerve/computer-science-flash-cards/main/screenshots/cards_ui-1467754141259.png -------------------------------------------------------------------------------- /screenshots/memorize_ui-1467754306971.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localnerve/computer-science-flash-cards/main/screenshots/memorize_ui-1467754306971.png -------------------------------------------------------------------------------- /screenshots/memorize_code-1467754962142.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/localnerve/computer-science-flash-cards/main/screenshots/memorize_code-1467754962142.png -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -f /src/db/cards.db ]; then 4 | cp cards-empty.db /src/db/cards.db 5 | fi 6 | 7 | export CARDS_SETTINGS=/src/config.txt 8 | gunicorn --bind 0.0.0.0:8000 flash_cards:app -------------------------------------------------------------------------------- /flash_cards.ini: -------------------------------------------------------------------------------- 1 | [uwsgi] 2 | module = wsgi:app 3 | 4 | master = true 5 | processes = 5 6 | 7 | socket = flash_cards.sock 8 | chmod-socket = 660 9 | vacuum = true 10 | 11 | die-on-term = true 12 | 13 | 14 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | 5 | cs-flash-cards: 6 | build: . 7 | ports: 8 | - 8000:8000 9 | volumes: 10 | - ./cards-empty.db:/src/db/cards.db 11 | # - ./cards-jwasham-extreme.db:/src/db/cards.db 12 | # - ./cards-jwasham.db:/src/db/cards.db 13 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.9 2 | LABEL maintainer="Tinpee " 3 | 4 | ADD . /src 5 | WORKDIR /src 6 | RUN pip install --upgrade pip \ 7 | && pip install flask gunicorn 8 | 9 | COPY entrypoint.sh / 10 | RUN sed -i 's/\r$//' /entrypoint.sh 11 | RUN chmod +x /entrypoint.sh 12 | 13 | VOLUME /src/db 14 | 15 | EXPOSE 8000 16 | CMD ["/entrypoint.sh"] 17 | -------------------------------------------------------------------------------- /data/schema.sql: -------------------------------------------------------------------------------- 1 | -- drop table if exists cards; 2 | create table cards ( 3 | id integer primary key autoincrement, 4 | type tinyint not null, /* 1 for vocab, 2 for code */ 5 | front text not null, 6 | back text not null, 7 | known boolean default 0 8 | ); 9 | 10 | create table tags ( 11 | id integer primary key autoincrement, 12 | tagName text not null 13 | ); 14 | -------------------------------------------------------------------------------- /flash_cards.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=uWSGI instance to serve flash_cards 3 | After=network.target 4 | 5 | [Service] 6 | User=john 7 | Group=www-data 8 | WorkingDirectory=/var/www/cs_flash_cards 9 | Environment="PATH=/var/www/cs_flash_cards/py3env/bin" 10 | Environment="CARDS_SETTINGS=/var/www/cs_flash_cards/config-personal.txt" 11 | ExecStart=/var/www/cs_flash_cards/py3env/bin/uwsgi --ini flash_cards.ini 12 | 13 | [Install] 14 | WantedBy=multi-user.target -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | boto==2.40.0 2 | click==6.7 3 | configparser==3.5.0 4 | cryptography==43.0.1 5 | enum34==1.1.6 6 | Flask==2.3.2 7 | future==0.18.3 8 | httplib2==0.19.0 9 | ipaddress==1.0.16 10 | itsdangerous==0.24 11 | Jinja2==3.1.4 12 | jsonschema==2.5.1 13 | lockfile==0.12.2 14 | MarkupSafe==0.23 15 | ndg-httpsclient==0.4.2 16 | psutil==5.6.6 17 | pyasn1==0.1.9 18 | pycurl==7.43.0 19 | pyOpenSSL==17.5.0 20 | pytz==2016.10 21 | pyxdg==0.26 22 | requests==2.32.0 23 | scour==0.32 24 | six==1.10.0 25 | virtualenv==15.1.0 26 | Werkzeug==3.0.3 27 | -------------------------------------------------------------------------------- /templates/createDb.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% block body %} 3 | 4 |
5 |

Init database

6 |
7 |
8 | 9 | 10 |
11 |
12 | 13 |
14 |
15 |
16 | 17 | {% endblock %} 18 | -------------------------------------------------------------------------------- /templates/listDb.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% block body %} 3 | 4 | 5 | {% for db in dbs %} 6 | 7 | 10 | 15 | 16 | {% else %} 17 | 18 | 21 | 22 | {% endfor %} 23 |
8 | Load 9 | 11 |

12 | {{ db }} 13 |

14 |
19 | No dbs to show. 20 |
24 | 25 | {% endblock %} -------------------------------------------------------------------------------- /templates/editTag.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% block body %} 3 |
4 |

Edit Tag #{{ tag.id }}

5 |
6 |
7 | 8 | 9 |
10 | 11 |
12 |
13 | 14 | 15 |
16 |
17 |
18 | {% endblock %} 19 | -------------------------------------------------------------------------------- /static/style.css: -------------------------------------------------------------------------------- 1 | .toggleSelected { 2 | background-color: #62b06b; 3 | color: #ffffff; 4 | } 5 | 6 | textarea { 7 | font-family: monospace; 8 | } 9 | 10 | .cardContent .tagContent h4 { 11 | margin-top: 0; 12 | } 13 | 14 | .alignContainer { 15 | display: table; 16 | width: 100%; 17 | } 18 | 19 | .alignMiddle { 20 | height: 20em; 21 | display: table-cell; 22 | vertical-align: middle; 23 | } 24 | 25 | .cardBack { 26 | display: none; 27 | } 28 | 29 | .largerText { 30 | font-size: 2em; 31 | } 32 | 33 | 34 | /* disables collapsing header menu */ 35 | 36 | .navbar-collapse.collapse { 37 | display: block!important; 38 | } 39 | 40 | .navbar-nav>li, .navbar-nav { 41 | float: left !important; 42 | } 43 | 44 | .navbar-nav.navbar-right:last-child { 45 | margin-right: 0 !important; 46 | } 47 | 48 | .navbar-right { 49 | float: right!important; 50 | } -------------------------------------------------------------------------------- /templates/login.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% block body %} 3 |

Login

4 | {% if error %} 5 | 6 | {% endif %} 7 | 8 |
9 |
10 |
11 | 12 | 13 |
14 |
15 | 16 | 17 |
18 |
19 | 20 |
21 |
22 |
23 | {% endblock %} -------------------------------------------------------------------------------- /templates/cards.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% block body %} 3 | 4 |
5 |

Add a Card

6 |
7 |
8 | {% for tag in tags %} 9 | 12 | {% endfor %} 13 |
14 |
15 | 16 | 17 |
18 |
19 | 20 | 25 |
26 |
27 | 28 |
29 |
30 |
31 | 32 | 35 | 36 | {% endblock %} 37 | -------------------------------------------------------------------------------- /templates/tags.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% block body %} 3 | 4 |
5 |

Add a Tag

6 |
7 |
8 | 9 | 10 |
11 |
12 | 13 |
14 |
15 |
16 | 17 | 20 |
21 |
22 | 23 | 24 | {% for tag in tags %} 25 | 26 | 29 | 34 | 35 | {% else %} 36 | 37 | 40 | 41 | {% endfor %} 42 |
27 | 28 | 30 |

31 | {{ tag.tagName }} 32 |

33 |
38 | No tags to show. 39 |
43 | 44 | {% endblock %} 45 | -------------------------------------------------------------------------------- /static/highlight-theme-github.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | github.com style (c) Vasily Polovnyov 4 | 5 | */ 6 | 7 | .hljs { 8 | display: block; 9 | overflow-x: auto; 10 | padding: 0.5em; 11 | color: #333; 12 | background: #f8f8f8; 13 | } 14 | 15 | .hljs-comment, 16 | .hljs-quote { 17 | color: #998; 18 | font-style: italic; 19 | } 20 | 21 | .hljs-keyword, 22 | .hljs-selector-tag, 23 | .hljs-subst { 24 | color: #333; 25 | font-weight: bold; 26 | } 27 | 28 | .hljs-number, 29 | .hljs-literal, 30 | .hljs-variable, 31 | .hljs-template-variable, 32 | .hljs-tag .hljs-attr { 33 | color: #008080; 34 | } 35 | 36 | .hljs-string, 37 | .hljs-doctag { 38 | color: #d14; 39 | } 40 | 41 | .hljs-title, 42 | .hljs-section, 43 | .hljs-selector-id { 44 | color: #900; 45 | font-weight: bold; 46 | } 47 | 48 | .hljs-subst { 49 | font-weight: normal; 50 | } 51 | 52 | .hljs-type, 53 | .hljs-class .hljs-title { 54 | color: #458; 55 | font-weight: bold; 56 | } 57 | 58 | .hljs-tag, 59 | .hljs-name, 60 | .hljs-attribute { 61 | color: #000080; 62 | font-weight: normal; 63 | } 64 | 65 | .hljs-regexp, 66 | .hljs-link { 67 | color: #009926; 68 | } 69 | 70 | .hljs-symbol, 71 | .hljs-bullet { 72 | color: #990073; 73 | } 74 | 75 | .hljs-built_in, 76 | .hljs-builtin-name { 77 | color: #0086b3; 78 | } 79 | 80 | .hljs-meta { 81 | color: #999; 82 | font-weight: bold; 83 | } 84 | 85 | .hljs-deletion { 86 | background: #fdd; 87 | } 88 | 89 | .hljs-addition { 90 | background: #dfd; 91 | } 92 | 93 | .hljs-emphasis { 94 | font-style: italic; 95 | } 96 | 97 | .hljs-strong { 98 | font-weight: bold; 99 | } 100 | -------------------------------------------------------------------------------- /templates/show.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% block body %} 3 | 4 | 7 |
8 | all 9 | {% for tag in tags %} 10 | {{tag.tagName}} 11 | {% endfor %} 12 | known 13 | unknown 14 |
15 | 16 |
17 |
18 | 19 | 20 | {% for card in cards %} 21 | 22 | 25 | 35 | 36 | {% else %} 37 | 38 | 41 | 42 | {% endfor %} 43 |
23 | 24 | 26 |

27 | {{ card.front }} 28 |

29 | {% if card.type == 1 %} 30 | {{ card.back|replace("\n", "
")|safe }} 31 | {% else %} 32 |
{{ card.back|escape }}
33 | {% endif %} 34 |
39 | No cards to show. 40 |
44 | 45 | {% endblock %} 46 | -------------------------------------------------------------------------------- /static/general.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function(){ 2 | if ($('.memorizePanel').length != 0) { 3 | 4 | $('.flipCard').click(function(){ 5 | if ($('.cardFront').is(":visible") == true) { 6 | $('.cardFront').hide(); 7 | $('.cardBack').show(); 8 | } else { 9 | $('.cardFront').show(); 10 | $('.cardBack').hide(); 11 | } 12 | }); 13 | } 14 | 15 | if ($('.cardForm').length != 0) { 16 | 17 | $('.cardForm').submit(function(){ 18 | 19 | var frontTrim = $.trim($('#front').val()); 20 | $('#front').val(frontTrim); 21 | var backTrim = $.trim($('#back').val()); 22 | $('#back').val(backTrim); 23 | 24 | if (! $('#front').val() || ! $('#back').val()) { 25 | return false; 26 | } 27 | }); 28 | } 29 | 30 | if ($('.editPanel').length != 0) { 31 | 32 | function checkit() { 33 | var checkedVal = $('input[name=type]:checked').val(); 34 | var checkedId = $('input[name=type]:checked').attr("id"); 35 | if (checkedVal === undefined) { 36 | // hide the fields 37 | $('.fieldFront').hide(); 38 | $('.fieldBack').hide(); 39 | $('.saveButton').hide(); 40 | } else { 41 | $('.toggleButton').removeClass('toggleSelected'); 42 | 43 | if(checkedId === undefined) { 44 | $(this).addClass('toggleSelected'); 45 | } else { 46 | $('label[for='+ checkedId +']').addClass('toggleSelected'); 47 | } 48 | 49 | $('.fieldFront').show(); 50 | $('.fieldBack').show(); 51 | $('.saveButton').show(); 52 | } 53 | } 54 | 55 | $('.toggleButton').click(checkit); 56 | 57 | checkit(); 58 | } 59 | 60 | // to remove the short delay on click on touch devices 61 | FastClick.attach(document.body); 62 | }); 63 | -------------------------------------------------------------------------------- /templates/edit.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% block body %} 3 |
4 |

Edit Card #{{ card.id }}

5 |
6 | 7 |
8 | {% for tag in tags %} 9 | 13 | {% endfor %} 14 | 15 | 22 |
23 |
24 | 25 | 26 |
27 |
28 | 29 | 34 |
35 |
36 |
37 |
38 | 42 |
43 |
44 | 50 |
51 | 52 |
53 |
54 | 55 | 56 |
57 |
58 |
59 | {% endblock %} 60 | -------------------------------------------------------------------------------- /templates/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CS Flash Cards 5 | 6 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 |
16 | 17 |
18 | 39 | 40 | {% for message in get_flashed_messages() %} 41 | 42 | {% endfor %} 43 | {% block body %}{% endblock %} 44 |
45 |
46 |
47 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /templates/memorize_known.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% block body %} 3 | 4 |
5 |
6 |
7 | {% for tag in tags %} 8 | {{tag.tagName}} 9 | {% endfor %} 10 |
11 |
12 |
13 | 14 |
15 | 16 |
17 |
18 |
19 |
20 |
21 |
22 |

{{ card.front }}

23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | {% if card.type == 1 %} 32 | {% if short_answer %} 33 |
34 | {% endif %} 35 | {{ card.back|replace("\n", "
")|safe }} 36 | {% if short_answer %} 37 |
38 | {% endif %} 39 | {% else %} 40 |
{{ card.back|escape }}
41 | {% endif %} 42 |
43 |
44 |
45 |
46 |
47 |
48 | 49 |
50 | 68 |
69 |
70 | 80 |
81 | 82 | {% endblock %} 83 | -------------------------------------------------------------------------------- /templates/memorize.html: -------------------------------------------------------------------------------- 1 | {% extends "layout.html" %} 2 | {% block body %} 3 | 4 |
5 |
6 |
7 | {% for tag in tags %} 8 | {{tag.tagName}} 9 | {% endfor %} 10 |
11 |
12 |
13 | 14 |
15 | 16 |
17 | 28 |
29 |
30 |
31 |
32 |
33 |

{{ card.front }}

34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | {% if card.type == 1 %} 43 | {% if short_answer %} 44 |
45 | {% endif %} 46 | {{ card.back|replace("\n", "
")|safe }} 47 | {% if short_answer %} 48 |
49 | {% endif %} 50 | {% else %} 51 |
{{ card.back|escape }}
52 | {% endif %} 53 |
54 |
55 |
56 |
57 |
58 | 69 |
70 | 71 |
72 | 90 |
91 |
92 | 102 |
103 | 104 | {% endblock %} 105 | -------------------------------------------------------------------------------- /static/fastclick.min.js: -------------------------------------------------------------------------------- 1 | !function(){"use strict";function t(e,o){function i(t,e){return function(){return t.apply(e,arguments)}}var r;if(o=o||{},this.trackingClick=!1,this.trackingClickStart=0,this.targetElement=null,this.touchStartX=0,this.touchStartY=0,this.lastTouchIdentifier=0,this.touchBoundary=o.touchBoundary||10,this.layer=e,this.tapDelay=o.tapDelay||200,this.tapTimeout=o.tapTimeout||700,!t.notNeeded(e)){for(var a=["onMouse","onClick","onTouchStart","onTouchMove","onTouchEnd","onTouchCancel"],c=this,s=0,u=a.length;u>s;s++)c[a[s]]=i(c[a[s]],c);n&&(e.addEventListener("mouseover",this.onMouse,!0),e.addEventListener("mousedown",this.onMouse,!0),e.addEventListener("mouseup",this.onMouse,!0)),e.addEventListener("click",this.onClick,!0),e.addEventListener("touchstart",this.onTouchStart,!1),e.addEventListener("touchmove",this.onTouchMove,!1),e.addEventListener("touchend",this.onTouchEnd,!1),e.addEventListener("touchcancel",this.onTouchCancel,!1),Event.prototype.stopImmediatePropagation||(e.removeEventListener=function(t,n,o){var i=Node.prototype.removeEventListener;"click"===t?i.call(e,t,n.hijacked||n,o):i.call(e,t,n,o)},e.addEventListener=function(t,n,o){var i=Node.prototype.addEventListener;"click"===t?i.call(e,t,n.hijacked||(n.hijacked=function(t){t.propagationStopped||n(t)}),o):i.call(e,t,n,o)}),"function"==typeof e.onclick&&(r=e.onclick,e.addEventListener("click",function(t){r(t)},!1),e.onclick=null)}}var e=navigator.userAgent.indexOf("Windows Phone")>=0,n=navigator.userAgent.indexOf("Android")>0&&!e,o=/iP(ad|hone|od)/.test(navigator.userAgent)&&!e,i=o&&/OS 4_\d(_\d)?/.test(navigator.userAgent),r=o&&/OS [6-7]_\d/.test(navigator.userAgent),a=navigator.userAgent.indexOf("BB10")>0;t.prototype.needsClick=function(t){switch(t.nodeName.toLowerCase()){case"button":case"select":case"textarea":if(t.disabled)return!0;break;case"input":if(o&&"file"===t.type||t.disabled)return!0;break;case"label":case"iframe":case"video":return!0}return/\bneedsclick\b/.test(t.className)},t.prototype.needsFocus=function(t){switch(t.nodeName.toLowerCase()){case"textarea":return!0;case"select":return!n;case"input":switch(t.type){case"button":case"checkbox":case"file":case"image":case"radio":case"submit":return!1}return!t.disabled&&!t.readOnly;default:return/\bneedsfocus\b/.test(t.className)}},t.prototype.sendClick=function(t,e){var n,o;document.activeElement&&document.activeElement!==t&&document.activeElement.blur(),o=e.changedTouches[0],n=document.createEvent("MouseEvents"),n.initMouseEvent(this.determineEventType(t),!0,!0,window,1,o.screenX,o.screenY,o.clientX,o.clientY,!1,!1,!1,!1,0,null),n.forwardedTouchEvent=!0,t.dispatchEvent(n)},t.prototype.determineEventType=function(t){return n&&"select"===t.tagName.toLowerCase()?"mousedown":"click"},t.prototype.focus=function(t){var e;o&&t.setSelectionRange&&0!==t.type.indexOf("date")&&"time"!==t.type&&"month"!==t.type?(e=t.value.length,t.setSelectionRange(e,e)):t.focus()},t.prototype.updateScrollParent=function(t){var e,n;if(e=t.fastClickScrollParent,!e||!e.contains(t)){n=t;do{if(n.scrollHeight>n.offsetHeight){e=n,t.fastClickScrollParent=n;break}n=n.parentElement}while(n)}e&&(e.fastClickLastScrollTop=e.scrollTop)},t.prototype.getTargetElementFromEventTarget=function(t){return t.nodeType===Node.TEXT_NODE?t.parentNode:t},t.prototype.onTouchStart=function(t){var e,n,r;if(t.targetTouches.length>1)return!0;if(e=this.getTargetElementFromEventTarget(t.target),n=t.targetTouches[0],o){if(r=window.getSelection(),r.rangeCount&&!r.isCollapsed)return!0;if(!i){if(n.identifier&&n.identifier===this.lastTouchIdentifier)return t.preventDefault(),!1;this.lastTouchIdentifier=n.identifier,this.updateScrollParent(e)}}return this.trackingClick=!0,this.trackingClickStart=t.timeStamp,this.targetElement=e,this.touchStartX=n.pageX,this.touchStartY=n.pageY,t.timeStamp-this.lastClickTimen||Math.abs(e.pageY-this.touchStartY)>n?!0:!1},t.prototype.onTouchMove=function(t){return this.trackingClick?((this.targetElement!==this.getTargetElementFromEventTarget(t.target)||this.touchHasMoved(t))&&(this.trackingClick=!1,this.targetElement=null),!0):!0},t.prototype.findControl=function(t){return void 0!==t.control?t.control:t.htmlFor?document.getElementById(t.htmlFor):t.querySelector("button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea")},t.prototype.onTouchEnd=function(t){var e,a,c,s,u,l=this.targetElement;if(!this.trackingClick)return!0;if(t.timeStamp-this.lastClickTimethis.tapTimeout)return!0;if(this.cancelNextClick=!1,this.lastClickTime=t.timeStamp,a=this.trackingClickStart,this.trackingClick=!1,this.trackingClickStart=0,r&&(u=t.changedTouches[0],l=document.elementFromPoint(u.pageX-window.pageXOffset,u.pageY-window.pageYOffset)||l,l.fastClickScrollParent=this.targetElement.fastClickScrollParent),c=l.tagName.toLowerCase(),"label"===c){if(e=this.findControl(l)){if(this.focus(l),n)return!1;l=e}}else if(this.needsFocus(l))return t.timeStamp-a>100||o&&window.top!==window&&"input"===c?(this.targetElement=null,!1):(this.focus(l),this.sendClick(l,t),o&&"select"===c||(this.targetElement=null,t.preventDefault()),!1);return o&&!i&&(s=l.fastClickScrollParent,s&&s.fastClickLastScrollTop!==s.scrollTop)?!0:(this.needsClick(l)||(t.preventDefault(),this.sendClick(l,t)),!1)},t.prototype.onTouchCancel=function(){this.trackingClick=!1,this.targetElement=null},t.prototype.onMouse=function(t){return this.targetElement?t.forwardedTouchEvent?!0:t.cancelable&&(!this.needsClick(this.targetElement)||this.cancelNextClick)?(t.stopImmediatePropagation?t.stopImmediatePropagation():t.propagationStopped=!0,t.stopPropagation(),t.preventDefault(),!1):!0:!0},t.prototype.onClick=function(t){var e;return this.trackingClick?(this.targetElement=null,this.trackingClick=!1,!0):"submit"===t.target.type&&0===t.detail?!0:(e=this.onMouse(t),e||(this.targetElement=null),e)},t.prototype.destroy=function(){var t=this.layer;n&&(t.removeEventListener("mouseover",this.onMouse,!0),t.removeEventListener("mousedown",this.onMouse,!0),t.removeEventListener("mouseup",this.onMouse,!0)),t.removeEventListener("click",this.onClick,!0),t.removeEventListener("touchstart",this.onTouchStart,!1),t.removeEventListener("touchmove",this.onTouchMove,!1),t.removeEventListener("touchend",this.onTouchEnd,!1),t.removeEventListener("touchcancel",this.onTouchCancel,!1)},t.notNeeded=function(t){var e,o,i,r;if("undefined"==typeof window.ontouchstart)return!0;if(o=+(/Chrome\/([0-9]+)/.exec(navigator.userAgent)||[,0])[1]){if(!n)return!0;if(e=document.querySelector("meta[name=viewport]")){if(-1!==e.content.indexOf("user-scalable=no"))return!0;if(o>31&&document.documentElement.scrollWidth<=window.outerWidth)return!0}}if(a&&(i=navigator.userAgent.match(/Version\/([0-9]*)\.([0-9]*)/),i[1]>=10&&i[2]>=3&&(e=document.querySelector("meta[name=viewport]")))){if(-1!==e.content.indexOf("user-scalable=no"))return!0;if(document.documentElement.scrollWidth<=window.outerWidth)return!0}return"none"===t.style.msTouchAction||"manipulation"===t.style.touchAction?!0:(r=+(/Firefox\/([0-9]+)/.exec(navigator.userAgent)||[,0])[1],r>=27&&(e=document.querySelector("meta[name=viewport]"),e&&(-1!==e.content.indexOf("user-scalable=no")||document.documentElement.scrollWidth<=window.outerWidth))?!0:"none"===t.style.touchAction||"manipulation"===t.style.touchAction?!0:!1)},t.attach=function(e,n){return new t(e,n)},"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(function(){return t}):"undefined"!=typeof module&&module.exports?(module.exports=t.attach,module.exports.FastClick=t):window.FastClick=t}(); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Computer Science Flash Cards 2 | 3 | This is a little website I've put together to allow me to easily make flash cards and quiz myself for memorization of: 4 | 5 | - General cs knowledge 6 | - vocabulary 7 | - definitions of processes 8 | - powers of 2 9 | - design patterns 10 | - Code 11 | - data structures 12 | - algorithms 13 | - solving problems 14 | - bitwise operations 15 | 16 | Will be able to use it on: 17 | 18 | - desktop 19 | - mobile (phone and tablet) 20 | 21 | It uses: 22 | 23 | - Python 3 24 | - Flask 25 | - SQLite 26 | 27 | --- 28 | 29 | ## About the Site 30 | 31 | Here's a brief rundown: https://startupnextdoor.com/flash-cards-site-complete/ 32 | 33 | ## Screenshots 34 | 35 | UI for listing cards. From here you can add and edit cards. 36 | 37 | ![Card UI](screenshots/cards_ui-1467754141259.png) 38 | 39 | --- 40 | 41 | The front of a General flash card. 42 | 43 | ![Memorizing general knowledge](screenshots/memorize_ui-1467754306971.png) 44 | 45 | --- 46 | 47 | The reverse (answer side) of a Code flash card. 48 | 49 | ![Code view](screenshots/memorize_code-1467754962142.png) 50 | 51 | ## Important Note 52 | 53 | The set included in this project (**cards-jwasham.db**) is not my full set, and is way too big already. 54 | 55 | Thanks for asking for my list of 1,792 cards. But **it’s too much.** I even printed them out. It’s 50 pages, front and back, in tiny text. It would take about 8 hours to just read them all. 56 | 57 | My set includes a lot of obscure info from books I’ve read, Python trivia, machine learning knowledge, assembly language, etc. 58 | 59 | I've added it to the project if you want it (**cards-jwasham-extreme.db**). You've been warned. 60 | 61 | Please make your own set, and while you’re making them, only make cards for what you need to know. Otherwise, it gets out of hand. 62 | 63 | ## How to convert to Anki or CSV 64 | 65 | If you don't want to run a server, you can simply use Anki or a similar service/app. Use this script to convert from my sets (SQLite .db file), or yours, to CSV: 66 | 67 | https://github.com/eyedol/tools/blob/master/anki_data_builder.py 68 | 69 | Thanks [@eyedol](https://github.com/eyedol) 70 | 71 | ## Anki Flashcards: 72 | 73 | * [computer science flash cards - (basic)](https://ankiweb.net/shared/info/1782040640) 74 | * [computer science flash cards - (extreme)](https://ankiweb.net/shared/info/1691396127) 75 | 76 | Thanks [@JackKuo-tw](https://github.com/JackKuo-tw) 77 | 78 | ## How to run it on a server 79 | 80 | 1. Clone project to a directory on your web server. 81 | 1. Edit the config.txt file. Change the secret key, username and password. The username and password will be the login 82 | for your site. There is only one user - you. 83 | 1. Follow this long tutorial to get Flask running. It was way more work than it should be: 84 | https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-ubuntu-16-04 85 | - `wsgi.py` is the entry point. It calls `flash_cards.py` 86 | - This is my systemd file `/etc/systemd/system/flash_cards.service`: [view](flash_cards.service) 87 | - you can see the paths where I installed it, and the name of my virtualenv directory 88 | - when done with tutorial: 89 | ```shell 90 | sudo systemctl restart flash_cards 91 | sudo systemctl daemon-reload 92 | ``` 93 | 1. When you see a login page, you're good to go. 94 | 1. Log in. 95 | 1. Click the "General" or "Code" button and make a card! 96 | 1. When you're ready to start memorizing, click either "General" or "Code" 97 | in the top menu. 98 | 99 | ## How to run it on local host (Quick Guide) 100 | 101 | *Provided by [@devyash](https://github.com/devyash) - devyashsanghai@gmail.com - Reach out to this contributor if you have trouble.* 102 | 103 | 1. Install dependencies: 104 | 1. Install [Python](https://www.python.org/download/releases) 105 | 1. Add python as environment variable [windows](http://stackoverflow.com/questions/3701646/how-to-add-to-the-pythonpath-in-windows-7) 106 | 1. To install pip, securely download [get-pip.py](https://bootstrap.pypa.io/get-pip.py) 107 | 1. Run `python get-pip.py` in terminal 108 | 1. Add pip to your PATH system variable [windows](https://stackoverflow.com/questions/23708898/pip-is-not-recognized-as-an-internal-or-external-command) 109 | 1. Run `pip install -r requirements.txt` in terminal after going to correct folder 110 | 1. Type `python flash_cards.py` - if you get error for flask then use `python -m pip install Flask` first then run `flash_card.py` file 111 | 1. Open localhost:5000/ 112 | 1. Login using 'admin' and 'default' for the username and password, respectively. 113 | 114 | **NOTE:** If you wish to use John's flash cards then also do following steps: 115 | 116 | 1. Copy db files such as `cards-jwasham-extreme` OR `cards-jwasham` and paste them in db folder 117 | 1. Edit file `flash_cards.py` line 8 and replace 'cards.db' with any of the other database files e.g.('cards-jwasham.db') 118 | 1. Repeat the above steps from step 3 119 | 120 | Every time you wish to run your db just open folder in terminal and run `python flash_cards.py` 121 | 122 | ## How to run with Docker 123 | 124 | *Provided by [@Tinpee](https://github.com/tinpee) - tinpee.dev@gmail.com - Reach out to this contributor if you have trouble.* 125 | 126 | __Make sure you already installed [docker](https://www.docker.com) and optionally [docker-compose](https://docs.docker.com/compose/install/)__ 127 | 128 | 1. Clone project to any where you want and go to source folder. 129 | 1. Edit the `config.txt` file. Change the secret key, username and password. The username and password will be the login for your site. There is only one user - you. 130 | 1. Build image: 131 | - Docker: `docker build . -t cs-flash-cards` 132 | - Compose: `docker-compose build` 133 | 1. Run container: 134 | - Docker: `docker run -d -p 8000:8000 --name cs-flash-cards cs-flash-cards` 135 | - Compose: `docker-compose up` 136 | 1. Go your browser and type `http://localhost:8000` 137 | 138 | __If you already had a backup file `cards.db`. Run following command:__ 139 | 140 | *Note: We don't need to rebuild image, just delete old container if you already built.* 141 | 142 | ```shell 143 | docker run -d -p 8000:8000 --name cs-flash-cards -v :/src/db cs-flash-cards 144 | ``` 145 | 146 | - ``: is the full path contains `cards.db`. 147 | - Example: `/home/tinpee/cs-flash-cards/db`, and `cards.db` is inside this folder. 148 | 149 | For convenience, if you don't have `cards.db`, this container will auto copy a new one from `cards-empty.db`. 150 | 151 | --- 152 | 153 | ### How to backup data ? 154 | We just need store `cards.db` file, and don't need any sql command. 155 | - If you run container with `-v :/src/db` just go to `folder_db` and store `cards.db` anywhere you want. 156 | - Without `-v flag`. Type: `docker cp :/src/db/cards.db /path/to/save` 157 | 158 | ### How to restore data ? 159 | - Delete old container (not image): `docker rm cs-flash-cards` 160 | - Build a new one with `-v flag`: 161 | `docker run -d -p 8000:8000 --name cs-flash-cards -v :/src/db cs-flash-cards` 162 | - Voila :) 163 | 164 | ### How to deploy docker file on heroku 165 | 166 | - first install [heroku CLI](https://devcenter.heroku.com/articles/heroku-cli) 167 | - change `entrypoint.sh` 168 | 169 | ```shell 170 | - export CARDS_SETTINGS=/src/config.txt 171 | gunicorn --bind 0.0.0.0:$8000 flash_cards:app 172 | + export CARDS_SETTINGS=/src/config.txt 173 | gunicorn --bind 0.0.0.0:$PORT flash_cards:app 174 | ``` 175 | - deploy docker file with following commands 176 | 177 | ```shell 178 | heroku login 179 | heroku container:login 180 | heroku create 181 | # Creating app... done, ⬢ your-app-name 182 | heroku container:push web --app your-app-name 183 | heroku container:release web --app your-app-name 184 | heroku open --app your-app-name 185 | ``` 186 | 187 | ## Alternative for Node fans 188 | 189 | [@ashwanikumar04](https://github.com/ashwanikumar04) put together an alternative flash cards site running Node: https://github.com/ashwanikumar04/flash-cards 190 | 191 | Check out the demo! 192 | 193 | *Happy learning!* 194 | -------------------------------------------------------------------------------- /flash_cards.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sqlite3 3 | from flask import Flask, request, session, g, redirect, url_for, abort, \ 4 | render_template, flash 5 | 6 | app = Flask(__name__) 7 | app.config.from_object(__name__) 8 | nameDB='cards.db' 9 | pathDB='db' 10 | 11 | def load_config(): 12 | app.config.update(dict( 13 | DATABASE=os.path.join(app.root_path, pathDB, nameDB), 14 | SECRET_KEY='development key', 15 | USERNAME='admin', 16 | PASSWORD='default' 17 | )) 18 | app.config.from_envvar('CARDS_SETTINGS', silent=True) 19 | 20 | if __name__ == "__main__" or __name__ == "flash_cards": 21 | load_config() 22 | 23 | def connect_db(): 24 | rv = sqlite3.connect(app.config['DATABASE']) 25 | rv.row_factory = sqlite3.Row 26 | return rv 27 | 28 | 29 | def init_db(): 30 | db = get_db() 31 | with app.open_resource('data/schema.sql', mode='r') as f: 32 | db.cursor().executescript(f.read()) 33 | db.commit() 34 | 35 | def get_db(): 36 | """Opens a new database connection if there is none yet for the 37 | current application context. 38 | """ 39 | if not hasattr(g, 'sqlite_db'): 40 | g.sqlite_db = connect_db() 41 | return g.sqlite_db 42 | 43 | 44 | @app.teardown_appcontext 45 | def close_db(error): 46 | """Closes the database again at the end of the request.""" 47 | if hasattr(g, 'sqlite_db'): 48 | g.sqlite_db.close() 49 | 50 | @app.route('/') 51 | def index(): 52 | if session.get('logged_in'): 53 | return redirect(url_for('list_db')) 54 | else: 55 | return redirect(url_for('login')) 56 | 57 | 58 | @app.route('/cards') 59 | def cards(): 60 | if not session.get('logged_in'): 61 | return redirect(url_for('login')) 62 | db = get_db() 63 | query = ''' 64 | SELECT id, type, front, back, known 65 | FROM cards 66 | ORDER BY id DESC 67 | ''' 68 | cur = db.execute(query) 69 | cards = cur.fetchall() 70 | tags = getAllTag() 71 | return render_template('cards.html', cards=cards, tags=tags, filter_name="all") 72 | 73 | 74 | @app.route('/filter_cards/') 75 | def filter_cards(filter_name): 76 | if not session.get('logged_in'): 77 | return redirect(url_for('login')) 78 | 79 | filters = { 80 | "all": "where 1 = 1", 81 | "general": "where type = 1", 82 | "code": "where type = 2", 83 | "known": "where known = 1", 84 | "unknown": "where known = 0", 85 | } 86 | 87 | query = filters.get(filter_name) 88 | if(query is None): 89 | query = "where type = {0}".format(filter_name) 90 | filter_name = int(filter_name) 91 | 92 | if not query: 93 | return redirect(url_for('show')) 94 | 95 | db = get_db() 96 | fullquery = "SELECT id, type, front, back, known FROM cards " + \ 97 | query + " ORDER BY id DESC" 98 | cur = db.execute(fullquery) 99 | cards = cur.fetchall() 100 | tags = getAllTag() 101 | return render_template('show.html', cards=cards, tags=tags, filter_name=filter_name) 102 | 103 | 104 | @app.route('/add', methods=['POST']) 105 | def add_card(): 106 | if not session.get('logged_in'): 107 | return redirect(url_for('login')) 108 | db = get_db() 109 | db.execute('INSERT INTO cards (type, front, back) VALUES (?, ?, ?)', 110 | [request.form['type'], 111 | request.form['front'], 112 | request.form['back'] 113 | ]) 114 | db.commit() 115 | flash('New card was successfully added.') 116 | return redirect(url_for('cards')) 117 | 118 | 119 | @app.route('/edit/') 120 | def edit(card_id): 121 | if not session.get('logged_in'): 122 | return redirect(url_for('login')) 123 | db = get_db() 124 | query = ''' 125 | SELECT id, type, front, back, known 126 | FROM cards 127 | WHERE id = ? 128 | ''' 129 | cur = db.execute(query, [card_id]) 130 | card = cur.fetchone() 131 | tags = getAllTag() 132 | return render_template('edit.html', card=card, tags=tags) 133 | 134 | 135 | @app.route('/edit_card', methods=['POST']) 136 | def edit_card(): 137 | if not session.get('logged_in'): 138 | return redirect(url_for('login')) 139 | selected = request.form.getlist('known') 140 | known = bool(selected) 141 | db = get_db() 142 | command = ''' 143 | UPDATE cards 144 | SET 145 | type = ?, 146 | front = ?, 147 | back = ?, 148 | known = ? 149 | WHERE id = ? 150 | ''' 151 | db.execute(command, 152 | [request.form['type'], 153 | request.form['front'], 154 | request.form['back'], 155 | known, 156 | request.form['card_id'] 157 | ]) 158 | db.commit() 159 | flash('Card saved.') 160 | return redirect(url_for('show')) 161 | 162 | 163 | @app.route('/delete/') 164 | def delete(card_id): 165 | if not session.get('logged_in'): 166 | return redirect(url_for('login')) 167 | db = get_db() 168 | db.execute('DELETE FROM cards WHERE id = ?', [card_id]) 169 | db.commit() 170 | flash('Card deleted.') 171 | return redirect(url_for('cards')) 172 | 173 | @app.route('/memorize') 174 | @app.route('/memorize/') 175 | @app.route('/memorize//') 176 | def memorize(card_type, card_id=None): 177 | tag = getTag(card_type) 178 | if tag is None: 179 | return redirect(url_for('cards')) 180 | 181 | if card_id: 182 | card = get_card_by_id(card_id) 183 | else: 184 | card = get_card(card_type) 185 | if not card: 186 | flash("You've learned all the '" + tag[1] + "' cards.") 187 | return redirect(url_for('show')) 188 | short_answer = (len(card['back']) < 75) 189 | tags = getAllTag() 190 | card_type = int(card_type) 191 | return render_template('memorize.html', 192 | card=card, 193 | card_type=card_type, 194 | short_answer=short_answer, tags=tags) 195 | 196 | @app.route('/memorize_known') 197 | @app.route('/memorize_known/') 198 | @app.route('/memorize_known//') 199 | def memorize_known(card_type, card_id=None): 200 | tag = getTag(card_type) 201 | if tag is None: 202 | return redirect(url_for('cards')) 203 | 204 | if card_id: 205 | card = get_card_by_id(card_id) 206 | else: 207 | card = get_card_already_known(card_type) 208 | if not card: 209 | flash("You haven't learned any '" + tag[1] + "' cards yet.") 210 | return redirect(url_for('show')) 211 | short_answer = (len(card['back']) < 75) 212 | tags = getAllTag() 213 | card_type = int(card_type) 214 | return render_template('memorize_known.html', 215 | card=card, 216 | card_type=card_type, 217 | short_answer=short_answer, tags=tags) 218 | 219 | 220 | def get_card(type): 221 | db = get_db() 222 | 223 | query = ''' 224 | SELECT 225 | id, type, front, back, known 226 | FROM cards 227 | WHERE 228 | type = ? 229 | and known = 0 230 | ORDER BY RANDOM() 231 | LIMIT 1 232 | ''' 233 | 234 | cur = db.execute(query, [type]) 235 | return cur.fetchone() 236 | 237 | 238 | def get_card_by_id(card_id): 239 | db = get_db() 240 | 241 | query = ''' 242 | SELECT 243 | id, type, front, back, known 244 | FROM cards 245 | WHERE 246 | id = ? 247 | LIMIT 1 248 | ''' 249 | 250 | cur = db.execute(query, [card_id]) 251 | return cur.fetchone() 252 | 253 | 254 | @app.route('/mark_known//') 255 | def mark_known(card_id, card_type): 256 | if not session.get('logged_in'): 257 | return redirect(url_for('login')) 258 | db = get_db() 259 | db.execute('UPDATE cards SET known = 1 WHERE id = ?', [card_id]) 260 | db.commit() 261 | flash('Card marked as known.') 262 | return redirect(url_for('memorize', card_type=card_type)) 263 | 264 | @app.route('/login', methods=['GET', 'POST']) 265 | def login(): 266 | error = None 267 | if request.method == 'POST': 268 | if request.form['username'] != app.config['USERNAME']: 269 | error = 'Invalid username or password!' 270 | elif request.form['password'] != app.config['PASSWORD']: 271 | error = 'Invalid username or password!' 272 | else: 273 | session['logged_in'] = True 274 | session.permanent = True # stay logged in 275 | return redirect(url_for('index')) 276 | return render_template('login.html', error=error) 277 | 278 | 279 | @app.route('/logout') 280 | def logout(): 281 | session.pop('logged_in', None) 282 | flash("You've logged out") 283 | return redirect(url_for('index')) 284 | 285 | 286 | def getAllTag(): 287 | if not session.get('logged_in'): 288 | return redirect(url_for('login')) 289 | db = get_db() 290 | query = ''' 291 | SELECT id, tagName 292 | FROM tags 293 | ORDER BY id ASC 294 | ''' 295 | cur = db.execute(query) 296 | tags = cur.fetchall() 297 | return tags 298 | 299 | 300 | @app.route('/tags') 301 | def tags(): 302 | if not session.get('logged_in'): 303 | return redirect(url_for('login')) 304 | tags = getAllTag() 305 | return render_template('tags.html', tags=tags, filter_name="all") 306 | 307 | 308 | @app.route('/addTag', methods=['POST']) 309 | def add_tag(): 310 | if not session.get('logged_in'): 311 | return redirect(url_for('login')) 312 | db = get_db() 313 | db.execute('INSERT INTO tags (tagName) VALUES (?)', 314 | [request.form['tagName']]) 315 | db.commit() 316 | flash('New tag was successfully added.') 317 | return redirect(url_for('tags')) 318 | 319 | 320 | @app.route('/editTag/') 321 | def edit_tag(tag_id): 322 | if not session.get('logged_in'): 323 | return redirect(url_for('login')) 324 | tag = getTag(tag_id) 325 | return render_template('editTag.html', tag=tag) 326 | 327 | 328 | @app.route('/updateTag', methods=['POST']) 329 | def update_tag(): 330 | if not session.get('logged_in'): 331 | return redirect(url_for('login')) 332 | db = get_db() 333 | command = ''' 334 | UPDATE tags 335 | SET 336 | tagName = ? 337 | WHERE id = ? 338 | ''' 339 | db.execute(command, 340 | [request.form['tagName'], 341 | request.form['tag_id'] 342 | ]) 343 | db.commit() 344 | flash('Tag saved.') 345 | return redirect(url_for('tags')) 346 | 347 | def init_tag(): 348 | if not session.get('logged_in'): 349 | return redirect(url_for('login')) 350 | db = get_db() 351 | db.execute('INSERT INTO tags (tagName) VALUES (?)', 352 | ["general"]) 353 | db.commit() 354 | db.execute('INSERT INTO tags (tagName) VALUES (?)', 355 | ["code"]) 356 | db.commit() 357 | db.execute('INSERT INTO tags (tagName) VALUES (?)', 358 | ["bookmark"]) 359 | db.commit() 360 | 361 | @app.route('/show') 362 | def show(): 363 | if not session.get('logged_in'): 364 | return redirect(url_for('login')) 365 | tags = getAllTag() 366 | return render_template('show.html', tags=tags, filter_name="") 367 | 368 | def getTag(tag_id): 369 | if not session.get('logged_in'): 370 | return redirect(url_for('login')) 371 | db = get_db() 372 | query = ''' 373 | SELECT id, tagName 374 | FROM tags 375 | WHERE id = ? 376 | ''' 377 | cur = db.execute(query, [tag_id]) 378 | tag = cur.fetchone() 379 | return tag 380 | 381 | @app.route('/bookmark//') 382 | def bookmark(card_type, card_id): 383 | if not session.get('logged_in'): 384 | return redirect(url_for('login')) 385 | db = get_db() 386 | db.execute('UPDATE cards SET type = ? WHERE id = ?',[card_type,card_id]) 387 | db.commit() 388 | flash('Card saved.') 389 | return redirect(url_for('memorize', card_type=card_type)) 390 | 391 | @app.route('/list_db') 392 | def list_db(): 393 | if not session.get('logged_in'): 394 | return redirect(url_for('login')) 395 | dbs = [f for f in os.listdir(pathDB) if os.path.isfile(os.path.join(pathDB, f))] 396 | dbs = list(filter(lambda k: '.db' in k, dbs)) 397 | return render_template('listDb.html', dbs=dbs) 398 | 399 | @app.route('/load_db/') 400 | def load_db(name): 401 | if not session.get('logged_in'): 402 | return redirect(url_for('login')) 403 | global nameDB 404 | nameDB=name 405 | load_config() 406 | handle_old_schema() 407 | return redirect(url_for('memorize', card_type="1")) 408 | 409 | @app.route('/create_db') 410 | def create_db(): 411 | if not session.get('logged_in'): 412 | return redirect(url_for('login')) 413 | return render_template('createDb.html') 414 | 415 | @app.route('/init', methods=['POST']) 416 | def init(): 417 | if not session.get('logged_in'): 418 | return redirect(url_for('login')) 419 | global nameDB 420 | nameDB = request.form['dbName'] + '.db' 421 | load_config() 422 | init_db() 423 | init_tag() 424 | return redirect(url_for('index')) 425 | 426 | def check_table_tag_exists(): 427 | db = get_db() 428 | cur = db.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='tags'") 429 | result = cur.fetchone() 430 | return result 431 | 432 | def create_tag_table(): 433 | db = get_db() 434 | with app.open_resource('data/handle_old_schema.sql', mode='r') as f: 435 | db.cursor().executescript(f.read()) 436 | db.commit() 437 | 438 | def handle_old_schema(): 439 | result = check_table_tag_exists() 440 | if(result is None): 441 | create_tag_table() 442 | init_tag() 443 | 444 | def get_card_already_known(type): 445 | db = get_db() 446 | 447 | query = ''' 448 | SELECT 449 | id, type, front, back, known 450 | FROM cards 451 | WHERE 452 | type = ? 453 | and known = 1 454 | ORDER BY RANDOM() 455 | LIMIT 1 456 | ''' 457 | 458 | cur = db.execute(query, [type]) 459 | return cur.fetchone() 460 | 461 | @app.route('/mark_unknown//') 462 | def mark_unknown(card_id, card_type): 463 | if not session.get('logged_in'): 464 | return redirect(url_for('login')) 465 | db = get_db() 466 | db.execute('UPDATE cards SET known = 0 WHERE id = ?', [card_id]) 467 | db.commit() 468 | flash('Card marked as unknown.') 469 | return redirect(url_for('memorize_known', card_type=card_type)) 470 | 471 | if __name__ == '__main__': 472 | app.run(host='0.0.0.0') 473 | -------------------------------------------------------------------------------- /static/highlight.pack.js: -------------------------------------------------------------------------------- 1 | /*! highlight.js v9.9.0 | BSD3 License | git.io/hljslicense */ 2 | !function(e){var n="object"==typeof window&&window||"object"==typeof self&&self;"undefined"!=typeof exports?e(exports):n&&(n.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return n.hljs}))}(function(e){function n(e){return e.replace(/[&<>]/gm,function(e){return I[e]})}function t(e){return e.nodeName.toLowerCase()}function r(e,n){var t=e&&e.exec(n);return t&&0===t.index}function i(e){return k.test(e)}function a(e){var n,t,r,a,o=e.className+" ";if(o+=e.parentNode?e.parentNode.className:"",t=B.exec(o))return R(t[1])?t[1]:"no-highlight";for(o=o.split(/\s+/),n=0,r=o.length;r>n;n++)if(a=o[n],i(a)||R(a))return a}function o(e,n){var t,r={};for(t in e)r[t]=e[t];if(n)for(t in n)r[t]=n[t];return r}function u(e){var n=[];return function r(e,i){for(var a=e.firstChild;a;a=a.nextSibling)3===a.nodeType?i+=a.nodeValue.length:1===a.nodeType&&(n.push({event:"start",offset:i,node:a}),i=r(a,i),t(a).match(/br|hr|img|input/)||n.push({event:"stop",offset:i,node:a}));return i}(e,0),n}function c(e,r,i){function a(){return e.length&&r.length?e[0].offset!==r[0].offset?e[0].offset"}function u(e){l+=""}function c(e){("start"===e.event?o:u)(e.node)}for(var s=0,l="",f=[];e.length||r.length;){var g=a();if(l+=n(i.substring(s,g[0].offset)),s=g[0].offset,g===e){f.reverse().forEach(u);do c(g.splice(0,1)[0]),g=a();while(g===e&&g.length&&g[0].offset===s);f.reverse().forEach(o)}else"start"===g[0].event?f.push(g[0].node):f.pop(),c(g.splice(0,1)[0])}return l+n(i.substr(s))}function s(e){function n(e){return e&&e.source||e}function t(t,r){return new RegExp(n(t),"m"+(e.cI?"i":"")+(r?"g":""))}function r(i,a){if(!i.compiled){if(i.compiled=!0,i.k=i.k||i.bK,i.k){var u={},c=function(n,t){e.cI&&(t=t.toLowerCase()),t.split(" ").forEach(function(e){var t=e.split("|");u[t[0]]=[n,t[1]?Number(t[1]):1]})};"string"==typeof i.k?c("keyword",i.k):E(i.k).forEach(function(e){c(e,i.k[e])}),i.k=u}i.lR=t(i.l||/\w+/,!0),a&&(i.bK&&(i.b="\\b("+i.bK.split(" ").join("|")+")\\b"),i.b||(i.b=/\B|\b/),i.bR=t(i.b),i.e||i.eW||(i.e=/\B|\b/),i.e&&(i.eR=t(i.e)),i.tE=n(i.e)||"",i.eW&&a.tE&&(i.tE+=(i.e?"|":"")+a.tE)),i.i&&(i.iR=t(i.i)),null==i.r&&(i.r=1),i.c||(i.c=[]);var s=[];i.c.forEach(function(e){e.v?e.v.forEach(function(n){s.push(o(e,n))}):s.push("self"===e?i:e)}),i.c=s,i.c.forEach(function(e){r(e,i)}),i.starts&&r(i.starts,a);var l=i.c.map(function(e){return e.bK?"\\.?("+e.b+")\\.?":e.b}).concat([i.tE,i.i]).map(n).filter(Boolean);i.t=l.length?t(l.join("|"),!0):{exec:function(){return null}}}}r(e)}function l(e,t,i,a){function o(e,n){var t,i;for(t=0,i=n.c.length;i>t;t++)if(r(n.c[t].bR,e))return n.c[t]}function u(e,n){if(r(e.eR,n)){for(;e.endsParent&&e.parent;)e=e.parent;return e}return e.eW?u(e.parent,n):void 0}function c(e,n){return!i&&r(n.iR,e)}function g(e,n){var t=N.cI?n[0].toLowerCase():n[0];return e.k.hasOwnProperty(t)&&e.k[t]}function h(e,n,t,r){var i=r?"":y.classPrefix,a='',a+n+o}function p(){var e,t,r,i;if(!E.k)return n(B);for(i="",t=0,E.lR.lastIndex=0,r=E.lR.exec(B);r;)i+=n(B.substring(t,r.index)),e=g(E,r),e?(M+=e[1],i+=h(e[0],n(r[0]))):i+=n(r[0]),t=E.lR.lastIndex,r=E.lR.exec(B);return i+n(B.substr(t))}function d(){var e="string"==typeof E.sL;if(e&&!x[E.sL])return n(B);var t=e?l(E.sL,B,!0,L[E.sL]):f(B,E.sL.length?E.sL:void 0);return E.r>0&&(M+=t.r),e&&(L[E.sL]=t.top),h(t.language,t.value,!1,!0)}function b(){k+=null!=E.sL?d():p(),B=""}function v(e){k+=e.cN?h(e.cN,"",!0):"",E=Object.create(e,{parent:{value:E}})}function m(e,n){if(B+=e,null==n)return b(),0;var t=o(n,E);if(t)return t.skip?B+=n:(t.eB&&(B+=n),b(),t.rB||t.eB||(B=n)),v(t,n),t.rB?0:n.length;var r=u(E,n);if(r){var i=E;i.skip?B+=n:(i.rE||i.eE||(B+=n),b(),i.eE&&(B=n));do E.cN&&(k+=C),E.skip||(M+=E.r),E=E.parent;while(E!==r.parent);return r.starts&&v(r.starts,""),i.rE?0:n.length}if(c(n,E))throw new Error('Illegal lexeme "'+n+'" for mode "'+(E.cN||"")+'"');return B+=n,n.length||1}var N=R(e);if(!N)throw new Error('Unknown language: "'+e+'"');s(N);var w,E=a||N,L={},k="";for(w=E;w!==N;w=w.parent)w.cN&&(k=h(w.cN,"",!0)+k);var B="",M=0;try{for(var I,j,O=0;;){if(E.t.lastIndex=O,I=E.t.exec(t),!I)break;j=m(t.substring(O,I.index),I[0]),O=I.index+j}for(m(t.substr(O)),w=E;w.parent;w=w.parent)w.cN&&(k+=C);return{r:M,value:k,language:e,top:E}}catch(T){if(T.message&&-1!==T.message.indexOf("Illegal"))return{r:0,value:n(t)};throw T}}function f(e,t){t=t||y.languages||E(x);var r={r:0,value:n(e)},i=r;return t.filter(R).forEach(function(n){var t=l(n,e,!1);t.language=n,t.r>i.r&&(i=t),t.r>r.r&&(i=r,r=t)}),i.language&&(r.second_best=i),r}function g(e){return y.tabReplace||y.useBR?e.replace(M,function(e,n){return y.useBR&&"\n"===e?"
":y.tabReplace?n.replace(/\t/g,y.tabReplace):void 0}):e}function h(e,n,t){var r=n?L[n]:t,i=[e.trim()];return e.match(/\bhljs\b/)||i.push("hljs"),-1===e.indexOf(r)&&i.push(r),i.join(" ").trim()}function p(e){var n,t,r,o,s,p=a(e);i(p)||(y.useBR?(n=document.createElementNS("http://www.w3.org/1999/xhtml","div"),n.innerHTML=e.innerHTML.replace(/\n/g,"").replace(//g,"\n")):n=e,s=n.textContent,r=p?l(p,s,!0):f(s),t=u(n),t.length&&(o=document.createElementNS("http://www.w3.org/1999/xhtml","div"),o.innerHTML=r.value,r.value=c(t,u(o),s)),r.value=g(r.value),e.innerHTML=r.value,e.className=h(e.className,p,r.language),e.result={language:r.language,re:r.r},r.second_best&&(e.second_best={language:r.second_best.language,re:r.second_best.r}))}function d(e){y=o(y,e)}function b(){if(!b.called){b.called=!0;var e=document.querySelectorAll("pre code");w.forEach.call(e,p)}}function v(){addEventListener("DOMContentLoaded",b,!1),addEventListener("load",b,!1)}function m(n,t){var r=x[n]=t(e);r.aliases&&r.aliases.forEach(function(e){L[e]=n})}function N(){return E(x)}function R(e){return e=(e||"").toLowerCase(),x[e]||x[L[e]]}var w=[],E=Object.keys,x={},L={},k=/^(no-?highlight|plain|text)$/i,B=/\blang(?:uage)?-([\w-]+)\b/i,M=/((^(<[^>]+>|\t|)+|(?:\n)))/gm,C="
",y={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0},I={"&":"&","<":"<",">":">"};return e.highlight=l,e.highlightAuto=f,e.fixMarkup=g,e.highlightBlock=p,e.configure=d,e.initHighlighting=b,e.initHighlightingOnLoad=v,e.registerLanguage=m,e.listLanguages=N,e.getLanguage=R,e.inherit=o,e.IR="[a-zA-Z]\\w*",e.UIR="[a-zA-Z_]\\w*",e.NR="\\b\\d+(\\.\\d+)?",e.CNR="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",e.BNR="\\b(0b[01]+)",e.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",e.BE={b:"\\\\[\\s\\S]",r:0},e.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[e.BE]},e.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[e.BE]},e.PWM={b:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|like)\b/},e.C=function(n,t,r){var i=e.inherit({cN:"comment",b:n,e:t,c:[]},r||{});return i.c.push(e.PWM),i.c.push({cN:"doctag",b:"(?:TODO|FIXME|NOTE|BUG|XXX):",r:0}),i},e.CLCM=e.C("//","$"),e.CBCM=e.C("/\\*","\\*/"),e.HCM=e.C("#","$"),e.NM={cN:"number",b:e.NR,r:0},e.CNM={cN:"number",b:e.CNR,r:0},e.BNM={cN:"number",b:e.BNR,r:0},e.CSSNM={cN:"number",b:e.NR+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",r:0},e.RM={cN:"regexp",b:/\//,e:/\/[gimuy]*/,i:/\n/,c:[e.BE,{b:/\[/,e:/\]/,r:0,c:[e.BE]}]},e.TM={cN:"title",b:e.IR,r:0},e.UTM={cN:"title",b:e.UIR,r:0},e.METHOD_GUARD={b:"\\.\\s*"+e.UIR,r:0},e});hljs.registerLanguage("java",function(e){var a="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",t=a+"(<"+a+"(\\s*,\\s*"+a+")*>)?",r="false synchronized int abstract float private char boolean static null if const for true while long strictfp finally protected import native final void enum else break transient catch instanceof byte super volatile case assert short package default double public try this switch continue throws protected public private module requires exports do",s="\\b(0[bB]([01]+[01_]+[01]+|[01]+)|0[xX]([a-fA-F0-9]+[a-fA-F0-9_]+[a-fA-F0-9]+|[a-fA-F0-9]+)|(([\\d]+[\\d_]+[\\d]+|[\\d]+)(\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))?|\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))([eE][-+]?\\d+)?)[lLfF]?",c={cN:"number",b:s,r:0};return{aliases:["jsp"],k:r,i:/<\/|#/,c:[e.C("/\\*\\*","\\*/",{r:0,c:[{b:/\w+@/,r:0},{cN:"doctag",b:"@[A-Za-z]+"}]}),e.CLCM,e.CBCM,e.ASM,e.QSM,{cN:"class",bK:"class interface",e:/[{;=]/,eE:!0,k:"class interface",i:/[:"\[\]]/,c:[{bK:"extends implements"},e.UTM]},{bK:"new throw return else",r:0},{cN:"function",b:"("+t+"\\s+)+"+e.UIR+"\\s*\\(",rB:!0,e:/[{;=]/,eE:!0,k:r,c:[{b:e.UIR+"\\s*\\(",rB:!0,r:0,c:[e.UTM]},{cN:"params",b:/\(/,e:/\)/,k:r,r:0,c:[e.ASM,e.QSM,e.CNM,e.CBCM]},e.CLCM,e.CBCM]},c,{cN:"meta",b:"@[A-Za-z]+"}]}});hljs.registerLanguage("cpp",function(t){var e={cN:"keyword",b:"\\b[a-z\\d_]*_t\\b"},r={cN:"string",v:[{b:'(u8?|U)?L?"',e:'"',i:"\\n",c:[t.BE]},{b:'(u8?|U)?R"',e:'"',c:[t.BE]},{b:"'\\\\?.",e:"'",i:"."}]},s={cN:"number",v:[{b:"\\b(0b[01']+)"},{b:"\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{b:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],r:0},i={cN:"meta",b:/#\s*[a-z]+\b/,e:/$/,k:{"meta-keyword":"if else elif endif define undef warning error line pragma ifdef ifndef include"},c:[{b:/\\\n/,r:0},t.inherit(r,{cN:"meta-string"}),{cN:"meta-string",b:"<",e:">",i:"\\n"},t.CLCM,t.CBCM]},a=t.IR+"\\s*\\(",c={keyword:"int float while private char catch import module export virtual operator sizeof dynamic_cast|10 typedef const_cast|10 const struct for static_cast|10 union namespace unsigned long volatile static protected bool template mutable if public friend do goto auto void enum else break extern using class asm case typeid short reinterpret_cast|10 default double register explicit signed typename try this switch continue inline delete alignof constexpr decltype noexcept static_assert thread_local restrict _Bool complex _Complex _Imaginary atomic_bool atomic_char atomic_schar atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong atomic_ullong new throw return",built_in:"std string cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap array shared_ptr abort abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr",literal:"true false nullptr NULL"},n=[e,t.CLCM,t.CBCM,s,r];return{aliases:["c","cc","h","c++","h++","hpp"],k:c,i:"",k:c,c:["self",e]},{b:t.IR+"::",k:c},{v:[{b:/=/,e:/;/},{b:/\(/,e:/\)/},{bK:"new throw return else",e:/;/}],k:c,c:n.concat([{b:/\(/,e:/\)/,k:c,c:n.concat(["self"]),r:0}]),r:0},{cN:"function",b:"("+t.IR+"[\\*&\\s]+)+"+a,rB:!0,e:/[{;=]/,eE:!0,k:c,i:/[^\w\s\*&]/,c:[{b:a,rB:!0,c:[t.TM],r:0},{cN:"params",b:/\(/,e:/\)/,k:c,r:0,c:[t.CLCM,t.CBCM,r,s,e]},t.CLCM,t.CBCM,i]}]),exports:{preprocessor:i,strings:r,k:c}}});hljs.registerLanguage("python",function(e){var r={cN:"meta",b:/^(>>>|\.\.\.) /},b={cN:"string",c:[e.BE],v:[{b:/(u|b)?r?'''/,e:/'''/,c:[r],r:10},{b:/(u|b)?r?"""/,e:/"""/,c:[r],r:10},{b:/(u|r|ur)'/,e:/'/,r:10},{b:/(u|r|ur)"/,e:/"/,r:10},{b:/(b|br)'/,e:/'/},{b:/(b|br)"/,e:/"/},e.ASM,e.QSM]},a={cN:"number",r:0,v:[{b:e.BNR+"[lLjJ]?"},{b:"\\b(0o[0-7]+)[lLjJ]?"},{b:e.CNR+"[lLjJ]?"}]},l={cN:"params",b:/\(/,e:/\)/,c:["self",r,a,b]};return{aliases:["py","gyp"],k:{keyword:"and elif is global as in if from raise for except finally print import pass return exec else break not with class assert yield try while continue del or def lambda async await nonlocal|10 None True False",built_in:"Ellipsis NotImplemented"},i:/(<\/|->|\?)|=>/,c:[r,a,b,e.HCM,{v:[{cN:"function",bK:"def"},{cN:"class",bK:"class"}],e:/:/,i:/[${=;\n,]/,c:[e.UTM,l,{b:/->/,eW:!0,k:"None"}]},{cN:"meta",b:/^[\t ]*@/,e:/$/},{b:/\b(print|exec)\(/}]}});hljs.registerLanguage("cs",function(e){var i={keyword:"abstract as base bool break byte case catch char checked const continue decimal default delegate do double else enum event explicit extern finally fixed float for foreach goto if implicit in int interface internal is lock long object operator out override params private protected public readonly ref sbyte sealed short sizeof stackalloc static string struct switch this try typeof uint ulong unchecked unsafe ushort using virtual void volatile while nameof add alias ascending async await by descending dynamic equals from get global group into join let on orderby partial remove select set value var where yield",literal:"null false true"},r={cN:"string",b:'@"',e:'"',c:[{b:'""'}]},t=e.inherit(r,{i:/\n/}),a={cN:"subst",b:"{",e:"}",k:i},n=e.inherit(a,{i:/\n/}),c={cN:"string",b:/\$"/,e:'"',i:/\n/,c:[{b:"{{"},{b:"}}"},e.BE,n]},s={cN:"string",b:/\$@"/,e:'"',c:[{b:"{{"},{b:"}}"},{b:'""'},a]},o=e.inherit(s,{i:/\n/,c:[{b:"{{"},{b:"}}"},{b:'""'},n]});a.c=[s,c,r,e.ASM,e.QSM,e.CNM,e.CBCM],n.c=[o,c,t,e.ASM,e.QSM,e.CNM,e.inherit(e.CBCM,{i:/\n/})];var l={v:[s,c,r,e.ASM,e.QSM]},b=e.IR+"(<"+e.IR+"(\\s*,\\s*"+e.IR+")*>)?(\\[\\])?";return{aliases:["csharp"],k:i,i:/::/,c:[e.C("///","$",{rB:!0,c:[{cN:"doctag",v:[{b:"///",r:0},{b:""},{b:""}]}]}),e.CLCM,e.CBCM,{cN:"meta",b:"#",e:"$",k:{"meta-keyword":"if else elif endif define undef warning error line region endregion pragma checksum"}},l,e.CNM,{bK:"class interface",e:/[{;=]/,i:/[^\s:]/,c:[e.TM,e.CLCM,e.CBCM]},{bK:"namespace",e:/[{;=]/,i:/[^\s:]/,c:[e.inherit(e.TM,{b:"[a-zA-Z](\\.?\\w)*"}),e.CLCM,e.CBCM]},{bK:"new return throw await",r:0},{cN:"function",b:"("+b+"\\s+)+"+e.IR+"\\s*\\(",rB:!0,e:/[{;=]/,eE:!0,k:i,c:[{b:e.IR+"\\s*\\(",rB:!0,c:[e.TM],r:0},{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,k:i,r:0,c:[l,e.CNM,e.CBCM]},e.CLCM,e.CBCM]}]}});hljs.registerLanguage("javascript",function(e){var r="[A-Za-z$_][0-9A-Za-z$_]*",t={keyword:"in of if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const export super debugger as async await static import from as",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect Promise"},a={cN:"number",v:[{b:"\\b(0[bB][01]+)"},{b:"\\b(0[oO][0-7]+)"},{b:e.CNR}],r:0},n={cN:"subst",b:"\\$\\{",e:"\\}",k:t,c:[]},c={cN:"string",b:"`",e:"`",c:[e.BE,n]};n.c=[e.ASM,e.QSM,c,a,e.RM];var s=n.c.concat([e.CBCM,e.CLCM]);return{aliases:["js","jsx"],k:t,c:[{cN:"meta",r:10,b:/^\s*['"]use (strict|asm)['"]/},{cN:"meta",b:/^#!/,e:/$/},e.ASM,e.QSM,c,e.CLCM,e.CBCM,a,{b:/[{,]\s*/,r:0,c:[{b:r+"\\s*:",rB:!0,r:0,c:[{cN:"attr",b:r,r:0}]}]},{b:"("+e.RSR+"|\\b(case|return|throw)\\b)\\s*",k:"return throw case",c:[e.CLCM,e.CBCM,e.RM,{cN:"function",b:"(\\(.*?\\)|"+r+")\\s*=>",rB:!0,e:"\\s*=>",c:[{cN:"params",v:[{b:r},{b:/\(\s*\)/},{b:/\(/,e:/\)/,eB:!0,eE:!0,k:t,c:s}]}]},{b://,sL:"xml",c:[{b:/<\w+\s*\/>/,skip:!0},{b:/<\w+/,e:/(\/\w+|\w+\/)>/,skip:!0,c:[{b:/<\w+\s*\/>/,skip:!0},"self"]}]}],r:0},{cN:"function",bK:"function",e:/\{/,eE:!0,c:[e.inherit(e.TM,{b:r}),{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,c:s}],i:/\[|%/},{b:/\$[(.]/},e.METHOD_GUARD,{cN:"class",bK:"class",e:/[{;=]/,eE:!0,i:/[:"\[\]]/,c:[{bK:"extends"},e.UTM]},{bK:"constructor",e:/\{/,eE:!0}],i:/#(?!!)/}}); -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | Attribution-ShareAlike 4.0 International 2 | 3 | ======================================================================= 4 | 5 | Creative Commons Corporation ("Creative Commons") is not a law firm and 6 | does not provide legal services or legal advice. Distribution of 7 | Creative Commons public licenses does not create a lawyer-client or 8 | other relationship. Creative Commons makes its licenses and related 9 | information available on an "as-is" basis. Creative Commons gives no 10 | warranties regarding its licenses, any material licensed under their 11 | terms and conditions, or any related information. Creative Commons 12 | disclaims all liability for damages resulting from their use to the 13 | fullest extent possible. 14 | 15 | Using Creative Commons Public Licenses 16 | 17 | Creative Commons public licenses provide a standard set of terms and 18 | conditions that creators and other rights holders may use to share 19 | original works of authorship and other material subject to copyright 20 | and certain other rights specified in the public license below. The 21 | following considerations are for informational purposes only, are not 22 | exhaustive, and do not form part of our licenses. 23 | 24 | Considerations for licensors: Our public licenses are 25 | intended for use by those authorized to give the public 26 | permission to use material in ways otherwise restricted by 27 | copyright and certain other rights. Our licenses are 28 | irrevocable. Licensors should read and understand the terms 29 | and conditions of the license they choose before applying it. 30 | Licensors should also secure all rights necessary before 31 | applying our licenses so that the public can reuse the 32 | material as expected. Licensors should clearly mark any 33 | material not subject to the license. This includes other CC- 34 | licensed material, or material used under an exception or 35 | limitation to copyright. More considerations for licensors: 36 | wiki.creativecommons.org/Considerations_for_licensors 37 | 38 | Considerations for the public: By using one of our public 39 | licenses, a licensor grants the public permission to use the 40 | licensed material under specified terms and conditions. If 41 | the licensor's permission is not necessary for any reason--for 42 | example, because of any applicable exception or limitation to 43 | copyright--then that use is not regulated by the license. Our 44 | licenses grant only permissions under copyright and certain 45 | other rights that a licensor has authority to grant. Use of 46 | the licensed material may still be restricted for other 47 | reasons, including because others have copyright or other 48 | rights in the material. A licensor may make special requests, 49 | such as asking that all changes be marked or described. 50 | Although not required by our licenses, you are encouraged to 51 | respect those requests where reasonable. More_considerations 52 | for the public: 53 | wiki.creativecommons.org/Considerations_for_licensees 54 | 55 | ======================================================================= 56 | 57 | Creative Commons Attribution-ShareAlike 4.0 International Public 58 | License 59 | 60 | By exercising the Licensed Rights (defined below), You accept and agree 61 | to be bound by the terms and conditions of this Creative Commons 62 | Attribution-ShareAlike 4.0 International Public License ("Public 63 | License"). To the extent this Public License may be interpreted as a 64 | contract, You are granted the Licensed Rights in consideration of Your 65 | acceptance of these terms and conditions, and the Licensor grants You 66 | such rights in consideration of benefits the Licensor receives from 67 | making the Licensed Material available under these terms and 68 | conditions. 69 | 70 | 71 | Section 1 -- Definitions. 72 | 73 | a. Adapted Material means material subject to Copyright and Similar 74 | Rights that is derived from or based upon the Licensed Material 75 | and in which the Licensed Material is translated, altered, 76 | arranged, transformed, or otherwise modified in a manner requiring 77 | permission under the Copyright and Similar Rights held by the 78 | Licensor. For purposes of this Public License, where the Licensed 79 | Material is a musical work, performance, or sound recording, 80 | Adapted Material is always produced where the Licensed Material is 81 | synched in timed relation with a moving image. 82 | 83 | b. Adapter's License means the license You apply to Your Copyright 84 | and Similar Rights in Your contributions to Adapted Material in 85 | accordance with the terms and conditions of this Public License. 86 | 87 | c. BY-SA Compatible License means a license listed at 88 | creativecommons.org/compatiblelicenses, approved by Creative 89 | Commons as essentially the equivalent of this Public License. 90 | 91 | d. Copyright and Similar Rights means copyright and/or similar rights 92 | closely related to copyright including, without limitation, 93 | performance, broadcast, sound recording, and Sui Generis Database 94 | Rights, without regard to how the rights are labeled or 95 | categorized. For purposes of this Public License, the rights 96 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 97 | Rights. 98 | 99 | e. Effective Technological Measures means those measures that, in the 100 | absence of proper authority, may not be circumvented under laws 101 | fulfilling obligations under Article 11 of the WIPO Copyright 102 | Treaty adopted on December 20, 1996, and/or similar international 103 | agreements. 104 | 105 | f. Exceptions and Limitations means fair use, fair dealing, and/or 106 | any other exception or limitation to Copyright and Similar Rights 107 | that applies to Your use of the Licensed Material. 108 | 109 | g. License Elements means the license attributes listed in the name 110 | of a Creative Commons Public License. The License Elements of this 111 | Public License are Attribution and ShareAlike. 112 | 113 | h. Licensed Material means the artistic or literary work, database, 114 | or other material to which the Licensor applied this Public 115 | License. 116 | 117 | i. Licensed Rights means the rights granted to You subject to the 118 | terms and conditions of this Public License, which are limited to 119 | all Copyright and Similar Rights that apply to Your use of the 120 | Licensed Material and that the Licensor has authority to license. 121 | 122 | j. Licensor means the individual(s) or entity(ies) granting rights 123 | under this Public License. 124 | 125 | k. Share means to provide material to the public by any means or 126 | process that requires permission under the Licensed Rights, such 127 | as reproduction, public display, public performance, distribution, 128 | dissemination, communication, or importation, and to make material 129 | available to the public including in ways that members of the 130 | public may access the material from a place and at a time 131 | individually chosen by them. 132 | 133 | l. Sui Generis Database Rights means rights other than copyright 134 | resulting from Directive 96/9/EC of the European Parliament and of 135 | the Council of 11 March 1996 on the legal protection of databases, 136 | as amended and/or succeeded, as well as other essentially 137 | equivalent rights anywhere in the world. 138 | 139 | m. You means the individual or entity exercising the Licensed Rights 140 | under this Public License. Your has a corresponding meaning. 141 | 142 | 143 | Section 2 -- Scope. 144 | 145 | a. License grant. 146 | 147 | 1. Subject to the terms and conditions of this Public License, 148 | the Licensor hereby grants You a worldwide, royalty-free, 149 | non-sublicensable, non-exclusive, irrevocable license to 150 | exercise the Licensed Rights in the Licensed Material to: 151 | 152 | a. reproduce and Share the Licensed Material, in whole or 153 | in part; and 154 | 155 | b. produce, reproduce, and Share Adapted Material. 156 | 157 | 2. Exceptions and Limitations. For the avoidance of doubt, where 158 | Exceptions and Limitations apply to Your use, this Public 159 | License does not apply, and You do not need to comply with 160 | its terms and conditions. 161 | 162 | 3. Term. The term of this Public License is specified in Section 163 | 6(a). 164 | 165 | 4. Media and formats; technical modifications allowed. The 166 | Licensor authorizes You to exercise the Licensed Rights in 167 | all media and formats whether now known or hereafter created, 168 | and to make technical modifications necessary to do so. The 169 | Licensor waives and/or agrees not to assert any right or 170 | authority to forbid You from making technical modifications 171 | necessary to exercise the Licensed Rights, including 172 | technical modifications necessary to circumvent Effective 173 | Technological Measures. For purposes of this Public License, 174 | simply making modifications authorized by this Section 2(a) 175 | (4) never produces Adapted Material. 176 | 177 | 5. Downstream recipients. 178 | 179 | a. Offer from the Licensor -- Licensed Material. Every 180 | recipient of the Licensed Material automatically 181 | receives an offer from the Licensor to exercise the 182 | Licensed Rights under the terms and conditions of this 183 | Public License. 184 | 185 | b. Additional offer from the Licensor -- Adapted Material. 186 | Every recipient of Adapted Material from You 187 | automatically receives an offer from the Licensor to 188 | exercise the Licensed Rights in the Adapted Material 189 | under the conditions of the Adapter's License You apply. 190 | 191 | c. No downstream restrictions. You may not offer or impose 192 | any additional or different terms or conditions on, or 193 | apply any Effective Technological Measures to, the 194 | Licensed Material if doing so restricts exercise of the 195 | Licensed Rights by any recipient of the Licensed 196 | Material. 197 | 198 | 6. No endorsement. Nothing in this Public License constitutes or 199 | may be construed as permission to assert or imply that You 200 | are, or that Your use of the Licensed Material is, connected 201 | with, or sponsored, endorsed, or granted official status by, 202 | the Licensor or others designated to receive attribution as 203 | provided in Section 3(a)(1)(A)(i). 204 | 205 | b. Other rights. 206 | 207 | 1. Moral rights, such as the right of integrity, are not 208 | licensed under this Public License, nor are publicity, 209 | privacy, and/or other similar personality rights; however, to 210 | the extent possible, the Licensor waives and/or agrees not to 211 | assert any such rights held by the Licensor to the limited 212 | extent necessary to allow You to exercise the Licensed 213 | Rights, but not otherwise. 214 | 215 | 2. Patent and trademark rights are not licensed under this 216 | Public License. 217 | 218 | 3. To the extent possible, the Licensor waives any right to 219 | collect royalties from You for the exercise of the Licensed 220 | Rights, whether directly or through a collecting society 221 | under any voluntary or waivable statutory or compulsory 222 | licensing scheme. In all other cases the Licensor expressly 223 | reserves any right to collect such royalties. 224 | 225 | 226 | Section 3 -- License Conditions. 227 | 228 | Your exercise of the Licensed Rights is expressly made subject to the 229 | following conditions. 230 | 231 | a. Attribution. 232 | 233 | 1. If You Share the Licensed Material (including in modified 234 | form), You must: 235 | 236 | a. retain the following if it is supplied by the Licensor 237 | with the Licensed Material: 238 | 239 | i. identification of the creator(s) of the Licensed 240 | Material and any others designated to receive 241 | attribution, in any reasonable manner requested by 242 | the Licensor (including by pseudonym if 243 | designated); 244 | 245 | ii. a copyright notice; 246 | 247 | iii. a notice that refers to this Public License; 248 | 249 | iv. a notice that refers to the disclaimer of 250 | warranties; 251 | 252 | v. a URI or hyperlink to the Licensed Material to the 253 | extent reasonably practicable; 254 | 255 | b. indicate if You modified the Licensed Material and 256 | retain an indication of any previous modifications; and 257 | 258 | c. indicate the Licensed Material is licensed under this 259 | Public License, and include the text of, or the URI or 260 | hyperlink to, this Public License. 261 | 262 | 2. You may satisfy the conditions in Section 3(a)(1) in any 263 | reasonable manner based on the medium, means, and context in 264 | which You Share the Licensed Material. For example, it may be 265 | reasonable to satisfy the conditions by providing a URI or 266 | hyperlink to a resource that includes the required 267 | information. 268 | 269 | 3. If requested by the Licensor, You must remove any of the 270 | information required by Section 3(a)(1)(A) to the extent 271 | reasonably practicable. 272 | 273 | b. ShareAlike. 274 | 275 | In addition to the conditions in Section 3(a), if You Share 276 | Adapted Material You produce, the following conditions also apply. 277 | 278 | 1. The Adapter's License You apply must be a Creative Commons 279 | license with the same License Elements, this version or 280 | later, or a BY-SA Compatible License. 281 | 282 | 2. You must include the text of, or the URI or hyperlink to, the 283 | Adapter's License You apply. You may satisfy this condition 284 | in any reasonable manner based on the medium, means, and 285 | context in which You Share Adapted Material. 286 | 287 | 3. You may not offer or impose any additional or different terms 288 | or conditions on, or apply any Effective Technological 289 | Measures to, Adapted Material that restrict exercise of the 290 | rights granted under the Adapter's License You apply. 291 | 292 | 293 | Section 4 -- Sui Generis Database Rights. 294 | 295 | Where the Licensed Rights include Sui Generis Database Rights that 296 | apply to Your use of the Licensed Material: 297 | 298 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 299 | to extract, reuse, reproduce, and Share all or a substantial 300 | portion of the contents of the database; 301 | 302 | b. if You include all or a substantial portion of the database 303 | contents in a database in which You have Sui Generis Database 304 | Rights, then the database in which You have Sui Generis Database 305 | Rights (but not its individual contents) is Adapted Material, 306 | 307 | including for purposes of Section 3(b); and 308 | c. You must comply with the conditions in Section 3(a) if You Share 309 | all or a substantial portion of the contents of the database. 310 | 311 | For the avoidance of doubt, this Section 4 supplements and does not 312 | replace Your obligations under this Public License where the Licensed 313 | Rights include other Copyright and Similar Rights. 314 | 315 | 316 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 317 | 318 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 319 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 320 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 321 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 322 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 323 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 324 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 325 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 326 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 327 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 328 | 329 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 330 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 331 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 332 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 333 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 334 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 335 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 336 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 337 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 338 | 339 | c. The disclaimer of warranties and limitation of liability provided 340 | above shall be interpreted in a manner that, to the extent 341 | possible, most closely approximates an absolute disclaimer and 342 | waiver of all liability. 343 | 344 | 345 | Section 6 -- Term and Termination. 346 | 347 | a. This Public License applies for the term of the Copyright and 348 | Similar Rights licensed here. However, if You fail to comply with 349 | this Public License, then Your rights under this Public License 350 | terminate automatically. 351 | 352 | b. Where Your right to use the Licensed Material has terminated under 353 | Section 6(a), it reinstates: 354 | 355 | 1. automatically as of the date the violation is cured, provided 356 | it is cured within 30 days of Your discovery of the 357 | violation; or 358 | 359 | 2. upon express reinstatement by the Licensor. 360 | 361 | For the avoidance of doubt, this Section 6(b) does not affect any 362 | right the Licensor may have to seek remedies for Your violations 363 | of this Public License. 364 | 365 | c. For the avoidance of doubt, the Licensor may also offer the 366 | Licensed Material under separate terms or conditions or stop 367 | distributing the Licensed Material at any time; however, doing so 368 | will not terminate this Public License. 369 | 370 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 371 | License. 372 | 373 | 374 | Section 7 -- Other Terms and Conditions. 375 | 376 | a. The Licensor shall not be bound by any additional or different 377 | terms or conditions communicated by You unless expressly agreed. 378 | 379 | b. Any arrangements, understandings, or agreements regarding the 380 | Licensed Material not stated herein are separate from and 381 | independent of the terms and conditions of this Public License. 382 | 383 | 384 | Section 8 -- Interpretation. 385 | 386 | a. For the avoidance of doubt, this Public License does not, and 387 | shall not be interpreted to, reduce, limit, restrict, or impose 388 | conditions on any use of the Licensed Material that could lawfully 389 | be made without permission under this Public License. 390 | 391 | b. To the extent possible, if any provision of this Public License is 392 | deemed unenforceable, it shall be automatically reformed to the 393 | minimum extent necessary to make it enforceable. If the provision 394 | cannot be reformed, it shall be severed from this Public License 395 | without affecting the enforceability of the remaining terms and 396 | conditions. 397 | 398 | c. No term or condition of this Public License will be waived and no 399 | failure to comply consented to unless expressly agreed to by the 400 | Licensor. 401 | 402 | d. Nothing in this Public License constitutes or may be interpreted 403 | as a limitation upon, or waiver of, any privileges and immunities 404 | that apply to the Licensor or You, including from the legal 405 | processes of any jurisdiction or authority. 406 | 407 | 408 | ======================================================================= 409 | 410 | Creative Commons is not a party to its public 411 | licenses. Notwithstanding, Creative Commons may elect to apply one of 412 | its public licenses to material it publishes and in those instances 413 | will be considered the “Licensor.” The text of the Creative Commons 414 | public licenses is dedicated to the public domain under the CC0 Public 415 | Domain Dedication. Except for the limited purpose of indicating that 416 | material is shared under a Creative Commons public license or as 417 | otherwise permitted by the Creative Commons policies published at 418 | creativecommons.org/policies, Creative Commons does not authorize the 419 | use of the trademark "Creative Commons" or any other trademark or logo 420 | of Creative Commons without its prior written consent including, 421 | without limitation, in connection with any unauthorized modifications 422 | to any of its public licenses or any other arrangements, 423 | understandings, or agreements concerning use of licensed material. For 424 | the avoidance of doubt, this paragraph does not form part of the 425 | public licenses. 426 | 427 | Creative Commons may be contacted at creativecommons.org. 428 | --------------------------------------------------------------------------------