[READ-ONLY] Mirror of https://github.com/probablykasper/ferrum. Music library app for Mac, Linux and Windows ferrum.kasper.space
electron linux macos music music-library music-player napi windows
0

Configure Feed

Select the types of activity you want to include in your feed.

Initial commit

Kasper (Jul 14, 2019, 3:05 AM +0200) b59d237a

+613
+2
.gitattributes
··· 1 + # Auto detect text files and perform LF normalization 2 + * text=auto
+8
.htaccess
··· 1 + RewriteEngine On 2 + 3 + #skip existing files or directories 4 + RewriteCond %{REQUEST_FILENAME} !-f 5 + RewriteCond %{REQUEST_FILENAME} !-d 6 + 7 + #everything else goes to index.php 8 + RewriteRule ^ index.php?request=%{THE_REQUEST} [L]
.sass-cache/7606f85a0411ac911e8bd245f93950d410726a7f/global.sassc

This is a binary file and will not be displayed.

.sass-cache/7606f85a0411ac911e8bd245f93950d410726a7f/main.sassc

This is a binary file and will not be displayed.

+100
css/global backup.sass
··· 1 + // sass --watch css/global.sass:css/global.css 2 + 3 + $c-dark: #282c35 4 + $c-light: #323742 5 + $c-accent: #03A9F4 6 + 7 + 8 + body 9 + background-color: $c-dark 10 + margin: 0px 11 + width: 100% 12 + height: 100% 13 + font-family: "Roboto", sans-serif 14 + color: white 15 + -webkit-font-smoothing: antialiased 16 + p 17 + text-align: center 18 + font-size: 18px 19 + margin: 0 20 + a 21 + text-decoration: none 22 + outline: none 23 + h1 24 + text-align: center 25 + font-size: 40px 26 + font-weight: normal 27 + margin-top: 25px 28 + margin-bottom: 25px 29 + 30 + main.home 31 + 32 + div.login-div 33 + position: absolute 34 + top: 50% 35 + left: 50% 36 + transform: translate(-50%, -50%) 37 + 38 + form 39 + 40 + div 41 + display: flex 42 + 43 + input 44 + color: rgba(#FFFFFF, 0.6) 45 + background-color: $c-light 46 + border: none 47 + border-radius: 2px 48 + width: 150px 49 + padding: 5px 50 + margin: 10px 3px 51 + font-size: 20px 52 + 53 + &:focus 54 + outline: none 55 + 56 + &[name="submit_login"], &[name="submit_register"] 57 + width: auto 58 + color: $c-accent 59 + margin: auto 60 + display: block 61 + transition: color 0.2s ease 62 + background-color: rgba(#000000, 0) 63 + cursor: pointer 64 + 65 + &:hover 66 + color: rgba($c-accent, 0.8) 67 + 68 + form 69 + 70 + input[type="submit"] 71 + border: none 72 + padding: 5px 73 + font-size: 20px 74 + color: $c-accent 75 + margin: auto 76 + display: block 77 + transition: color 0.2s ease 78 + background-color: rgba(#000000, 0) 79 + cursor: pointer 80 + 81 + &:focus 82 + outline: none 83 + 84 + &:hover 85 + color: rgba($c-accent, 0.8) 86 + 87 + a 88 + position: absolute 89 + left: 50% 90 + bottom: 5px 91 + transform: translate(-50%, -50%) 92 + 93 + p 94 + color: $c-accent 95 + transition: color 0.2s ease 96 + 97 + &:hover, &:focus 98 + cursor: pointer 99 + p 100 + color: rgba($c-accent, 0.8)
+95
css/global.css
··· 1 + body { 2 + background-color: #282c35; 3 + margin: 0px; 4 + width: 100%; 5 + height: 100%; 6 + font-family: "Roboto", sans-serif; 7 + color: white; 8 + -webkit-font-smoothing: antialiased; } 9 + 10 + p { 11 + text-align: center; 12 + font-size: 18px; 13 + margin: 0; } 14 + 15 + a { 16 + text-decoration: none; 17 + outline: none; } 18 + 19 + h1 { 20 + text-align: center; 21 + font-size: 40px; 22 + font-weight: normal; 23 + margin-top: 25px; 24 + margin-bottom: 25px; } 25 + 26 + main.home div.login-div { 27 + position: absolute; 28 + top: 50%; 29 + left: 50%; 30 + transform: translate(-50%, -50%); } 31 + main.home div.login-div div { 32 + display: flex; } 33 + main.home form input { 34 + color: rgba(255, 255, 255, 0.6); 35 + background-color: #323742; 36 + border: none; 37 + border-radius: 2px; 38 + width: 150px; 39 + padding: 5px; 40 + margin: 10px 3px; 41 + font-size: 17px; } 42 + main.home form input:focus { 43 + outline: none; } 44 + main.home form input[type="submit"] { 45 + font-size: 20px; 46 + color: #03A9F4; 47 + width: auto; 48 + margin: auto; 49 + display: block; 50 + transition: color 0.2s ease; 51 + background-color: transparent; 52 + cursor: pointer; } 53 + main.home form input[type="submit"]:hover { 54 + color: rgba(3, 169, 244, 0.8); } 55 + main.home a { 56 + position: absolute; 57 + left: 50%; 58 + bottom: 5px; 59 + transform: translate(-50%, -50%); } 60 + main.home a p { 61 + color: #03A9F4; 62 + transition: color 0.2s ease; } 63 + main.home a:hover, main.home a:focus { 64 + cursor: pointer; } 65 + main.home a:hover p, main.home a:focus p { 66 + color: rgba(3, 169, 244, 0.8); } 67 + main.home div.chat-box { 68 + width: 400px; 69 + position: absolute; 70 + transform: translateX(-50%); 71 + left: 50%; } 72 + main.home div.chat-box div.chat-message { 73 + height: 50px; 74 + margin: 10px 0px; 75 + border-radius: 2px; } 76 + main.home div.chat-box div.chat-message p { 77 + text-align: left; } 78 + main.home div.chat-box div.chat-message:nth-child(2n) { 79 + background-color: #242933; } 80 + main.home div.chat-box div.chat-message:nth-child(2n-1) { 81 + background-color: #323742; } 82 + main.home div.chat-box div.chat-typer { 83 + width: 100%; 84 + margin: 10px 0px; } 85 + main.home div.chat-box div.chat-typer input { 86 + background-color: #323742; 87 + border: none; 88 + outline: none; 89 + width: 390px; 90 + border-radius: 2px; 91 + padding: 5px; 92 + font-size: 17px; 93 + color: rgba(255, 255, 255, 0.6); } 94 + 95 + /*# sourceMappingURL=global.css.map */
+7
css/global.css.map
··· 1 + { 2 + "version": 3, 3 + "mappings": "AAQA,IAAI;EACH,gBAAgB,EAPR,OAAO;EAQf,MAAM,EAAE,GAAG;EACX,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,IAAI;EACZ,WAAW,EAAE,oBAAoB;EACjC,KAAK,EAAE,KAAK;EACZ,sBAAsB,EAAE,WAAW;;AACpC,CAAC;EACA,UAAU,EAAE,MAAM;EAClB,SAAS,EAAE,IAAI;EACf,MAAM,EAAE,CAAC;;AACV,CAAC;EACA,eAAe,EAAE,IAAI;EACrB,OAAO,EAAE,IAAI;;AACd,EAAE;EACD,UAAU,EAAE,MAAM;EAClB,SAAS,EAAE,IAAI;EACf,WAAW,EAAE,MAAM;EACnB,UAAU,EAAE,IAAI;E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V,OAAO;EAoGf,qCAAc;IAGb,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,QAAQ;IAEhB,2CAAK;MACJ,gBAAgB,EA3GV,OAAO;MA4Gb,MAAM,EAAE,IAAI;MACZ,OAAO,EAAE,IAAI;MACb,KAAK,EAAE,KAAK;MACZ,aAAa,EAAE,GAAG;MAClB,OAAO,EAAE,GAAG;MACZ,SAAS,EAAE,IAAI;MACf,KAAK,EAAE,wBAAkB", 4 + "sources": ["global.sass"], 5 + "names": [], 6 + "file": "global.css" 7 + }
+119
css/global.sass
··· 1 + // sass --watch css/global.sass:css/global.css 2 + 3 + $c-dark: #282c35 4 + $c-dark-2: #242933 5 + $c-light: #323742 6 + $c-accent: #03A9F4 7 + 8 + 9 + body 10 + background-color: $c-dark 11 + margin: 0px 12 + width: 100% 13 + height: 100% 14 + font-family: "Roboto", sans-serif 15 + color: white 16 + -webkit-font-smoothing: antialiased 17 + p 18 + text-align: center 19 + font-size: 18px 20 + margin: 0 21 + a 22 + text-decoration: none 23 + outline: none 24 + h1 25 + text-align: center 26 + font-size: 40px 27 + font-weight: normal 28 + margin-top: 25px 29 + margin-bottom: 25px 30 + 31 + main.home 32 + 33 + div.login-div 34 + position: absolute 35 + top: 50% 36 + left: 50% 37 + transform: translate(-50%, -50%) 38 + 39 + div 40 + display: flex 41 + 42 + form 43 + 44 + input 45 + color: rgba(#FFFFFF, 0.6) 46 + background-color: $c-light 47 + border: none 48 + border-radius: 2px 49 + width: 150px 50 + padding: 5px 51 + margin: 10px 3px 52 + font-size: 17px 53 + 54 + &:focus 55 + outline: none 56 + 57 + &[type="submit"] 58 + font-size: 20px 59 + color: $c-accent 60 + width: auto 61 + margin: auto 62 + display: block 63 + transition: color 0.2s ease 64 + background-color: rgba(#000000, 0) 65 + cursor: pointer 66 + &:hover 67 + color: rgba($c-accent, 0.8) 68 + 69 + a 70 + position: absolute 71 + left: 50% 72 + bottom: 5px 73 + transform: translate(-50%, -50%) 74 + 75 + p 76 + color: $c-accent 77 + transition: color 0.2s ease 78 + 79 + &:hover, &:focus 80 + cursor: pointer 81 + p 82 + color: rgba($c-accent, 0.8) 83 + 84 + div.chat-box 85 + width: 400px 86 + // height: 100% 87 + position: absolute 88 + transform: translateX(-50%) 89 + left: 50% 90 + 91 + div.chat-message 92 + height: 50px 93 + margin: 10px 0px 94 + border-radius: 2px 95 + 96 + p 97 + text-align: left 98 + 99 + &:nth-child(2n) 100 + background-color: $c-dark-2 101 + 102 + &:nth-child(2n-1) 103 + background-color: $c-light 104 + 105 + div.chat-typer 106 + // bottom: 0 107 + // position: absolute 108 + width: 100% 109 + margin: 10px 0px 110 + 111 + input 112 + background-color: $c-light 113 + border: none 114 + outline: none 115 + width: 390px 116 + border-radius: 2px 117 + padding: 5px 118 + font-size: 17px 119 + color: rgba(#FFFFFF, 0.6)
+53
home.php
··· 1 + <main class="home"> 2 + 3 + <? if($logged_out): ?> 4 + 5 + <div class="login-div"> 6 + <h1>Ferrum</h1> 7 + <form action="" method="post"> 8 + <div> 9 + <input type="text" name="username" value="<?= htmlentities($typed_username);?>"/> 10 + <input type="password" name="password" value=""/> 11 + </div> 12 + <div> 13 + <input type="submit" name="submit_login" value="Login"/> 14 + </div> 15 + </form> 16 + </div> 17 + <a class="register-link" href="/register"> 18 + <p>Register instead</p> 19 + </a> 20 + 21 + <? elseif($logged_in): ?> 22 + 23 + <p>Welcome back, <?=$username;?>!</p> 24 + <form action="" method="post"> 25 + <input type="submit" name="submit_logout" value="Logout"/> 26 + </form> 27 + <div class="chat-box"> 28 + <div class="chat-message"> 29 + <p>Here it is</p> 30 + </div> 31 + <div class="chat-message"> 32 + <p>Here it is again</p> 33 + </div> 34 + <div class="chat-message"> 35 + <p>Here it is and again</p> 36 + </div> 37 + <div class="chat-message"> 38 + <p>Here it is aaand here</p> 39 + </div> 40 + <div class="chat-message"> 41 + <p>Here it is plus here</p> 42 + </div> 43 + <div class="chat-message"> 44 + <p>Here it is so yeah</p> 45 + </div> 46 + <div class="chat-typer"> 47 + <input type="text"> 48 + </div> 49 + </div> 50 + 51 + </main> 52 + 53 + <? endif; ?>
+62
includes/check_login.php
··· 1 + <? 2 + 3 + $username = ""; 4 + $typed_username = ""; 5 + $typed_email = ""; 6 + 7 + if (isset($_POST["submit_logout"])) { 8 + $_SESSION["logged_in"] = false; 9 + $_SESSION["username"] = NULL; 10 + } 11 + 12 + if (isset($_POST["submit_login"])) { 13 + $username = $_POST["username"]; 14 + $typed_username = $username; 15 + $username = mysqli_real_escape_string($db_connection, $username); 16 + 17 + $password = $_POST["password"]; 18 + $query = db_query("SELECT * FROM logins WHERE username = '{$username}' LIMIT 1"); 19 + 20 + if ($user = mysqli_fetch_assoc($query)) { 21 + if ($user["password"] == $password) { 22 + $_SESSION["logged_in"] = true; 23 + $username = $user["username"]; 24 + $username = htmlentities($username); 25 + $_SESSION["username"] = $username; 26 + } 27 + } else { 28 + $_SESSION["logged_in"] = false; 29 + } 30 + } 31 + 32 + if (isset($_POST["submit_register"])) { 33 + $username = $_POST["username"]; 34 + $typed_username = $username; 35 + $username = mysqli_real_escape_string($db_connection, $username); 36 + 37 + $email = $_POST["email"]; 38 + $typed_email = $email; 39 + $email = mysqli_real_escape_string($db_connection, $email); 40 + 41 + $password = $_POST["password"]; 42 + $password = mysqli_real_escape_string($db_connection, $password); 43 + $password_repeat = $_POST["password_repeat"]; 44 + $password_repeat = mysqli_real_escape_string($db_connection, $password_repeat); 45 + 46 + $query = db_query("SELECT * FROM logins WHERE username = '{$username}' LIMIT 1"); 47 + if ($user = mysqli_fetch_assoc($query)) { 48 + // username exists already 49 + echo "Username already taken"; 50 + } else { 51 + // username is unique 52 + $query = db_query("INSERT INTO logins VALUES ('{$email}','{$username}','{$password}')"); 53 + } 54 + } 55 + 56 + session_to_string("logged_in"); 57 + session_to_string("username"); 58 + session_to_string("email"); 59 + 60 + $logged_out = !$logged_in; 61 + 62 + ?>
+101
includes/functions.php
··· 1 + <? 2 + 3 + $site_address = "http://localhost"; 4 + 5 + function get_slug() { 6 + global $slug; 7 + $slug = $_SERVER["REQUEST_URI"]; 8 + $slug = explode("?", $slug, 2); 9 + $slug = $slug[0]; 10 + $slug = strtolower($slug); 11 + return $slug; 12 + } 13 + 14 + function redirect_from_to($from_slug, $to_url) { 15 + global $slug; 16 + global $site_address; 17 + if ($slug == $from_slug) { 18 + header("Location: $site_address$to_url"); 19 + die(); 20 + } 21 + } 22 + function redirect_if() { 23 + redirect_from_to("/home", ""); 24 + } 25 + function redirect_to($to_url) { 26 + global $slug; 27 + redirect_from_to("$slug", "$to_url"); 28 + } 29 + 30 + function db_connect() { 31 + global $db_connection; 32 + $host = "localhost"; 33 + $username = "web"; 34 + $password = "pass"; 35 + $db_name = "ferrum"; 36 + $db_connection = mysqli_connect($host, $username, $password, $db_name); 37 + } 38 + function db_disconnect() { 39 + // 5. Disconnect from db 40 + global $db_connection; 41 + mysqli_close($db_connection); 42 + } 43 + function db_query($query, $max_1_affected_row = false) { 44 + // true to require only 1 affected row 45 + global $db_connection; 46 + $result = mysqli_query($db_connection, $query); 47 + 48 + // Test for query error 49 + if ($max_1_affected_row = true) { 50 + $result 51 + ? /*success*/ 52 + : die("Datatabse query failed. " . mysqli_error($db_connection)); 53 + } else { 54 + $result && mysqli_affected_rows($db_connection) == 1 55 + ? /*success*/ 56 + : die("Datatabse query failed. " . mysqli_error($db_connection)); 57 + } 58 + return $result; 59 + } 60 + 61 + function validate_upload_image($target_file) { 62 + // Check if file already exists 63 + if (file_exists($target_file)) { 64 + die("File already exists"); 65 + } 66 + // Validate file size 67 + if ($_FILES["cover_upload"]["size"] > 5000000) { 68 + die("File is too large."); 69 + } 70 + // Validate format 71 + global $imageFileType; 72 + if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") { 73 + die("Sorry, only JPG, JPEG, PNG & GIF files are allowed."); 74 + } 75 + } 76 + 77 + function encode_for_slug($string) { 78 + $string = strtolower($string); 79 + $string = str_replace([" "], "-", $string); 80 + $string = str_replace([",", "'", '"'], "", $string); 81 + return $string; 82 + } 83 + 84 + function session_to_string($session_index) { 85 + if (isset($_SESSION["$session_index"])) { 86 + $session_value = $_SESSION["$session_index"]; 87 + global $$session_index; 88 + $$session_index = $session_value; 89 + } 90 + } 91 + function post_to_sql_string($post_index) { 92 + if (isset($_POST["$post_index"])) { 93 + $post_value = $_POST["$post_index"]; 94 + global $db_connection; 95 + $post_value = mysqli_real_escape_string($db_connection, $post_value); 96 + global $$post_index; 97 + $$post_index = $post_value; 98 + } 99 + } 100 + 101 + ?>
+32
index.php
··· 1 + <? 2 + session_start(); 3 + include("./includes/functions.php"); 4 + get_slug(); 5 + redirect_if(); 6 + db_connect(); 7 + 8 + include("./includes/check_login.php"); 9 + 10 + if ($slug == "/") { 11 + $include_path = "home.php"; 12 + } elseif ($slug == "/register") { 13 + $include_path = "register.php"; 14 + } else { 15 + // redirect_to(""); 16 + } 17 + ?> 18 + 19 + <!DOCTYPE html> 20 + <html> 21 + <head> 22 + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 23 + <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" type="text/css"> 24 + <link rel="stylesheet" type="text/css" href="/css/global.css"> 25 + </head> 26 + <body> 27 + <? include("$include_path"); ?> 28 + <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> 29 + <script src="/js/global.js"></script> 30 + </body> 31 + </html> 32 + <? db_disconnect(); ?>
+5
js/global.js
··· 1 + $("document").ready(function() { 2 + 3 + $("").fadeIn("slow"); 4 + 5 + });
+29
register.php
··· 1 + <main class="home"> 2 + 3 + <? if($logged_out): ?> 4 + 5 + <div class="login-div"> 6 + <h1>Ferrum</h1> 7 + <form action="/" method="post"> 8 + <div> 9 + <input type="text" name="username" value="<?= htmlentities($typed_username);?>" placeholder="Username"/> 10 + <input type="text" name="email" value="<?= htmlentities($typed_email);?>" placeholder="Email"/> 11 + </div> 12 + <div> 13 + <input type="password" name="password" value="" placeholder="Password"/> 14 + <input type="password" name="password_repeat" value="" placeholder="Password again"/> 15 + </div> 16 + <div> 17 + <input type="submit" name="submit_register" value="Register"/> 18 + </div> 19 + </form> 20 + </div> 21 + <a class="login-link" href="/"> 22 + <p>Login instead</p> 23 + </a> 24 + 25 + <? elseif($logged_in): 26 + 27 + redirect_to("/"); 28 + 29 + endif;