add # before title, add webpage title (wip)

This commit is contained in:
quenousimporte 2024-10-16 10:27:01 +02:00
parent aa3a99bd0b
commit 79c0b08397
4 changed files with 23 additions and 4 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
settings.php

View File

@ -38,8 +38,10 @@
{ {
foreach($links as $link) foreach($links as $link)
{ {
$url = $link[1];
$title = webpagetitle($url);
$divcontent .= '<div> $divcontent .= '<div>
<a target="_blank" href="' . $link[1] . '">' . $link[1] . '</a> <a target="_blank" href="' . $url . '">' . $title . '</a>
</div>'; </div>';
} }
} }

View File

@ -1,6 +1,21 @@
<?php <?php
require('common.php'); require('common.php');
function webpagetitle($url)
{
// too costly upon each note opening. enable with a cache?
/*$html = file_get_contents($url);
if ($html === FALSE)
{
return $url;
}
preg_match('/<title>(.*?)<\/title>/i', $html, $matches);
return isset($matches[1]) ? $matches[1] : $url;*/
return $url;
}
function savenote($title, $content) function savenote($title, $content)
{ {
global $dir; global $dir;
@ -28,6 +43,8 @@
array_unshift($_SESSION['index'], $path); array_unshift($_SESSION['index'], $path);
} }
// main
// handle save actions // handle save actions
if (count($_POST) > 0) if (count($_POST) > 0)
{ {
@ -75,7 +92,6 @@
} }
} }
// main
$title = ''; $title = '';
$content = false; $content = false;
if (isset($_GET['new'])) if (isset($_GET['new']))
@ -126,7 +142,7 @@
<input type="submit" name="download" value="download" accesskey="d"> <input type="submit" name="download" value="download" accesskey="d">
<input type="submit" name="delete" value="delete"> <input type="submit" name="delete" value="delete">
<input hidden name="lastchanged" value="<?php echo $lastchanged; ?>"> <input hidden name="lastchanged" value="<?php echo $lastchanged; ?>">
<div><input autocomplete="off" class="title" name="title" value="<?php echo $title; ?>"></div> <div># <input autocomplete="off" class="title" name="title" value="<?php echo $title; ?>"></div>
</div> </div>
<div class="editor"> <div class="editor">
<textarea rows="<?php echo $rows; ?>" autofocus name="content" spellcheck="false"><?php echo $content; ?></textarea> <textarea rows="<?php echo $rows; ?>" autofocus name="content" spellcheck="false"><?php echo $content; ?></textarea>

View File

@ -34,7 +34,7 @@ a {
outline: none; outline: none;
margin-top: 10px; margin-top: 10px;
color: inherit; color: inherit;
width: 100%; width: 80%;
} }
input[type="submit"] { input[type="submit"] {