clemtre
8 months ago
5 changed files with 196 additions and 345 deletions
@ -1,80 +0,0 @@ |
|||||
#!/bin/sh |
|
||||
|
|
||||
# needs a better name |
|
||||
|
|
||||
# - - - - - - - - - - - - - - - - ARGS - - - - - - - - - - - - - - - - - |
|
||||
show_help() { |
|
||||
echo "Usage:" |
|
||||
echo "1. Copy the desired Url to your clipboard" |
|
||||
echo "2. ./edit_bookmarks_dmenu.sh BOOKMARKS" |
|
||||
echo "Options:" |
|
||||
echo " --help Display this help message" |
|
||||
exit 1 |
|
||||
} |
|
||||
if [ "$#" -eq 0 ]; then |
|
||||
echo "Nothing happened, I need a file of bookmarks to edit." |
|
||||
show_help |
|
||||
fi |
|
||||
|
|
||||
while [ "$#" -gt 0 ]; do |
|
||||
case "$1" in |
|
||||
--help) |
|
||||
show_help |
|
||||
;; |
|
||||
-*) |
|
||||
echo "Error: Unknown option: $1" >&2 |
|
||||
show_help |
|
||||
;; |
|
||||
esac |
|
||||
shift |
|
||||
done |
|
||||
dmenu_style() { |
|
||||
local font='junicode-18' |
|
||||
local normal_bg='#000000' |
|
||||
local normal_fg='#FFFFFF' |
|
||||
local selected_bg='#AAAAAA' |
|
||||
local selected_fg='#000000' |
|
||||
echo "-fn $font -nb $normal_bg -nf $normal_fg -sb $selected_bg -sf $selected_fg" |
|
||||
} |
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- |
|
||||
|
|
||||
# TODO : process multiple files of BOOKMARKS at once |
|
||||
BOOKMARKS=$1 |
|
||||
|
|
||||
URL=$(xclip -o -selection clipboard) |
|
||||
|
|
||||
# The curl for Name: is a blocking process and will pause the programm |
|
||||
# in case internet shuts :^) |
|
||||
|
|
||||
# TODO : |
|
||||
# add description, tags and color in one field with symbols such as : |
|
||||
# § this is a description. § comma, separated, tags § color |
|
||||
|
|
||||
# If the given string ressembles to a url, continue. |
|
||||
# https://stackoverflow.com/questions/21115121/how-to-test-if-string-matches-a-regex-in-posix-shell-not-bash |
|
||||
# URL_REGEX="^(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]" |
|
||||
if printf "$URL" | grep -q http; then |
|
||||
# TODO : incrementing id replacing <ol> list counter |
|
||||
#PREV_URL_COUNT=$(grep "URL: " $BOOKMARKS | wc -l) |
|
||||
#ID: $((PREV_URL_COUNT + 1)) |
|
||||
# TODO : add the bookmark in reverse, last in first first on the stack |
|
||||
# maybe using tac instead of cat ? |
|
||||
cat <<- EOF >> $BOOKMARKS |
|
||||
|
|
||||
URL: $(printf $URL) |
|
||||
Name: $(curl $URL | awk -v RS='</title>' '\ |
|
||||
/<title>/ {gsub(/.*<title>/, ""); print}\ |
|
||||
' | tr -d '\n') |
|
||||
Description: $(printf "" | dmenu -p "Enter a description: " $(dmenu_style)) |
|
||||
Tags: $(printf "" | dmenu -p "Enter comma separated tags: " $(dmenu_style)) |
|
||||
Date: $(date +%s) |
|
||||
|
|
||||
EOF |
|
||||
|
|
||||
else |
|
||||
printf "Text in clipboard is not a url" |
|
||||
exit |
|
||||
fi |
|
||||
|
|
||||
# what we used to need htmlq for : |
|
||||
# name=$(curl $url | ~/.cargo/bin/htmlq title --text | sed -r '/^\s*$/d' | sed 's/^ *//g') |
|
@ -0,0 +1,60 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# - - - - - - - - - - - - - - - - ARGS - - - - - - - - - - - - - - - - - |
||||
|
show_help() { |
||||
|
printf " |
||||
|
Usage: |
||||
|
1. Copy the desired URL to your clipboard |
||||
|
2. ./interface_dmenu.sh BOOKMARKS |
||||
|
Options: |
||||
|
--help Display this help message" |
||||
|
exit 1 |
||||
|
} |
||||
|
if [ "$#" -eq 0 ]; then |
||||
|
printf "Nothing happened, I need a file of bookmarks to edit." |
||||
|
show_help |
||||
|
fi |
||||
|
|
||||
|
while [ "$#" -gt 0 ]; do |
||||
|
case "$1" in |
||||
|
--help) |
||||
|
show_help |
||||
|
;; |
||||
|
-*) |
||||
|
printf "Error: Unknown option: $1" >&2 |
||||
|
show_help |
||||
|
;; |
||||
|
esac |
||||
|
shift |
||||
|
done |
||||
|
|
||||
|
dmenu_style() { |
||||
|
local font='junicode-18' |
||||
|
local normal_bg='#000000' |
||||
|
local normal_fg='#FFFFFF' |
||||
|
local selected_bg='#AAAAAA' |
||||
|
local selected_fg='#000000' |
||||
|
echo "-fn $font -nb $normal_bg -nf $normal_fg -sb $selected_bg -sf $selected_fg" |
||||
|
} |
||||
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- |
||||
|
|
||||
|
URL=$(xclip -o -selection clipboard) |
||||
|
|
||||
|
if [ "${URL#"http"}" != "$URL" ]; then |
||||
|
DESC=$(dmenu -p "$URL · description →" $(dmenu_style)) |
||||
|
TAGS=$(dmenu -p "$URL · $DESC · tags →" $(dmenu_style)) |
||||
|
|
||||
|
cat <<- EOF > signet |
||||
|
URL: $URL |
||||
|
Description: $DESC |
||||
|
Tags: $TAGS |
||||
|
Date: $(date +%g/%m/%d) |
||||
|
|
||||
|
EOF |
||||
|
|
||||
|
./edit.sh |
||||
|
|
||||
|
else |
||||
|
printf "Text in clipboard is not a url" |
||||
|
exit |
||||
|
fi |
@ -1,59 +1,19 @@ |
|||||
//document.addEventListener("keydown", function(event) {
|
const textarea = document.querySelector('textarea') |
||||
// var keyPressed = event.key.toLowerCase();
|
|
||||
//
|
function updateValue(e) { |
||||
// if (keyPressed === 'p') {
|
let val = textarea.value.toLowerCase() |
||||
// const val = Math.round(Math.random()*255)
|
document.querySelectorAll('.signets tr').forEach((e) => { |
||||
// document.querySelector('body').style.background = `rgba(${val},${val /2},${val})`
|
var listItemText = e.innerHTML.toLowerCase(); |
||||
// console.log("The 'P' key was pressed");
|
listItemText.includes(val) ? |
||||
// }
|
e.classList.remove('hidden') : e.classList.add('hidden') |
||||
//});
|
}) |
||||
|
|
||||
// Barre de recherche
|
|
||||
$(document).ready(function () { |
|
||||
$('li').addClass('active') |
|
||||
$('textarea').on('input', function () { |
|
||||
var userInput = $(this).val().toLowerCase(); |
|
||||
|
|
||||
$('li').each(function () { |
|
||||
var listItemText = $(this).text().toLowerCase(); |
|
||||
if (listItemText.includes(userInput)) { |
|
||||
$(this).addClass('active'); |
|
||||
} else { |
|
||||
$(this).removeClass('active'); |
|
||||
} |
|
||||
}); |
|
||||
|
|
||||
}); |
|
||||
}); |
|
||||
|
|
||||
// On convertit les dates au format AA-MM-JJ
|
|
||||
function formatDateFromEpoch(epochTime) { |
|
||||
const date = new Date(epochTime * 1000); |
|
||||
|
|
||||
const YY = date.getFullYear().toString() |
|
||||
const MM = ('0' + (date.getMonth() + 1)).slice(-2) |
|
||||
const DD = ('0' + date.getDate()).slice(-2) |
|
||||
|
|
||||
if(epochTime == ''){ |
|
||||
|
|
||||
return `N/A`; |
|
||||
} |
|
||||
|
|
||||
return `${YY}/${MM}/${DD}`; |
|
||||
} |
} |
||||
|
|
||||
const dates = document.querySelectorAll('h4') |
document.addEventListener("DOMContentLoaded", function(event) { |
||||
dates.forEach((date) => { |
textarea.addEventListener("input", updateValue); |
||||
date.innerHTML= formatDateFromEpoch(date.innerHTML) |
|
||||
}) |
|
||||
|
|
||||
// On cache les descriptions si elles sont vides
|
|
||||
$('h2').each(function() { |
|
||||
$(this).html() == '' ? $(this).hide() : $(this).show() |
|
||||
}) |
}) |
||||
|
|
||||
// On colore les entrées qui ont un attribut 'color'
|
document.querySelectorAll('[color]').forEach((e) => { |
||||
$('[color]').each(function() { |
e.style.background = `linear-gradient(var(--background), ${e.getAttribute('color')} ` |
||||
$(this).css('background', `linear-gradient(var(--background), ${$(this).attr('color')} `) |
|
||||
|
|
||||
}) |
}) |
||||
|
Loading…
Reference in new issue