diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e7848915f..f6eba47d7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,7 @@ ## Getting Started -When contributing to Monkeytype, it's good to know our best practices, tips, and tricks. First, Monkeytype is written in ~~JavaScript~~ TypeScript, CSS, and HTML (in order of language usage within the project); thus, we assume you are comfortable in these languages or have basic knowledge of them. Our backend is in NodeJS and we use MongoDB to store our user data. Firebase is used for authentication. Furthermore, we use Prettier to format our code. +When contributing to Monkeytype, it's good to know our best practices, tips, and tricks. First, Monkeytype is written in ~~JavaScript~~ TypeScript, CSS, and HTML (in order of language usage within the project); thus, we assume you are comfortable in these languages or have basic knowledge of them. Our backend is in NodeJS and we use MongoDB to store our user data. Firebase is used for authentication. Redis is used to store daily leaderboard data. Furthermore, we use Prettier to format our code. ## How to Contribute diff --git a/frontend/src/styles/core.scss b/frontend/src/styles/core.scss index 2aa962a29..a7c4695fa 100644 --- a/frontend/src/styles/core.scss +++ b/frontend/src/styles/core.scss @@ -42,6 +42,11 @@ /* Firefox */ } +::selection { + background-color: var(--main-color); + color: var(--sub-alt-color); +} + #app { display: grid; grid-template-columns: auto minmax(0, 1000px) auto; diff --git a/frontend/src/ts/test/test-logic.ts b/frontend/src/ts/test/test-logic.ts index db81dd8c1..1ea026c8f 100644 --- a/frontend/src/ts/test/test-logic.ts +++ b/frontend/src/ts/test/test-logic.ts @@ -260,8 +260,50 @@ export async function punctuateWord( } } else if (Math.random() < 0.25 && currentLanguage == "code") { const specials = ["{", "}", "[", "]", "(", ")", ";", "=", "+", "%", "/"]; + const specialsC = [ + "{", + "}", + "[", + "]", + "(", + ")", + ";", + "=", + "+", + "%", + "/", + "/*", + "*/", + "//", + "!=", + "==", + "<=", + ">=", + "||", + "&&", + "<<", + ">>", + "%=", + "&=", + "*=", + "++", + "+=", + "--", + "-=", + "/=", + "^=", + "|=", + ]; - word = Misc.randomElementFromArray(specials); + if ( + (Config.language.startsWith("code_c") && + !Config.language.startsWith("code_css")) || + Config.language.startsWith("code_arduino") + ) { + word = Misc.randomElementFromArray(specialsC); + } else { + word = Misc.randomElementFromArray(specials); + } } else if ( Math.random() < 0.5 && currentLanguage === "english" && diff --git a/frontend/static/languages/code_arduino.json b/frontend/static/languages/code_arduino.json index 934969bfc..d57fe2983 100644 --- a/frontend/static/languages/code_arduino.json +++ b/frontend/static/languages/code_arduino.json @@ -1,111 +1,111 @@ { - "name": "code_arduino", - "leftToRight": true, - "noLazyMode": true, - "words": [ - "digitalRead", - "digitalWrite", - "pinMode", - "analogRead", - "analogReference", - "analogWrite", - "analogReadResolution", - "analogWriteResolution", - "noTone", - "pulseIn", - "pulseInLong", - "shiftIn", - "shiftOut", - "tone", - "delay", - "delayMicroseconds", - "micros", - "millis", - "abs", - "constrain", - "map", - "max", - "min", - "pow", - "sq", - "sqrt", - "cos", - "sin", - "tan", - "isAlpha", - "isAlphaNumeric", - "isAscii", - "isControl", - "isDigit", - "isGraph", - "isHexadecimalDigit", - "isLowerCase", - "isPrintable", - "isPunct", - "isSpace", - "isUpperCase", - "isWhitespace", - "random", - "randomSeed", - "bit", - "bitClear", - "bitRead", - "bitSet", - "bitWrite", - "highByte", - "lowByte", - "attachInterrupt", - "detachInterrupt", - "interrupts", - "noInterrupts", - "Serial", - "SPI", - "Stream", - "Wire", - "Keyboard", - "Mouse", - "HIGH", - "LOW", - "INPUT", - "OUTPUT", - "INPUT_PULLUP", - "LED_BUILTIN", - "true", - "false", - "bool", - "boolean", - "byte", - "char", - "double", - "float", - "int", - "long", - "short", - "size_t", - "string", - "String", - "unsigned", - "void", - "word", - "const", - "static", - "volatile", - "PROGMEM", - "sizeof", - "loop", - "setup", - "break", - "continue", - "do", - "else", - "for", - "goto", - "if", - "return", - "switch", - "case", - "while", - "#define", - "#include" - ] + "name": "code_arduino", + "leftToRight": true, + "noLazyMode": true, + "words": [ + "digitalRead", + "digitalWrite", + "pinMode", + "analogRead", + "analogReference", + "analogWrite", + "analogReadResolution", + "analogWriteResolution", + "noTone", + "pulseIn", + "pulseInLong", + "shiftIn", + "shiftOut", + "tone", + "delay", + "delayMicroseconds", + "micros", + "millis", + "abs", + "constrain", + "map", + "max", + "min", + "pow", + "sq", + "sqrt", + "cos", + "sin", + "tan", + "isAlpha", + "isAlphaNumeric", + "isAscii", + "isControl", + "isDigit", + "isGraph", + "isHexadecimalDigit", + "isLowerCase", + "isPrintable", + "isPunct", + "isSpace", + "isUpperCase", + "isWhitespace", + "random", + "randomSeed", + "bit", + "bitClear", + "bitRead", + "bitSet", + "bitWrite", + "highByte", + "lowByte", + "attachInterrupt", + "detachInterrupt", + "interrupts", + "noInterrupts", + "Serial", + "SPI", + "Stream", + "Wire", + "Keyboard", + "Mouse", + "HIGH", + "LOW", + "INPUT", + "OUTPUT", + "INPUT_PULLUP", + "LED_BUILTIN", + "true", + "false", + "bool", + "boolean", + "byte", + "char", + "double", + "float", + "int", + "long", + "short", + "size_t", + "string", + "String", + "unsigned", + "void", + "word", + "const", + "static", + "volatile", + "PROGMEM", + "sizeof", + "loop", + "setup", + "break", + "continue", + "do", + "else", + "for", + "goto", + "if", + "return", + "switch", + "case", + "while", + "#define", + "#include" + ] } diff --git a/frontend/static/languages/code_c.json b/frontend/static/languages/code_c.json index a9bd149e3..a04130f6d 100644 --- a/frontend/static/languages/code_c.json +++ b/frontend/static/languages/code_c.json @@ -3,55 +3,205 @@ "leftToRight": true, "noLazyMode": true, "words": [ - "int", - "char", - "unsigned", - "float", - "void", - "main", - "union", - "long", - "double", - "printf", - "sprintf", - "if", - "else", - "struct", - "fork", - "switch", - "for", - "define", - "return", - "include", - "case", - "&&", - "||", + "auto", "break", - "bool", - "static", + "case", + "char", + "const", + "continue", + "default", + "do", + "double", + "else", "enum", + "extern", + "float", + "for", + "goto", + "if", + "inline", + "int", + "long", + "register", + "restrict", + "return", + "short", + "signed", + "sizeof", + "static", + "struct", + "switch", "typedef", - "exit", + "union", + "unsigned", + "void", + "volatile", + "while", + "_Decimal128", + "_Decimal32", + "_Decimal64", + "_Generic", + "#if", + "#elif", + "#else", + "#endif", + "#ifdef", + "#ifndef", + "#elifdef", + "#elifndef", + "#define", + "#undef", + "#include", + "#line", + "#error", + "#warning", + "#pragma", + "defined", + "__has_c_attribute", + "_Pragma", + "asm", + "fortran", + "", + "EDOM", + "EILSEQ", + "ERANGE", + "errno", + "assert", + "static_assert", + "", + "imaginary", + "complex", + "", + "int8_t", + "int16_t", + "int32_t", + "int64_t", + "int_fast8_t", + "int_fast16_t", + "int_fast32_t", + "int_fast64_t", + "int_least8_t", + "int_least16_t", + "int_least32_t", + "int_least64_t", + "intmax_t", + "intptr_t", + "uint8_t", + "uint16_t", + "uint32_t", + "uint64_t", + "uint_fast8_t", + "uint_fast16_t", + "uint_fast32_t", + "uint_fast64_t", + "uint_least8_t", + "uint_least16_t", + "uint_least32_t", + "uint_least64_t", + "uintmax_t", + "uintptr_t", "", + "FILE", + "stdin", + "stdout", + "stderr", + "fopen", + "fopen_s", + "freopen", + "freopen_s", + "fclose", + "fflush", + "setbuf", + "setvbuf", + "fgetc", + "getc", + "fputc", + "putc", "scanf", + "fscanf", + "sscanf", + "printf", + "fprintf", + "sprintf", + "EOF", "NULL", + "", "malloc", "calloc", - "free", "realloc", + "free", + "aligned_alloc", + "abort", + "exit", + "quick_exit", + "unreachable", + "system", + "getenv", + "signal", + "raise", + "setjmp", + "longjmp", + "rand", + "srand", + "qsort", + "bsearch", "", - "fgets", - "strcmp", + "tolower", + "toupper", + "atof", + "atoi", + "atol", + "atoll", + "strtol", + "strtoll", + "strtoul", + "strtoull", + "strtof", + "strtod", + "strtold", "strcpy", - "fputs", - "stdout", - "EOF", - "getc", - "while", - "fclose", - "fopen", - "do", - "fscanf", - "extern" + "strncpy", + "strcat", + "strncat", + "strlenstrnlen_s", + "strcmp", + "strncmp", + "strcoll", + "strchr", + "strrchr", + "strspn", + "strcspn", + "strpbrk", + "strstr", + "strtok", + "memchr", + "memcmp", + "memset", + "memcpy", + "memmove", + "", + "abs", + "div", + "exp", + "log", + "pow", + "sqrt", + "sin", + "cos", + "tan", + "asin", + "acos", + "atan", + "sinh", + "cosh", + "tanh", + "asinh", + "acosh", + "atanh", + "ceil", + "floor", + "round", + "INFINITY", + "NAN" ] } diff --git a/frontend/static/languages/code_python.json b/frontend/static/languages/code_python.json index 44a9fbcc3..043fcd145 100644 --- a/frontend/static/languages/code_python.json +++ b/frontend/static/languages/code_python.json @@ -23,6 +23,7 @@ "callable", "capitalise", "capitalize", + "case", "casefold", "ceil", "center", @@ -109,6 +110,7 @@ "lstrip", "maketrans", "map", + "match", "math", "max", "memoryview", diff --git a/frontend/static/languages/spanish.json b/frontend/static/languages/spanish.json index e2db70991..77e1e97f6 100644 --- a/frontend/static/languages/spanish.json +++ b/frontend/static/languages/spanish.json @@ -100,7 +100,7 @@ "vivir", "donde", "después", - "espalda", + "atrás", "poco", "ronda", "hombre", diff --git a/frontend/static/quotes/code_c++.json b/frontend/static/quotes/code_c++.json index a2d36ee37..f6c84baaa 100644 --- a/frontend/static/quotes/code_c++.json +++ b/frontend/static/quotes/code_c++.json @@ -14,9 +14,9 @@ "id": 1 }, { - "text": "float Q_rsqrt( float number )\\n{\\n long i;\\n float x2, y;\\n const float threehalfs = 1.5F;\\n\\n x2 = number * 0.5F;\\n y = number;\\n i = * ( long * ) &y; // evil floating point bit level hacking\\n i = 0x5f3759df - ( i >> 1 ); // what the fuck?\\n y = * ( float * ) &i;\\n y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration\\n return y;\\n}\\n", + "text": "float Q_rsqrt( float number )\\n{\\n\\tlong i;\\n\\tfloat x2, y;\\n\\tconst float threehalfs = 1.5F;\\n\\n\\tx2 = number * 0.5F;\\n\\ty = number;\\n\\ti = * ( long * ) &y;\\n\\ti = 0x5f3759df - ( i >> 1 );\\n\\ty = * ( float * ) &i;\\n\\ty = y * ( threehalfs - ( x2 * y * y ) );\\n\\treturn y;\\n}\\n", "source": "Quake III Arena Source Code (Fast Inverse Square Root)", - "length": 377, + "length": 281, "id": 2 }, { @@ -200,4 +200,4 @@ "id": 32 } ] -} +} \ No newline at end of file diff --git a/frontend/static/quotes/code_c.json b/frontend/static/quotes/code_c.json index 024650867..9410e7102 100644 --- a/frontend/static/quotes/code_c.json +++ b/frontend/static/quotes/code_c.json @@ -12,6 +12,24 @@ "source": "Linux Kernel Source Code", "length": 73, "id": 1 + }, + { + "text": "void reverse(char s[]) {\\n\\tint c, i, j;\\n\\tfor ( i = 0, j = strlen(s)-1; i < j; i++, j--) {\\n\\t\\tc = s[i];\\n\\t\\ts[i] = s[j];\\n\\t\\ts[j] = c;\\n\\t}\\n}\\nvoid itoa(int n, char s[], int width) {\\n\\tint i, sign;\\n\\tif ((sign = n) < 0)\\n\\t\\tn = -n;\\n\\ti = 0;\\n\\tdo {\\n\\t\\ts[i++] = n % 10 + '0';\\n\\t\\tprintf(\"%d %% %d + '0' = %d\\\\n\", n, 10, s[i-1]);\\n\\t} while ((n /= 10) > 0);\\n\\tif (sign < 0)\\n\\t\\ts[i++] = '-';\\n\\twhile (i < width)\\n\\t\\ts[i++] = ' ';\\n\\ts[i] = '\\\\0';\\n\\treverse(s);\\n}", + "source": "clc-wiki - atoi", + "length": 480, + "id": 2 + }, + { + "text": "int hexalpha_to_int(int c)\\n{\\n\\tchar hexalpha[] = \"aAbBcCdDeEfF\";\\n\\tint i;\\n\\tint answer = 0;\\n\\tfor(i = 0; answer == 0 && hexalpha[i] != '\\\\0'; i++)\\n\\t{\\n\\t\\tif(hexalpha[i] == c)\\n\\t\\t{\\n\\t\\t\\tanswer = 10 + (i / 2);\\n\\t\\t}\\n\\t}\\n\\treturn answer;\\n}\\nunsigned int htoi(const char s[])\\n{\\n\\tunsigned int answer = 0;\\n\\tint i = 0;\\n\\tint valid = 1;\\n\\tint hexit;\\n\\n\\tif(s[i] == '0')\\n\\t{\\n\\t\\t++i;\\n\\t\\tif(s[i] == 'x' || s[i] == 'X')\\n\\t\\t{\\n\\t\\t\\t++i;\\n\\t\\t}\\n\\t}\\n\\twhile(valid && s[i] != '\\\\0')\\n\\t{\\n\\t\\tanswer = answer * 16;\\n\\t\\tif(s[i] >= '0' && s[i] <= '9')\\n\\t\\t{\\n\\t\\t\\tanswer = answer + (s[i] - '0');\\n\\t\\t}\\n\\t\\telse\\n\\t\\t{\\n\\t\\t\\thexit = hexalpha_to_int(s[i]);\\n\\t\\t\\tif(hexit == 0)\\n\\t\\t\\t{\\n\\t\\t\\t\\tvalid = 0;\\n\\t\\t\\t}\\n\\t\\t\\telse\\n\\t\\t\\t{\\n\\t\\t\\t\\tanswer = answer + hexit;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t++i;\\n\\t}\\n\\tif(!valid)\\n\\t{\\n\\t\\tanswer = 0;\\n\\t}\\n\\treturn answer;\\n}", + "source": "clc-wiki - htoi", + "length": 884, + "id": 3 + }, + { + "text": "unsigned rightrot(unsigned x, unsigned n)\\n{\\n\\twhile (n > 0) {\\n\\t\\tif ((x & 1) == 1)\\n\\t\\t\\tx = (x >> 1) | ~(~0U >> 1);\\n\\t\\telse\\n\\t\\t\\tx = (x >> 1);\\n\\t\\tn--;\\n\\t}\\n\\treturn x;\\n}", + "source": "clc-wiki - rightrot", + "length": 183, + "id": 4 } ] -} +} \ No newline at end of file diff --git a/frontend/static/quotes/english.json b/frontend/static/quotes/english.json index 0cc065776..87da91a7d 100644 --- a/frontend/static/quotes/english.json +++ b/frontend/static/quotes/english.json @@ -35406,6 +35406,12 @@ "source": "Destiny 2: Forsaken - Uldren Sov", "length": 89, "id": 6221 + }, + { + "text": "During my lifetime I have dedicated myself to this struggle of the African people. I have fought against white domination, and I have fought against black domination. I have cherished the ideal of a democratic and free society in which all persons live together in harmony and with equal opportunities. It is an ideal which I hope to live for and to achieve. But if needs be, it is an ideal for which I am prepared to die.", + "source": "I am prepared to die - Nelson Mandela", + "length": 422, + "id": 6222 } ] } diff --git a/frontend/static/quotes/russian.json b/frontend/static/quotes/russian.json index a03cbb291..e331b1402 100644 --- a/frontend/static/quotes/russian.json +++ b/frontend/static/quotes/russian.json @@ -8,70 +8,70 @@ ], "quotes": [ { + "id": 1, + "source": "А. П. Чехов - Верочка.", "text": "Старик благодушно улыбался и кивал головой.", - "source": "А. П. Чехов - Верочка.", - "length": 43, - "id": 1 + "length": 43 }, { + "id": 2, + "source": "А. П. Чехов - Верочка.", "text": "Луна стояла высоко над садом, а ниже ее куда-то на восток неслись прозрачные туманные пятна.", - "source": "А. П. Чехов - Верочка.", - "length": 92, - "id": 2 + "length": 92 }, { - "text": "Не может же русский человек быть счастлив в одиночку, ему нужно участие окружающих, а без этого он не будет счастлив.", + "id": 3, "source": "В. Даль", - "length": 117, - "id": 3 + "text": "Не может же русский человек быть счастлив в одиночку, ему нужно участие окружающих, а без этого он не будет счастлив.", + "length": 117 }, { + "id": 4, + "source": "1984", "text": "Министерство любви внушало страх. В здании отсутствовали окна. Уинстон ни разу не переступал его порога, ни разу не подходил к нему ближе чем на полкилометра. Попасть туда можно было только по официальному делу, да и то преодолев целый лабиринт колючей проволоки, стальных дверей и замаскированных пулемётных гнезд. Даже на улицах, ведущих к внешнему кольцу ограждений, патрулировали охранники в чёрной форме, с лицами горилл, вооруженные суставчатыми дубинками.", - "source": "1984", - "length": 462, - "id": 4 + "length": 462 }, { + "id": 5, + "source": "Мы", "text": "Я уверен, что мы победим. Потому что разум должен победить.", - "source": "Мы", - "length": 59, - "id": 5 + "length": 59 }, { + "id": 6, + "source": "Мы", "text": "Вчерашний день был для меня той самой бумагой, через которую химики фильтруют свои растворы: все взвешенные частицы, всё лишнее остаётся на этой бумаге. И утром я спустился вниз начисто отдистиллированный, прозрачный.", - "source": "Мы", - "length": 217, - "id": 6 + "length": 217 }, { + "id": 7, + "source": "Незнайка на луне", "text": "Каждый, кто покупал \"Газету для дураков\", говорил, что он покупает ее не потому, что считает себя дураком, а потому, что ему интересно узнать, о чем там для дураков пишут. Кстати сказать, газета эта велась очень разумно. Всё в ней даже для дураков было понятно. В результате \"Газета для дураков\" расходилась в больших количествах.", - "source": "Незнайка на луне", - "length": 330, - "id": 7 + "length": 330 }, { + "id": 8, + "source": "Незнайка на луне", "text": "Знайка знал, что чем больше слов, тем больше путаницы, и к тому же был уверен, что слова \"В Солнечный город\" не могли означать ничего, кроме того, что он уехал в Солнечный город.", - "source": "Незнайка на луне", - "length": 178, - "id": 8 + "length": 178 }, { - "text": "Океания воевала с Остазией: Океания всегда воевала с Остазией.", + "id": 9, "source": "1984", - "length": 62, - "id": 9 + "text": "Океания воевала с Остазией: Океания всегда воевала с Остазией.", + "length": 62 }, { + "id": 10, + "source": "Собачье сердце", "text": "Лаской-с. Единственным способом, который возможен в обращении с живым существом. Террором ничего поделать нельзя с животным, на какой бы ступени развития оно ни стояло. Это я утверждал, утверждаю и буду утверждать. Они напрасно думают, что террор им поможет. Нет-с, нет-с, не поможет, какой бы он ни был: белый, красный и даже коричневый! Террор совершенно парализует нервную систему.", - "source": "Собачье сердце", - "length": 384, - "id": 10 + "length": 384 }, { - "text": "Сообразите, что весь ужас в том, что у него уже не собачье, а именно человеческое сердце. И самое паршивое из всех, которое существует в природе. Следовательно, разруха сидит не в клозетах, а в головах! Если вы заботитесь о своем пищеварении, вот добрый совет: не говорите за обедом о большевизме и о медицине.", + "id": 11, "source": "Собачье сердце", - "length": 310, - "id": 11 + "text": "Сообразите, что весь ужас в том, что у него уже не собачье, а именно человеческое сердце. И самое паршивое из всех, которое существует в природе. Следовательно, разруха сидит не в клозетах, а в головах! Если вы заботитесь о своем пищеварении, вот добрый совет: не говорите за обедом о большевизме и о медицине.", + "length": 310 }, { "id": 12, @@ -6084,6 +6084,72 @@ "source": "Джон Рональд Руэл Толкин - Хоббит, или Туда и обратно", "text": "Хоббит пережил во мраке пещеры настоящую битву с самим собой, пережил и победил!", "length": 80 + }, + { + "id": 1026, + "source": "Джоан Роулинг - Гарри Поттер и Принц-полукровка", + "text": "Величие порождает зависть, зависть рождает зло, ложь — искры зла. Вы должны знать это, Дамблдор.", + "length": 96 + }, + { + "id": 1027, + "source": "Джоан Роулинг - Гарри Поттер и Орден Феникса", + "text": "Всё, что мы теряем, обязательно к нам вернётся, только не всегда так, как мы ожидаем.", + "length": 85 + }, + { + "id": 1028, + "source": "Джоан Роулинг - Гарри Поттер и Дары Смерти", + "text": "Если не спросишь, никогда не узнаешь. Если знаешь, нужно лишь спросить.", + "length": 71 + }, + { + "id": 1029, + "source": "Фильм \"Апрель\" (2001 г.)", + "text": "У самурая нет цели, только путь.", + "length": 32 + }, + { + "id": 1030, + "source": "Джоан Роулинг - Гарри Поттер и Кубок Огня", + "text": "Любопытство не грех, Гарри, но надо быть немного терпеливее.", + "length": 60 + }, + { + "id": 1031, + "source": "Джоан Роулинг - Гарри Поттер и Философский Камень", + "text": "Страх перед именем усиливает страх перед тем, кто его носит.", + "length": 60 + }, + { + "id": 1032, + "source": "Джоан Роулинг - Гарри Поттер и Орден Феникса", + "text": "Не забывайте о том, что все великие волшебники в истории в свое время были такими же, как мы, – школьниками. Если у них получилось, то получится и у нас.", + "length": 153 + }, + { + "id": 1033, + "source": "Джоан Роулинг - Гарри Поттер и Философский Камень", + "text": "Требуется большое мужество, чтобы противостоять своим врагам... но еще сложнее противостоять своим друзьям.", + "length": 107 + }, + { + "id": 1034, + "source": "Джоан Роулинг - Гарри Поттер и Узник Азкабана", + "text": "Выходит, больше всего на свете ты боишься страха. Это похвально!", + "length": 64 + }, + { + "id": 1035, + "source": "Джоан Роулинг - Гарри Поттер и Орден Феникса", + "text": "На свете нет ничего невозможного — дело только в том, хватит ли у тебя храбрости.", + "length": 81 + }, + { + "id": 1036, + "source": "Джоан Роулинг - Гарри Поттер и Узник Азкабана", + "text": "Счастье можно найти даже в темные времена, если не забывать обращаться к свету.", + "length": 79 } ] }