Browse Source

added custom settings for end users

hnh.mtf 3 years ago
parent
commit
966afd9f8c
13 changed files with 199 additions and 28 deletions
  1. 5 5
      config.php
  2. 2 2
      donate.php
  3. 1 1
      index.php
  4. 2 3
      search.php
  5. 66 0
      settings.php
  6. 16 0
      static/dark.css
  7. 16 0
      static/discord.css
  8. 1 0
      static/footer.html
  9. 2 1
      static/header.php
  10. 16 0
      static/light.css
  11. 16 0
      static/night_owl.css
  12. 16 0
      static/nord.css
  13. 40 16
      static/styles.css

+ 5 - 5
config.php

@@ -20,13 +20,13 @@
         Online libreddit instances: https://github.com/spikecodes/libreddit
         Online libreddit instances: https://github.com/spikecodes/libreddit
         
         
         If you don't want to replace YouTube for an example but you want to replace everything else:
         If you don't want to replace YouTube for an example but you want to replace everything else:
-        $config_replace_youtube_with_invidious = null;
+        $config_replace_youtube_with_invidious = isset($_REQUEST["invidious"]) ? $_REQUEST["invidious"]  : null;
     */
     */
     $config_disable_privacy_friendly_frontends = false; // setting this to true will disable all of them
     $config_disable_privacy_friendly_frontends = false; // setting this to true will disable all of them
