commit 49767c31ccc9b092b98d7e52a1783b4c9192e6aa
parent 96edf48eb381c13478fc27161aad504569a5e4d1
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date: Sat, 26 Oct 2024 23:17:08 +0200
feat: add bookmarklet
Diffstat:
5 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/assets/css/custom.css b/assets/css/custom.css
@@ -47,6 +47,7 @@ textarea#content {
padding: .1rem 1rem !important;
text-decoration: none !important;
display: inline-block;
+ line-height: 2 !important;
}
.likenavitem:hover {
diff --git a/config/i18n.php b/config/i18n.php
@@ -26,6 +26,9 @@ if ($lang == "en") {
$GLOBALS["i18n_search"] = "Search";
$GLOBALS["i18n_search_placeholder"] = "Search your notes...";
$GLOBALS["i18n_matches"] = "Matches";
+ $GLOBALS["i18n_bookmarklet"] = "Bookmarklet";
+ $GLOBALS["i18n_bookmarklet_tp"] = "Drag this to your bookmark toolbar. On other websites you can then click the icon to remember it in Rememori.";
+ $GLOBALS["i18n_bookmarklet_prompt"] = "Under which category do you want to remember this site?";
}
if ($lang == "de") {
$GLOBALS["i18n_note"] = "Notiz";
@@ -48,6 +51,9 @@ if ($lang == "de") {
$GLOBALS["i18n_search"] = "Suchen";
$GLOBALS["i18n_search_placeholder"] = "Notizen durchsuchen...";
$GLOBALS["i18n_matches"] = "Funde";
+ $GLOBALS["i18n_bookmarklet"] = "Bookmarklet";
+ $GLOBALS["i18n_bookmarklet_tp"] = "Dieser Link kann zur Lesezeichensymbollietse gezogen werden. Anderen Webseiten können dann per Klick auf das Symbol in Rememori gespeichert werden.";
+ $GLOBALS["i18n_bookmarklet_prompt"] = "Unter welcher Kategorie soll diese Seite gespeicher werden?";
}
diff --git a/index.php b/index.php
@@ -131,7 +131,7 @@
<header>
<!-- Buttons -->
- <?php top_navigation(); ?>
+ <?php top_navigation($user, $token, $category); ?>
<!-- Headline -->
<h1>Rememori</h1>
diff --git a/lib/bookmarklet.php b/lib/bookmarklet.php
@@ -0,0 +1,26 @@
+<?php
+
+function bookmarklet(
+ string $user,
+ string $token
+) {
+
+ /* construct javascript bookmarklet */
+ echo "javascript:(function() {
+var category = prompt(
+'" . $GLOBALS["i18n_bookmarklet_prompt"] . "',
+'unknown'
+);
+remori_window = window.open(
+'https://" . $_SERVER["SERVER_NAME"] . "/api/new.php
+?user=" . $user . "
+&token=" . $token . "
+&category=' + category + '
+&content=' + window.location.href
+);
+setTimeout(() => { remori_window.close(); }, 1500);
+})();";
+
+} // function
+
+?>
diff --git a/lib/menus.php b/lib/menus.php
@@ -1,6 +1,9 @@
<?php
-function top_navigation() {
+function top_navigation(
+ string $user,
+ string $token
+) {
?>
@@ -55,6 +58,16 @@ function top_navigation() {
>
</form>
+ <!-- Bookmarklet -->
+ <a
+ class="likenavitem"
+ href="<?php echo bookmarklet($user, $token); ?>"
+ onclick="window.alert('<?php echo $GLOBALS["i18n_bookmarklet_tp"];?>');"
+ title="<?php echo $GLOBALS["i18n_bookmarklet_tp"]; ?>"
+ >
+ <?php echo $GLOBALS["i18n_bookmarklet"]; ?>
+ </a>
+
<!-- Logout-Action -->
<form action="/" method="post" class="inline">
<input