-    $config_replace_youtube_with_invidious = "https://yewtu.be";
+    $config_replace_youtube_with_invidious = isset($_REQUEST["invidious"]) ? $_REQUEST["invidious"]  : "https://yewtu.be";
-    $config_replace_instagram_with_bibliogram = "https://bibliogram.pussthecat.org";
+    $config_replace_instagram_with_bibliogram = isset($_REQUEST["bibliogram"]) ? $_REQUEST["bibliogram"]  : "https://bibliogram.pussthecat.org";
-    $config_replace_twitter_with_nitter = "https://nitter.namazso.eu";
+    $config_replace_twitter_with_nitter = isset($_REQUEST["nitter"]) ? $_REQUEST["nitter"]  : "https://nitter.namazso.eu";
-    $config_replace_reddit_with_libreddit = "https://libreddit.dothq.co";
+    $config_replace_reddit_with_libreddit = isset($_REQUEST["libreddit"]) ? $_REQUEST["libreddit"]  : "https://libreddit.dothq.co";
 
 
     /*
     /*
         To send requests trough a proxy uncomment CURLOPT_PROXY and CURLOPT_PROXYTYPE:
         To send requests trough a proxy uncomment CURLOPT_PROXY and CURLOPT_PROXYTYPE:

+ 2 - 2
donate.php

@@ -1,4 +1,4 @@
-<?php require "static/header.html"; ?>
+<?php require "static/header.php"; ?>
     <title>LibreX - Donate</title>
     <title>LibreX - Donate</title>
     </head>
     </head>
     <body>
     <body>
@@ -6,7 +6,7 @@
                <p>Support the host</p>
                <p>Support the host</p>
                <span>(Your donation thingy goes here...)</span>
                <span>(Your donation thingy goes here...)</span>
                <p>Support the creator</p>
                <p>Support the creator</p>
-               <span>Monero (XMR):  <br/><br/><span style="background-color:black;">41dGQr9EwZBfYBY3fibTtJZYfssfRuzJZDSVDeneoVcgckehK3BiLxAV4FvEVJiVqdiW996zvMxhFB8G8ot9nBFqQ84VkuC</span></span>
+               <span>Monero (XMR):  <br/><br/>41dGQr9EwZBfYBY3fibTtJZYfssfRuzJZDSVDeneoVcgckehK3BiLxAV4FvEVJiVqdiW996zvMxhFB8G8ot9nBFqQ84VkuC</span>
                <img src="static/images/xmr.png" alt="xmr qr code"/>
                <img src="static/images/xmr.png" alt="xmr qr code"/>
         </div>
         </div>
 
 

+ 1 - 1
index.php

@@ -1,4 +1,4 @@
-<?php require "static/header.html"; ?>
+<?php require "static/header.php"; ?>
 
 
     <title>LibreX</title>
     <title>LibreX</title>
     </head>
     </head>

+ 2 - 3
search.php

@@ -1,5 +1,5 @@
 
 
-<?php require "static/header.html"; ?>
+<?php require "static/header.php"; ?>
 
 
 <title> <?php echo $_REQUEST["q"]; ?> - LibreX</title>
 <title> <?php echo $_REQUEST["q"]; ?> - LibreX</title>
 </head>
 </head>
@@ -21,7 +21,7 @@
             >
             >
             <br>
             <br>
             <?php
             <?php
-                $type = $_REQUEST["type"];
+                $type = isset($_REQUEST["type"]) ? (int) $_REQUEST["type"] : 0;
                 echo "<input type=\"hidden\" name=\"type\" value=\"$type\"/>";
                 echo "<input type=\"hidden\" name=\"type\" value=\"$type\"/>";
             ?>
             ?>
             <button type="submit" style="display:none;"></button>
             <button type="submit" style="display:none;"></button>
@@ -40,7 +40,6 @@
             require "config.php";
             require "config.php";
 
 
             $page = isset($_REQUEST["p"]) ? (int) $_REQUEST["p"] : 0;
             $page = isset($_REQUEST["p"]) ? (int) $_REQUEST["p"] : 0;
-            $type = isset($_REQUEST["type"]) ? (int) $_REQUEST["type"] : 0;
         
         
             $query_encoded = urlencode($query);
             $query_encoded = urlencode($query);
 
 

+ 66 - 0
settings.php

@@ -0,0 +1,66 @@
+<?php 
+    require "static/header.php";
+    require "config.php";
+?>
+
+    <title>LibreX - Settings</title>
+    </head>
+    <body class="settings-container">
+        <p>Since LibreX doesn't use any cookies for better user privacy, settings are passed trough query parameters.</p>
+
+        <form method="post" enctype="multipart/form-data" autocomplete="off">
+            <label for="theme">Theme:</label>
+            <select name="theme">
+                <option value="dark">Dark</option>
+                <option value="light">Light</option>
+                <option value="nord">Nord</option>
+                <option value="night_owl">Night Owl</option>
+                <option value="discord">Discord</option>
+            </select>
+            <br><br>
+            <p>Privacy friendly frontends</p>
+            <div class="instances-container">
+                <label for="invidious">Invidious:</label>
+                <input type="text" name="invidious">
+
+                <br><br>
+                <label for="bibliogram">Bibliogram:</label>
+                <input type="text" name="bibliogram">
+
+                <br><br>
+                <label for="nitter">Nitter:</label>
+                <input type="text" name="nitter">
+
+                <br><br>
+                <label for="libreddit">Libreddit:</label>
+                <input type="text" name="libreddit">
+            </div>
+            <br>
+            <button type="submit" name="save" value="1">Save</button>
+        </form>
+
+
+        <?php
+            if (isset($_REQUEST["save"]))
+            {
+                $url = $_SERVER["HTTP_HOST"] . "/search.php?q=test&theme=" . $_REQUEST["theme"];
+
+                if (!empty($_REQUEST["invidious"]))
+                    $url .= "&invidious=" . $_REQUEST["invidious"];
+
+                if (!empty($_REQUEST["bibliogram"]))
+                    $url .= "&bibliogram=" . $_REQUEST["bibliogram"];
+
+                if (!empty($_REQUEST["nitter"]))
+                    $url .= "&nitter=" . $_REQUEST["nitter"];
+
+                if (!empty($_REQUEST["libreddit"]))
+                    $url .= "&nitter=" . $_REQUEST["libreddit"];
+
+                echo "<a href=\"$url\"><p>";
+                echo  $url;
+                echo "</p>";
+            }
+        ?>
+
+<?php require "static/footer.html"; ?>

+ 16 - 0
static/dark.css

@@ -0,0 +1,16 @@
+:root {
+    --main-bg: #202124;
+    --main-fg: #e8eaed;
+
+    --alt-fg: #bd93f9;
+
+    --result-link-fg: #8ab4f8;
+    --result-fg: #999da2;
+
+    --button-bg: #303134;
+
+    --special-result-border: #bdc1c6;
+
+    --footer-fg: #999da2;
+    --footer-bg: #171717;
+}

+ 16 - 0
static/discord.css

@@ -0,0 +1,16 @@
+:root {
+    --main-bg: #2f3136;
+    --main-fg: #dcddde;
+
+    --alt-fg: #bd93f9;
+
+    --result-link-fg: #747ff4;
+    --result-fg: #dcddde;
+
+    --button-bg: #36393f;
+
+    --special-result-border: #dcddde;
+
+    --footer-fg: #dcddde;
+    --footer-bg: #36393f;
+}

+ 1 - 0
static/footer.html

@@ -1,6 +1,7 @@
 <div class="footer-container">
 <div class="footer-container">
     <a href="/">LibreX</a>
     <a href="/">LibreX</a>
     <a href="https://github.com/hnhx/librex/" target="_blank">Source &amp; Instance list</a>
     <a href="https://github.com/hnhx/librex/" target="_blank">Source &amp; Instance list</a>
+    <a href="/settings.php">Settings</a>
     <a href="/api.php" target="_blank">API</a>
     <a href="/api.php" target="_blank">API</a>
     <a href="/donate.php">Donate ❤️</a>
     <a href="/donate.php">Donate ❤️</a>
 </div>
 </div>

+ 2 - 1
static/header.html → static/header.php

@@ -8,4 +8,5 @@
         <link rel="stylesheet" type="text/css" href="static/styles.css"/>
         <link rel="stylesheet" type="text/css" href="static/styles.css"/>
         <link title="LibreX search" type="application/opensearchdescription+xml" href="/opensearch.xml?method=POST" rel="search"/>
         <link title="LibreX search" type="application/opensearchdescription+xml" href="/opensearch.xml?method=POST" rel="search"/>
         <link rel="shortcut icon" href="static/images/librex.png" />
         <link rel="shortcut icon" href="static/images/librex.png" />
-    
+
+        <link rel="stylesheet" type="text/css" href="<?php echo "static/" . (isset($_REQUEST["theme"]) ? $_REQUEST["theme"] . ".css" : "dark.css"); ?>"/>

+ 16 - 0
static/light.css

@@ -0,0 +1,16 @@
+:root {
+    --main-bg: #fff;
+    --main-fg: #202124;
+
+    --alt-fg: #bd93f9;
+
+    --result-link-fg: #1a0dab;
+    --result-fg: #70757a;
+
+    --button-bg: #f2f2f2;
+
+    --special-result-border: #bdc1c6;
+
+    --footer-fg: #70757a;
+    --footer-bg: #f2f2f2;
+}

+ 16 - 0
static/night_owl.css

@@ -0,0 +1,16 @@
+:root {
+    --main-bg: #011627;
+    --main-fg: #d6deeb;
+
+    --alt-fg: #bd93f9;
+
+    --result-link-fg: #5f7e97;
+    --result-fg: #d6deeb;
+
+    --button-bg: #122d42;
+
+    --special-result-border: #d6deeb;
+
+    --footer-fg: #d6deeb;
+    --footer-bg: #011627;
+}

+ 16 - 0
static/nord.css

@@ -0,0 +1,16 @@
+:root {
+    --main-bg: #3B4252;
+    --main-fg: #E5E9F0;
+
+    --alt-fg: #bd93f9;
+
+    --result-link-fg: #88C0D0;
+    --result-fg: #D8DEE9;
+
+    --button-bg: #4C566A;
+
+    --special-result-border: #D8DEE9;
+
+    --footer-fg: #D8DEE9;
+    --footer-bg: #2E3440;
+}

+ 40 - 16
static/styles.css

@@ -1,6 +1,6 @@
 html {
 html {
-    color: #e8eaed;
+    color: var(--main-fg);
-    background-color: #202124; 
+    background-color: var(--main-bg); 
     font-family: Arial, Helvetica, sans-serif;
     font-family: Arial, Helvetica, sans-serif;
     font-size: 16px;
     font-size: 16px;
 }
 }
@@ -16,7 +16,7 @@ button {
 
 
 p {
 p {
     font-size:18px;
     font-size:18px;
-    color: #999da2;
+    color: var(--result-fg);
 }
 }
 
 
 a,
 a,
@@ -49,13 +49,19 @@ a:hover, .text-result-wrapper h2:hover {
     border-radius: 25px;
     border-radius: 25px;
 }
 }
 
 
-.search-button-wrapper button {
+.search-button-wrapper button, 
+.settings-container button, 
+.settings-container select {
     color: inherit;
     color: inherit;
-    background-color: #303134;
+    background-color: var(--button-bg);
     font-size: 14px;
     font-size: 14px;
     border: none;
     border: none;
     border-radius: 4px;
     border-radius: 4px;
     padding: 13px 10px 13px 10px;
     padding: 13px 10px 13px 10px;
+}
+
+.search-button-wrapper button {
+   
     margin: 30px 60px 0px 60px;
     margin: 30px 60px 0px 60px;
 }
 }
 
 
@@ -95,11 +101,29 @@ a:hover, .text-result-wrapper h2:hover {
 .sub-search-button-wrapper button {
 .sub-search-button-wrapper button {
     border: none;
     border: none;
     background-color: inherit;
     background-color: inherit;
-    color: #bd93f9;
+    color: var(--alt-fg);
     font-size: 18px;
     font-size: 18px;
     margin-right: 25px;
     margin-right: 25px;
 }
 }
 
 
+.settings-container {
+    margin-top: 10%;
+    text-align: center;
+    margin-left: 25%;
+    margin-right: 25%;
+    word-wrap: break-word;
+}
+
+.instances-container input {
+    color: inherit;
+    background-color: inherit;  
+    padding: 5px;
+    font-size: inherit;
+    font-family: inherit;
+    border: 1px solid #5f6368;
+    border-radius: 5px;
+}
+
 .text-result-container,
 .text-result-container,
 #time,
 #time,
 .next-page-button-wrapper {
 .next-page-button-wrapper {
@@ -113,7 +137,7 @@ a:hover, .text-result-wrapper h2:hover {
 
 
 .special-result-container {
 .special-result-container {
     padding: 10px;
     padding: 10px;
-    border: 1px solid #bdc1c6;
+    border: 1px solid var(--special-result-border);
     width: 500px;
     width: 500px;
 }
 }
 
 
@@ -125,12 +149,12 @@ a:hover, .text-result-wrapper h2:hover {
 
 
 .text-result-wrapper a {
 .text-result-wrapper a {
     font-size: 14px;
     font-size: 14px;
-    color:#bdc1c6;
+    color: var(--result-fg);
 }
 }
 
 
 .text-result-wrapper h2 {
 .text-result-wrapper h2 {
     font-size: 20px;
     font-size: 20px;
-    color: #8ab4f8;
+    color: var(--result-link-fg);
     padding-top: 5px;
     padding-top: 5px;
     margin-top: 1px;
     margin-top: 1px;
 }
 }
@@ -138,7 +162,7 @@ a:hover, .text-result-wrapper h2:hover {
 .special-result-container a {
 .special-result-container a {
     display: flex;
     display: flex;
     margin-top: 10px;
     margin-top: 10px;
-    color: #bd93f9;
+    color: var(--alt-fg);
     font-size:14px;
     font-size:14px;
 }
 }
 
 
@@ -150,7 +174,7 @@ a:hover, .text-result-wrapper h2:hover {
 .next-page-button-wrapper button {
 .next-page-button-wrapper button {
     border:none;
     border:none;
     background-color: inherit;
     background-color: inherit;
-    color: #8ab4f8;
+    color: var(--result-link-fg);
     font-size: 18px;
     font-size: 18px;
 }
 }
 
 
@@ -166,7 +190,7 @@ a:hover, .text-result-wrapper h2:hover {
 
 
 .image-result-container img {
 .image-result-container img {
     margin: 10px;
     margin: 10px;
-    border: 1px solid #5f6368;
+    border: 1px solid var(--button-bg);
 }
 }
 
 
 .donate-container {
 .donate-container {
@@ -175,7 +199,7 @@ a:hover, .text-result-wrapper h2:hover {
     margin-left: auto;
     margin-left: auto;
     margin-right: auto;
     margin-right: auto;
     margin-top: 8%;
     margin-top: 8%;
-    border: 1px solid #bdc1c6;
+    border: 1px solid var(--main-fg);
     max-width: 500px;
     max-width: 500px;
     padding:0px 20px 20px 20px;
     padding:0px 20px 20px 20px;
 }
 }
@@ -185,7 +209,7 @@ a:hover, .text-result-wrapper h2:hover {
 }
 }
 
 
 .donate-container a {
 .donate-container a {
-    color: #bd93f9;
+    color: var(--alt-fg);
 }
 }
 
 
 .footer-container {
 .footer-container {
@@ -193,7 +217,7 @@ a:hover, .text-result-wrapper h2:hover {
     left: 0;
     left: 0;
     bottom: 0;
     bottom: 0;
     width: 100vw;
     width: 100vw;
-    background-color: #171717;
+    background-color: var(--footer-bg);
     padding-top: 15px;
     padding-top: 15px;
     padding-bottom: 15px;
     padding-bottom: 15px;
     border-top: 1px solid #303134;
     border-top: 1px solid #303134;
@@ -201,7 +225,7 @@ a:hover, .text-result-wrapper h2:hover {
 }
 }
 
 
 .footer-container a {
 .footer-container a {
-    color: #999da2;
+    color: var(--footer-fg);
     margin-left: 15px;
     margin-left: 15px;
     margin-right: 15px;
     margin-right: 15px;
 }
 }