diff --git a/Makefile b/Makefile index 8f9ab9e7..e6f42853 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ # Shaarli, the personal, minimalist, super-fast, no-database delicious clone. -# # Makefile for PHP code analysis & testing -# + # Prerequisites: # - install Composer, either: # - from your distro's package manager; @@ -9,6 +8,7 @@ # - install/update test dependencies: # $ composer install # 1st setup # $ composer update + BIN = vendor/bin PHP_SOURCE = index.php MESS_DETECTOR_RULES = cleancode,codesize,controversial,design,naming,unusedcode @@ -17,41 +17,39 @@ all: static_analysis_summary ## # Concise status of the project -# # These targets are non-blocking: || exit 0 ## + static_analysis_summary: code_sniffer_source copy_paste mess_detector_summary ## # PHP_CodeSniffer -# # Detects PHP syntax errors -# # Documentation (usage, output formatting): # - http://pear.php.net/manual/en/package.php.php-codesniffer.usage.php # - http://pear.php.net/manual/en/package.php.php-codesniffer.reporting.php ## + code_sniffer: code_sniffer_full -# - errors by Git author +### - errors by Git author code_sniffer_blame: @$(BIN)/phpcs $(PHP_SOURCE) --report-gitblame -# - all errors/warnings +### - all errors/warnings code_sniffer_full: @$(BIN)/phpcs $(PHP_SOURCE) --report-full --report-width=200 -# - errors grouped by kind +### - errors grouped by kind code_sniffer_source: @$(BIN)/phpcs $(PHP_SOURCE) --report-source || exit 0 ## # PHP Copy/Paste Detector -# # Detects code redundancy -# # Documentation: https://github.com/sebastianbergmann/phpcpd ## + copy_paste: @echo "-----------------------" @echo "PHP COPY/PASTE DETECTOR" @@ -61,32 +59,30 @@ copy_paste: ## # PHP Mess Detector -# # Detects PHP syntax errors, sorted by category -# # Rules documentation: http://phpmd.org/rules/index.html -# +## + mess_title: @echo "-----------------" @echo "PHP MESS DETECTOR" @echo "-----------------" -# - all warnings +### - all warnings mess_detector: mess_title @$(BIN)/phpmd $(PHP_SOURCE) text $(MESS_DETECTOR_RULES) | sed 's_.*\/__' -# - all warnings -# the generated HTML contains links to PHPMD's documentation +### - all warnings + HTML output contains links to PHPMD's documentation mess_detector_html: @$(BIN)/phpmd $(PHP_SOURCE) html $(MESS_DETECTOR_RULES) \ --reportfile phpmd.html || exit 0 -# - warnings grouped by message, sorted by descending frequency order +### - warnings grouped by message, sorted by descending frequency order mess_detector_grouped: mess_title @$(BIN)/phpmd $(PHP_SOURCE) text $(MESS_DETECTOR_RULES) \ | cut -f 2 | sort | uniq -c | sort -nr -# - summary: number of warnings by rule set +### - summary: number of warnings by rule set mess_detector_summary: mess_title @for rule in $$(echo $(MESS_DETECTOR_RULES) | tr ',' ' '); do \ warnings=$$($(BIN)/phpmd $(PHP_SOURCE) text $$rule | wc -l); \ @@ -95,13 +91,20 @@ mess_detector_summary: mess_title ## # Targets for repository and documentation maintenance -# -# remove all unversioned files +## + +### remove all unversioned files clean: @git clean -df -# update the local copy of the documentation +### update the local copy of the documentation doc: clean @rm -rf doc @git clone https://github.com/shaarli/Shaarli.wiki.git doc @rm -rf doc/.git + +### Convert local markdown documentation to HTML +htmldoc: + for file in `find doc/ -maxdepth 1 -name "*.md"`; do \ + pandoc -f markdown_github -t html5 -s -c "github-markdown.css" -o doc/`basename $$file .md`.html "$$file"; \ + done; \ No newline at end of file diff --git a/doc/Copy-a-Shaarli-installation-over-SSH-SCP,-serve-it-locally-with-php-cli.html b/doc/Copy-a-Shaarli-installation-over-SSH-SCP,-serve-it-locally-with-php-cli.html new file mode 100644 index 00000000..25e4bc6b --- /dev/null +++ b/doc/Copy-a-Shaarli-installation-over-SSH-SCP,-serve-it-locally-with-php-cli.html @@ -0,0 +1,75 @@ + + +
+ + + +Example bash script:
+#!/bin/bash
+#Description: Copy a Shaarli installation over SSH/SCP, serve it locally with php-cli
+#Will create a local-shaarli/ directory when you run it, backup your Shaarli there, and serve it locally.
+#Will NOT download linked pages. It's just a directly usable backup/copy/mirror of your Shaarli
+#Requires: ssh, scp and a working SSH access to the server where your Shaarli is installed
+#Usage: ./local-shaarli.sh
+#Author: nodiscc (nodiscc@gmail.com)
+#License: MIT (http://opensource.org/licenses/MIT)
+set -o errexit
+set -o nounset
+
+##### CONFIG #################
+#The port used by php's local server
+php_local_port=7431
+
+#Name of the SSH server and path where Shaarli is installed
+#TODO: pass these as command-line arguments
+remotehost="my.ssh.server"
+remote_shaarli_dir="/var/www/shaarli"
+
+
+###### FUNCTIONS #############
+_main() {
+ _CBSyncShaarli
+ _CBServeShaarli
+}
+
+_CBSyncShaarli() {
+ remote_temp_dir=$(ssh $remotehost mktemp -d)
+ remote_ssh_user=$(ssh $remotehost whoami)
+ ssh -t "$remotehost" sudo cp -r "$remote_shaarli_dir" "$remote_temp_dir"
+ ssh -t "$remotehost" sudo chown -R "$remote_ssh_user":"$remote_ssh_user" "$remote_temp_dir"
+ scp -rq "$remotehost":"$remote_temp_dir" local-shaarli
+ ssh "$remotehost" rm -r "$remote_temp_dir"
+}
+
+_CBServeShaarli() {
+ #TODO: allow serving a previously downloaded Shaarli
+ #TODO: ask before overwriting local copy, if it exists
+ cd local-shaarli/
+ php -S localhost:${php_local_port}
+ echo "Please go to http://localhost:${php_local_port}"
+}
+
+
+##### MAIN #################
+
+_main
+This outputs:
+$ ./local-shaarli.sh
+PHP 5.6.0RC4 Development Server started at Mon Sep 1 21:56:19 2014
+Listening on http://localhost:7431
+Document root is /home/user/local-shaarli/shaarli
+Press Ctrl-C to quit.
+
+[Mon Sep 1 21:56:27 2014] ::1:57868 [200]: /
+[Mon Sep 1 21:56:27 2014] ::1:57869 [200]: /index.html
+[Mon Sep 1 21:56:37 2014] ::1:57881 [200]: /...
+
+
diff --git a/doc/Download-CSS-styles-for-shaarlis-listed-in-an-opml-file.html b/doc/Download-CSS-styles-for-shaarlis-listed-in-an-opml-file.html
new file mode 100644
index 00000000..0f32fb84
--- /dev/null
+++ b/doc/Download-CSS-styles-for-shaarlis-listed-in-an-opml-file.html
@@ -0,0 +1,167 @@
+
+
+
+
+
+
+ Example php script:
+<!---- ?php -->
+<!---- Copyright (c) 2014 Nicolas Delsaux (https://github.com/Riduidel) -->
+<!---- License: zlib (http://www.gzip.org/zlib/zlib_license.html) -->
+
+/**
+ * Source: https://github.com/Riduidel
+ * Download css styles for shaarlis listed in an opml file
+ */
+define("SHAARLI_RSS_OPML", "https://www.ecirtam.net/shaarlirss/custom/people.opml");
+
+define("THEMES_TEMP_FOLDER", "new_themes");
+
+if(!file_exists(THEMES_TEMP_FOLDER)) {
+ mkdir(THEMES_TEMP_FOLDER);
+}
+
+function siteUrl($pathInSite) {
+ $indexPos = strpos($pathInSite, "index.php");
+ if(!$indexPos) {
+ return $pathInSite;
+ } else {
+ return substr($pathInSite, 0, $indexPos);
+ }
+}
+
+function createShaarliHashFromOPMLL($opmlFile) {
+ $result = array();
+ $opml = file_get_contents($opmlFile);
+ $opmlXml = simplexml_load_string($opml);
+ $outlineElements = $opmlXml->xpath("body/outline");
+ foreach($outlineElements as $site) {
+ $siteUrl = siteUrl((string) $site['htmlUrl']);
+ $result[$siteUrl]=((string) $site['text']);
+ }
+ return $result;
+}
+
+function getSiteFolder($url) {
+ $domain = parse_url($url, PHP_URL_HOST);
+ return THEMES_TEMP_FOLDER."/".str_replace(".", "_", $domain);
+}
+
+function get_http_response_code($theURL) {
+ $headers = get_headers($theURL);
+ return substr($headers[0], 9, 3);
+}
+
+/**
+ * This makes the code PHP-5 only (particularly the call to "get_headers")
+ */
+function copyUserStyleFrom($url, $name, $knownStyles) {
+ $userStyle = $url."inc/user.css";
+ if(in_array($url, $knownStyles)) {
+ // TODO add log message
+ } else {
+ $statusCode = get_http_response_code($userStyle);
+ if(intval($statusCode)<300) {
+ $styleSheet = file_get_contents($userStyle);
+ $siteFolder = getSiteFolder($url);
+ if(!file_exists($siteFolder)) {
+ mkdir($siteFolder);
+ }
+ if(!file_exists($siteFolder.'/user.css')) {
+ // Copy stylesheet
+ file_put_contents($siteFolder.'/user.css', $styleSheet);
+ }
+ if(!file_exists($siteFolder.'/README.md')) {
+ // Then write a readme.md file
+ file_put_contents($siteFolder.'/README.md',
+ "User style from ".$name."\n"
+ ."============================="
+ ."\n\n"
+ ."This stylesheet was downloaded from ".$userStyle." on ".date(DATE_RFC822)
+ );
+ }
+ if(!file_exists($siteFolder.'/config.ini')) {
+ // Write a config file containing useful informations
+ file_put_contents($siteFolder.'/config.ini',
+ "site_url=".$url."\n"
+ ."site_name=".$name."\n"
+ );
+ }
+ if(!file_exists($siteFolder.'/home.png')) {
+ // And finally copy generated thumbnail
+ $homeThumb = $siteFolder.'/home.png';
+ file_put_contents($siteFolder.'/home.png', file_get_contents(getThumbnailUrl($url)));
+ }
+ echo 'Theme have been downloaded from <a href="'.$url.'">'.$url.'</a> into '.$siteFolder
+ .'. It looks like <img src="'.$homeThumb.'"><br/>';
+ }
+ }
+}
+
+function getThumbnailUrl($url) {
+ return 'http://api.webthumbnail.org/?url='.$url;
+}
+
+function copyUserStylesFrom($urlToNames, $knownStyles) {
+ foreach($urlToNames as $url => $name) {
+ copyUserStyleFrom($url, $name, $knownStyles);
+ }
+}
+
+/**
+ * Reading directory list, courtesy of http://www.laughing-buddha.net/php/dirlist/
+ * @param directory the directory we want to list files of
+ * @return a simple array containing the list of absolute file paths. Notice that current file (".") and parent one("..")
+ * are not listed here
+ */
+function getDirectoryList ($directory) {
+ $realPath = realpath($directory);
+ // create an array to hold directory list
+ $results = array();
+ // create a handler for the directory
+ $handler = opendir($directory);
+ // open directory and walk through the filenames
+ while ($file = readdir($handler)) {
+ // if file isn't this directory or its parent, add it to the results
+ if ($file != "." && $file != "..") {
+ $results[] = realpath($realPath . "/" . $file);
+ }
+ }
+ // tidy up: close the handler
+ closedir($handler);
+ // done!
+ return $results;
+}
+
+/**
+ * Start in themes folder and look in all subfolders for config.ini files.
+ * These config.ini files allow us not to download styles again and again
+ */
+function findKnownStyles() {
+ $result = array();
+ $subFolders = getDirectoryList("themes");
+ foreach($subFolders as $folder) {
+ $configFile = $folder."/config.ini";
+ if(file_exists($configFile)) {
+ $iniParameters = parse_ini_file($configFile);
+ array_push($result, $iniParameters['site_url']);
+ }
+ }
+ return $result;
+}
+
+$knownStyles = findKnownStyles();
+copyUserStylesFrom(createShaarliHashFromOPMLL(SHAARLI_RSS_OPML), $knownStyles);
+
+<!--- ? ---->
+
+
diff --git a/doc/Example-patch---add-new-via-field-for-links.html b/doc/Example-patch---add-new-via-field-for-links.html
new file mode 100644
index 00000000..7df9d253
--- /dev/null
+++ b/doc/Example-patch---add-new-via-field-for-links.html
@@ -0,0 +1,201 @@
+
+
+
+
+
+
+ Example patch to add a new field ("via") for links, an input field to set the "via" property from the "edit link" dialog, and display the "via" field in the link list display. Untested, use at your own risk
+Thanks to @Knah-Tsaeb in https://github.com/sebsauvage/Shaarli/pull/158
+From e0f363c18e8fe67990ed2bb1a08652e24e70bbcb Mon Sep 17 00:00:00 2001
+From: Knah Tsaeb <knah-tsaeb@knah-tsaeb.org>
+Date: Fri, 11 Oct 2013 15:18:37 +0200
+Subject: [PATCH] Add a "via"/origin property for links, add new input in "edit link" dialog
+Thanks to:
+* https://github.com/Knah-Tsaeb/Shaarli/commit/040eb18ec8cdabd5ea855e108f81f97fbf0478c4
+* https://github.com/Knah-Tsaeb/Shaarli/commit/4123658eae44d7564d1128ce52ddd5689efee813
+* https://github.com/Knah-Tsaeb/Shaarli/commit/f1a8ca9cc8fe49b119d51b2d8382cc1a34542f96
+
+---
+ index.php | 43 ++++++++++++++++++++++++++++++++-----------
+ tpl/editlink.html | 1 +
+ tpl/linklist.html | 1 +
+ 3 files changed, 34 insertions(+), 11 deletions(-)
+
+diff --git a/index.php b/index.php
+index 6fae2f8..53f798e 100644
+--- a/index.php
++++ b/index.php
+@@ -436,6 +436,12 @@ if (isset($_POST['login']))
+ // ------------------------------------------------------------------------------------------
+ // Misc utility functions:
+
++// Try to get just domain for @via
++function getJustDomain($url){
++ $parts = parse_url($url);
++ return trim($parts['host']);
++ }
++
+ // Returns the server URL (including port and http/https), without path.
+ // e.g. "http://myserver.com:8080"
+ // You can append $_SERVER['SCRIPT_NAME'] to get the current script URL.
+@@ -799,7 +805,8 @@ class linkdb implements Iterator, Countable, ArrayAccess
+ $found= (strpos(strtolower($l['title']),$s)!==false)
+ || (strpos(strtolower($l['description']),$s)!==false)
+ || (strpos(strtolower($l['url']),$s)!==false)
+- || (strpos(strtolower($l['tags']),$s)!==false);
++ || (strpos(strtolower($l['tags']),$s)!==false)
++ || (!empty($l['via']) && (strpos(strtolower($l['via']),$s)!==false));
+ if ($found) $filtered[$l['linkdate']] = $l;
+ }
+ krsort($filtered);
+@@ -814,7 +821,7 @@ class linkdb implements Iterator, Countable, ArrayAccess
+ $t = str_replace(',',' ',($casesensitive?$tags:strtolower($tags)));
+ $searchtags=explode(' ',$t);
+ $filtered=array();
+- foreach($this->links as $l)
++ foreach($this-> links as $l)
+ {
+ $linktags = explode(' ',($casesensitive?$l['tags']:strtolower($l['tags'])));
+ if (count(array_intersect($linktags,$searchtags)) == count($searchtags))
+@@ -905,7 +912,7 @@ function showRSS()
+ else $linksToDisplay = $LINKSDB;
+ $nblinksToDisplay = 50; // Number of links to display.
+ if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links.
+- {
++ {
+ $nblinksToDisplay = $_GET['nb']=='all' ? count($linksToDisplay) : max($_GET['nb']+0,1) ;
+ }
+
+@@ -944,7 +951,12 @@ function showRSS()
+ // If user wants permalinks first, put the final link in description
+ if ($usepermalinks===true) $descriptionlink = '(<a href="'.$absurl.'">Link</a>)';
+ if (strlen($link['description'])>0) $descriptionlink = '<br>'.$descriptionlink;
+- echo '<description><![CDATA['.nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description'])))).$descriptionlink.']]></description>'."\n</item>\n";
++ if(!empty($link['via'])){
++ $via = '<br>Origine => <a href="'.htmlspecialchars($link['via']).'">'.htmlspecialchars(getJustDomain($link['via'])).'</a>';
++ } else {
++ $via = '';
++ }
++ echo '<description><![CDATA['.nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description'])))).$via.$descriptionlink.']]></description>'."\n</item>\n";
+ $i++;
+ }
+ echo '</channel></rss><!-- Cached version of '.htmlspecialchars(pageUrl()).' -->';
+@@ -980,7 +992,7 @@ function showATOM()
+ else $linksToDisplay = $LINKSDB;
+ $nblinksToDisplay = 50; // Number of links to display.
+ if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links.
+- {
++ {
+ $nblinksToDisplay = $_GET['nb']=='all' ? count($linksToDisplay) : max($_GET['nb']+0,1) ;
+ }
+
+@@ -1006,11 +1018,16 @@ function showATOM()
+
+ // Add permalink in description
+ $descriptionlink = htmlspecialchars('(<a href="'.$guid.'">Permalink</a>)');
++ if(isset($link['via']) && !empty($link['via'])){
++ $via = htmlspecialchars('</br> Origine => <a href="'.$link['via'].'">'.getJustDomain($link['via']).'</a>');
++ } else {
++ $via = '';
++ }
+ // If user wants permalinks first, put the final link in description
+ if ($usepermalinks===true) $descriptionlink = htmlspecialchars('(<a href="'.$absurl.'">Link</a>)');
+ if (strlen($link['description'])>0) $descriptionlink = '<br>'.$descriptionlink;
+
+- $entries.='<content type="html">'.htmlspecialchars(nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description']))))).$descriptionlink."</content>\n";
++ $entries.='<content type="html">'.htmlspecialchars(nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description']))))).$descriptionlink.$via."</content>\n";
+ if ($link['tags']!='') // Adding tags to each ATOM entry (as mentioned in ATOM specification)
+ {
+ foreach(explode(' ',$link['tags']) as $tag)
+@@ -1478,7 +1495,7 @@ function renderPage()
+ if (!startsWith($url,'http:') && !startsWith($url,'https:') && !startsWith($url,'ftp:') && !startsWith($url,'magnet:') && !startsWith($url,'?'))
+ $url = 'http://'.$url;
+ $link = array('title'=>trim($_POST['lf_title']),'url'=>$url,'description'=>trim($_POST['lf_description']),'private'=>(isset($_POST['lf_private']) ? 1 : 0),
+- 'linkdate'=>$linkdate,'tags'=>str_replace(',',' ',$tags));
++ 'linkdate'=>$linkdate,'tags'=>str_replace(',',' ',$tags), 'via'=>trim($_POST['lf_via']));
+ if ($link['title']=='') $link['title']=$link['url']; // If title is empty, use the URL as title.
+ $LINKSDB[$linkdate] = $link;
+ $LINKSDB->savedb(); // Save to disk.
+@@ -1556,7 +1573,8 @@ function renderPage()
+ $title = (empty($_GET['title']) ? '' : $_GET['title'] ); // Get title if it was provided in URL (by the bookmarklet).
+ $description = (empty($_GET['description']) ? '' : $_GET['description']); // Get description if it was provided in URL (by the bookmarklet). [Bronco added that]
+ $tags = (empty($_GET['tags']) ? '' : $_GET['tags'] ); // Get tags if it was provided in URL
+- $private = (!empty($_GET['private']) && $_GET['private'] === "1" ? 1 : 0); // Get private if it was provided in URL
++ $via = (empty($_GET['via']) ? '' : $_GET['via'] );
++ $private = (!empty($_GET['private']) && $_GET['private'] === "1" ? 1 : 0); // Get private if it was provided in URL
+ if (($url!='') && parse_url($url,PHP_URL_SCHEME)=='') $url = 'http://'.$url;
+ // If this is an HTTP link, we try go get the page to extract the title (otherwise we will to straight to the edit form.)
+ if (empty($title) && parse_url($url,PHP_URL_SCHEME)=='http')
+@@ -1567,7 +1585,7 @@ function renderPage()
+ {
+ // Look for charset in html header.
+ preg_match('#<meta .*charset=.*>#Usi', $data, $meta);
+-
++
+ // If found, extract encoding.
+ if (!empty($meta[0]))
+ {
+@@ -1577,7 +1595,7 @@ function renderPage()
+ $html_charset = (!empty($enc[1])) ? strtolower($enc[1]) : 'utf-8';
+ }
+ else { $html_charset = 'utf-8'; }
+-
++
+ // Extract title
+ $title = html_extract_title($data);
+ if (!empty($title))
+@@ -1592,7 +1610,7 @@ function renderPage()
+ $url='?'.smallHash($linkdate);
+ $title='Note: ';
+ }
+- $link = array('linkdate'=>$linkdate,'title'=>$title,'url'=>$url,'description'=>$description,'tags'=>$tags,'private'=>$private);
++ $link = array('linkdate'=>$linkdate,'title'=>$title,'url'=>$url,'description'=>$description,'tags'=>$tags,'via' => $via,'private'=>$private);
+ }
+
+ $PAGE = new pageBuilder;
+@@ -1842,6 +1860,9 @@ function buildLinkList($PAGE,$LINKSDB)
+ $taglist = explode(' ',$link['tags']);
+ uasort($taglist, 'strcasecmp');
+ $link['taglist']=$taglist;
++ if(!empty($link['via'])){
++ $link['via']=htmlspecialchars($link['via']);
++ }
+ $linkDisp[$keys[$i]] = $link;
+ $i++;
+ }
+diff --git a/tpl/editlink.html b/tpl/editlink.html
+index 4a2c30c..14d4f9c 100644
+--- a/tpl/editlink.html
++++ b/tpl/editlink.html
+@@ -16,6 +16,7 @@
+ <i>Title</i><br><input type="text" name="lf_title" value="{$link.title|htmlspecialchars}" style="width:100%"><br>
+ <i>Description</i><br><textarea name="lf_description" rows="4" cols="25" style="width:100%">{$link.description|htmlspecialchars}</textarea><br>
+ <i>Tags</i><br><input type="text" id="lf_tags" name="lf_tags" value="{$link.tags|htmlspecialchars}" style="width:100%"><br>
++ <i>Origine</i><br><input type="text" name="lf_via" value="{$link.via|htmlspecialchars}" style="width:100%"><br>
+ {if condition="($link_is_new && $GLOBALS['privateLinkByDefault']==true) || $link.private == true"}
+ <input type="checkbox" checked="checked" name="lf_private" id="lf_private">
+ <label for="lf_private"><i>Private</i></label><br>
+diff --git a/tpl/linklist.html b/tpl/linklist.html
+index ddc38cb..0a8475f 100644
+--- a/tpl/linklist.html
++++ b/tpl/linklist.html
+@@ -43,6 +43,7 @@
+ <span class="linktitle"><a href="{$redirector}{$value.url|htmlspecialchars}">{$value.title|htmlspecialchars}</a></span>
+ <br>
+ {if="$value.description"}<div class="linkdescription"{if condition="$search_type=='permalink'"} style="max-height:none !important;"{/if}>{$value.description}</div>{/if}
++ {if condition="isset($value.via) && !empty($value.via)"}<div><a href="{$value.via}">Origine => {$value.via|getJustDomain}</a></div>{/if}
+ {if="!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()"}
+ <span class="linkdate" title="Permalink"><a href="?{$value.linkdate|smallHash}">{$value.localdate|htmlspecialchars} - permalink</a> - </span>
+ {else}
+--
+2.1.1
+
+
diff --git a/doc/Home.html b/doc/Home.html
new file mode 100644
index 00000000..e4d117f1
--- /dev/null
+++ b/doc/Home.html
@@ -0,0 +1,368 @@
+
+
+
+
+
+
+ Welcome to the Shaarli wiki! Here you can find some info on how to use, configure, tweak and solve problems with your Shaarli. For general info, read the README.
+If you have any questions or ideas, please join the chat (also reachable via IRC), post them in our general discussion or read the current issues. If you've found a bug, please create a new issue.
+If you'd like a feature added, see if it fits in the list of Ideas for Plugins and update the corresponding bug report.
+Note: This documentation is available online at https://github.com/shaarli/Shaarli/wiki, and locally in the doc/
directory of your Shaarli installation.
Sessions do not seem to work correctly on your server
Login
Tools
button in the top bar✚Shaare link
button, and drop it to your browser's bookmarks bar.This bookmarklet button in compatible with Firefox, Opera, Chrome and Safari. Under Opera, you can't drag'n drop the button: You have to right-click on it and add a bookmark to your personal toolbar.
+ +Save
.Voila! Your link is now shared.Shaarli can be used:
+readlater
)music
or video
tags)discussion
)Add Link
buttonAdd Link
Private
then click Save
It is possible to filter RSS/ATOM feeds and Picture Wall on a Shaarli to only display results of a specific search, or for a specific tag. For example, if you want to subscribe only to links tagged photography
:
photography
tag in the Filter by tag box. Links tagged photography
are displayed.RSS Feed
button.nature
?)https://my.shaarli.domain/?do=rss&searchtags=nature
, https://my.shaarli.domain/links/?do=picwall&searchterm=poney
+
To change the configuration, create the file data/options.php
, example:
<?php
+ $GLOBALS['config']['LINKS_PER_PAGE'] = 30;
+ $GLOBALS['config']['HIDE_TIMESTAMPS'] = true;
+ $GLOBALS['config']['ENABLE_THUMBNAILS'] = false;
+ ?>
+Do not edit config options in index.php! Your changes would be lost when you upgrade. The following parameters are available (parameters (default value)):
+DATADIR ('data')
: This is the name of the subdirectory where Shaarli stores is data file. You can change it for better security.CONFIG_FILE ($GLOBALS['config']['DATADIR'].'/config.php')
: Name of file which is used to store login/password.DATASTORE ($GLOBALS['config']['DATADIR'].'/datastore.php')
: Name of file which contains the link database.LINKS_PER_PAGE (20)
: Default number of links per page displayed.IPBANS_FILENAME ($GLOBALS['config']['DATADIR'].'/ipbans.php')
: Name of file which records login attempts and IP bans.BAN_AFTER (4)
: An IP address will be banned after this many failed login attempts.BAN_DURATION (1800)
: Duration of ban (in seconds). (1800 seconds = 30 minutes)OPEN_SHAARLI (false)
: If you set this option to true, anyone will be able to add/modify/delete/import/exports links without having to login.HIDE_TIMESTAMPS (false)
: If you set this option to true, the date/time of each link will not be displayed (including in RSS Feed).ENABLE_THUMBNAILS (true)
: Enable/disable thumbnails.RAINTPL_TMP (tmp/)
: Raintpl cache directory (keep the trailing slash!)CACHEDIR ('cache')
: Directory where the thumbnails are stored.ENABLE_LOCALCACHE (true)
: If you have a limited quota on your webspace, you can set this option to false: Shaarli will not generate thumbnails which need to be cached locally (vimeo, flickr, etc.). Thumbnails will still be visible for the services which do not use the local cache (youtube.com, imgur.com, dailymotion.com, imageshack.us)UPDATECHECK_FILENAME ($GLOBALS['config']['DATADIR'].'/lastupdatecheck.txt')
: name of the file used to store available shaarli version.UPDATECHECK_INTERVAL (86400)
: Delay between new Shaarli version check. 86400 seconds = 24 hours. Note that if you do not login for a week, Shaarli will not check for new version for a week.ENABLE_UPDATECHECK
: Determines whether Shaarli check for new releases at https://github.com/shaarli/ShaarliSHOW_ATOM (false)
: Show an ATOM Feed
button next to the Subscribe
(RSS) button. ATOM feeds are available at the address ?do=atom
regardless of this option.ARCHIVE_ORG (false)
: For each link, display a link to an archived version on archive.orgENABLE_RSS_PERMALINKS (true)
: choose whether the RSS item title link points directly to the link, or to the entry on Shaarli (permalink). true
is the original Shaarli bahevior (point directly to the link)inc/user.css
. This file allows to override rules defined in the main inc/shaarli.css
(only add changed rules), or define a whole new theme.inc/shaarli.css
! Your changes would be overriden when updating Shaarli.See also:
+ +| 💥 | This feature is currently being worked on and will be improved in the next releases. Experimental. |
|---------|---------|
tpl/
directory, run git clone https://url/of/my-template/
or unpack the zip archive. There should now be a my-template/
directory under the tpl/
dir, containing directly all the template files.data/options.php
to have Shaarli use this template. Eg.$GLOBALS['config']['RAINTPL_TPL'] = 'tpl/my-template/' ;
You can find a list of compatible templates in Related Software
+You have two ways of backing up your database:
+data/datastore.php
(by FTP or SSH). Restore by putting the file back in place.rsync -avzP my.server.com:/var/www/shaarli/data/datastore.php datastore-$(date +%Y-%m-%d_%H%M).php
Tools
> Export
). Restore by using the Import
feature../export-bookmarks.py --url=https://my.server.com/shaarli --username=myusername --password=mysupersecretpassword --download-dir=./ --type=all
Delete the file data/config.php and display the page again. You will be asked for a new login/password.
+Login form is protected against brute force attacks: 4 failed logins will ban the IP address from login for 30 minutes. Banned IPs can still browse links.
+To remove the current IP bans, delete the file data/ipbans.php
The file data/log.txt
shows all logins (successful or failed) and bans/lifted bans.
Search for failed
in this file to look for unauthorized login attempts.
If you export your bookmark from Diigo, make sure you use the Delicious export, not the Netscape export. (Their Netscape export is broken, and they don't seem to be interested in fixing it.)
+To correctly import the tags from a SemanticScuttle HTML export, edit the HTML file before importing and replace all occurences of tags=
(lowercase) to TAGS=
(uppercase).
See this issue for import tweaks.
+sessions
directory at the root of your webspace. Change the file extension to .php5
or create a .htaccess
file in the directory where Shaarli is located containing:php 1
+SetEnv PHP_VER 5
+Parse error: syntax error, unexpected '=', expecting '(' in /links/index.php on line xxx
, it means that your host is using php4, not php5. Shaarli requires php 5.1. Try changing the file extension to .php5
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /…/index.php on line xxx
, it means that your host has disabled the ability to fetch a file by HTTP in the php config (Typically in 1and1 hosting). Bad host. Change host. Or comment the following lines://list($status,$headers,$data) = getHTTP($url,4); // Short timeout to keep the application responsive.
+// FIXME: Decode charset according to charset specified in either 1) HTTP response headers or 2) <head> in html
+//if (strpos($status,'200 OK')) $title=html_extract_title($data);
+<? // tout ce qui est charge ici (generalement des includes et require) est charge en permanence. ?>
. To fix this, remove this message from php-include/prepend.php
Shaarli tries to sniff the language of the browser (using HTTP_ACCEPT_LANGUAGE headers) and choose a date format accordingly. But Shaarli can only use the date formats (and more generaly speaking, the locales) provided by the webserver. So even if you have a browser in French, you may end up with dates in US format (it's the case on sebsauvage.net :-( )
+On CentOS/RedHat derivatives, you may need to install the php-mbstring
package.
This can be caused by several things:
+session
directory on the root of your website.) You may need to create the session directory of set it up.sessions
subdirectory and add ini_set('session.save_path', $_SERVER['DOCUMENT_ROOT'].'/../sessions');
. Make sure this directory is not browsable !)Sessions do not seem to work correctly on your server
Follow the instructions in the error message. Make sure you are accessing shaarli via a direct IP address or a proper hostname. If you have no dots in the hostname (e.g. localhost
or http://my-webserver/shaarli/
), some browsers will not store cookies at all (this respects the HTTP cookie specification).
Download publisher.php at the root of your Shaarli installation and set $GLOBALS['config']['PUBSUBHUB_URL']
in your config.php
<input type="hidden" name="lf_linkdate" value="{$link.linkdate}">
in tpl/editlink.tpl
(line 14)type="hidden"
from this lineYYYMMDD_HHMMS
.$data = "tZNdb9MwFIb... <Commented content inside datastore.php>";
+$out = unserialize(gzinflate(base64_decode($data)));
+echo "<pre>"; // Pretty printing is love, pretty printing is life
+print_r($out);
+echo "</pre>";
+exit;
+This will output the internal representation of the datastore, "unobfuscated" (if this can really be considered obfuscation)
+Unofficial but relatedd work on Shaarli. If you maintain one of these, please get in touch with us to help us find a way to adapt your work to our fork. TODO contact repos owners to see if they'd like to standardize their work for the community fork.
+I was a StumbleUpon user. Then I got fed up with they big toolbar. I switched to delicious, which was lighter, faster and more beautiful. Until Yahoo bought it. Then the export API broke all the time, delicious became slow and was ditched by Yahoo. I switched to Diigo, which is not bad, but does too much. And Diigo is sslllooooowww and their Firefox extension a bit buggy. And… oh… their Firefox addon sends to Diigo every single URL you visit (Don't believe me ? Use Tamper Data and open any page).
+Enough is enough. Saving simple links should not be a complicated heavy thing. I ditched them all and wrote my own: Shaarli. It's simple, but it does the job and does it well. And my data is not hosted on a foreign server, but on my server.
+With Shaarli:
+Shaarli is for shaaring your links.
+Link database is an associative array which is serialized, compressed (with deflate), base64-encoded and saved as a comment in a .php file. Thus even if the server does not support htaccess files, the data file will still not be readable by URL. The database looks like this:
+<?php /* zP1ZjxxJtiYIvvevEPJ2lDOaLrZv7o...
+...ka7gaco/Z+TFXM2i7BlfMf8qxpaSSYfKlvqv/x8= */ ?>
HTTP_REFERER
for some functions (like redirects and clicking on tags). If you have disabled or masqueraded HTTP_REFERER
in your browser, some features of Shaarli may not workmagic_quotes
is a horrible option of php which is often activated on servers. No serious developer should rely on this horror to secure their code against SQL injections. You should disable it (and Shaarli expects this option to be disabled). Nevertheless, I have added code to cope with magic_quotes on, so you should not be bothered even on crappy hosts.Small hashes are used to make a link to an entry in Shaarli. They are unique. In fact, the date of the items (eg.20110923_150523) is hashed with CRC32, then converted to base64 and some characters are replaced. They are always 6 characters longs and use only A-Z a-z 0-9 - _ and @.
Here is the directory structure of Shaarli and the purpose of the different files:
+ index.php : Main program.
+ COPYING : Shaarli license.
+ inc/ : Includes (libraries, CSS…)
+ shaarli.css : Shaarli stylesheet.
+ jquery.min.js : jQuery javascript library.
+ jquery-ui.min.js : jQuery-UI javascript library.
+ jquery-MIT-LICENSE.txt: jQuery license.
+ jquery.lazyload.min.js: LazyLoad javascript library.
+ rain.tpl.class.php : RainTPL templating library.
+ tpl/ : RainTPL templates for Shaarli. They are used to build the pages.
+ images/ : Images and icons used in Shaarli.
+ data/ : Directory where data is stored (bookmark database, configuration, logs, banlist…)
+ config.php : Shaarli configuration (login, password, timezone, title…)
+ datastore.php : Your link database (compressed).
+ ipban.php : IP address ban system data.
+ lastupdatecheck.txt : Update check timestamp file (used to check every 24 hours if a new version of Shaarli is available).
+ log.txt : login/IPban log.
+ cache/ : Directory containing the thumbnails cache. This directory is automatically created. You can erase it anytime you want.
+ tmp/ : Temporary directory for compiled RainTPL templates. This directory is automatically created. You can erase it anytime you want.
+Does browsing this page feel slow ? Try browsing older pages, too.
+It's not slow at all, is it ? And don't forget the database contains more than 16000 links, and it's on a shared host, with 32000 visitors/day for my website alone. And it's still damn fast. Why ?
+The data file is only 3.7 Mb. It's read 99% of the time, and is probably already in the operation system disk cache. So generating a page involves no I/O at all most of the time.
+...
+ + diff --git a/doc/Home.md b/doc/Home.md index c80b8c92..bbece989 100644 --- a/doc/Home.md +++ b/doc/Home.md @@ -8,6 +8,52 @@ If you'd like a feature added, see if it fits in the list of [Ideas for Plugins] _Note: This documentation is available online at https://github.com/shaarli/Shaarli/wiki, and locally in the `doc/` directory of your Shaarli installation._ +---------------------------------------------------------------------------------- + + + +- [Basic Usage](#basic-usage) + - [Add the sharing button (_bookmarklet_) to your browser](#add-the-sharing-button-_bookmarklet_-to-your-browser) + - [Share links using the _bookmarklet_](#share-links-using-the-_bookmarklet_) +- [Other usage examples](#other-usage-examples) + - [Using Shaarli as a blog, notepad, pastebin...](#using-shaarli-as-a-blog-notepad-pastebin) + - [RSS Feeds or Picture Wall for a specific search/tag](#rss-feeds-or-picture-wall-for-a-specific-searchtag) +- [Configuration](#configuration) + - [Main data/options.php file](#main-dataoptionsphp-file) + - [Changing theme](#changing-theme) + - [Changing template](#changing-template) +- [Backup](#backup) +- [Troubleshooting](#troubleshooting) + - [I forgot my password !](#i-forgot-my-password-) + - [I'm locked out - Login bruteforce protection](#im-locked-out---login-bruteforce-protection) + - [List of all login attempts](#list-of-all-login-attempts) + - [Exporting from Diigo](#exporting-from-diigo) + - [Importing from SemanticScuttle](#importing-from-semanticscuttle) + - [Importing from Mister Wong](#importing-from-mister-wong) + - [Hosting problems](#hosting-problems) + - [Dates are not properly formatted](#dates-are-not-properly-formatted) + - [Problems on CentOS servers](#problems-on-centos-servers) + - [My session expires ! I can't stay logged in](#my-session-expires--i-cant-stay-logged-in) + - [`Sessions do not seem to work correctly on your server`](#sessions-do-not-seem-to-work-correctly-on-your-server) + - [pubsubhubbub support](#pubsubhubbub-support) +- [Notes](#notes) + - [Various hacks](#various-hacks) + - [Changing timestamp for a link](#changing-timestamp-for-a-link) +- [Related software](#related-software) +- [Other links](#other-links) +- [FAQ](#faq) + - [Why did you create Shaarli ?](#why-did-you-create-shaarli-) + - [Why use Shaarli and not Delicious/Diigo ?](#why-use-shaarli-and-not-deliciousdiigo-) + - [What does Shaarli mean ?](#what-does-shaarli-mean-) +- [Technical details](#technical-details) + - [Directory structure](#directory-structure) + - [Why not use a real database ? Files are slow !](#why-not-use-a-real-database--files-are-slow-) +- [Wiki - TODO](#wiki---todo) + + + + + ------------------------------------------------------------------ # Basic Usage @@ -139,17 +185,6 @@ You have two ways of backing up your database: * This can be done using the [shaarchiver](https://github.com/nodiscc/shaarchiver) tool. Example command: `./export-bookmarks.py --url=https://my.server.com/shaarli --username=myusername --password=mysupersecretpassword --download-dir=./ --type=all` - -# Login bruteforce protection -Login form is protected against brute force attacks: 4 failed logins will ban the IP address from login for 30 minutes. Banned IPs can still browse links. - -To remove the current IP bans, delete the file `data/ipbans.php` - -## List of all login attempts - -The file `data/log.txt` shows all logins (successful or failed) and bans/lifted bans. -Search for `failed` in this file to look for unauthorized login attempts. - # Troubleshooting ### I forgot my password ! @@ -157,6 +192,18 @@ Search for `failed` in this file to look for unauthorized login attempts. Delete the file data/config.php and display the page again. You will be asked for a new login/password. + +### I'm locked out - Login bruteforce protection +Login form is protected against brute force attacks: 4 failed logins will ban the IP address from login for 30 minutes. Banned IPs can still browse links. + +To remove the current IP bans, delete the file `data/ipbans.php` + +### List of all login attempts + +The file `data/log.txt` shows all logins (successful or failed) and bans/lifted bans. +Search for `failed` in this file to look for unauthorized login attempts. + + ### Exporting from Diigo If you export your bookmark from Diigo, make sure you use the Delicious export, not the Netscape export. (Their Netscape export is broken, and they don't seem to be interested in fixing it.) diff --git a/doc/Ideas-for-plugins.html b/doc/Ideas-for-plugins.html new file mode 100644 index 00000000..8ca3572c --- /dev/null +++ b/doc/Ideas-for-plugins.html @@ -0,0 +1,26 @@ + + + + + + +Please list here ideas for potential plugins. Do not include lengthy discussion about why/how the plugin should work, but link instead to an issue where this would have been discussed.
By listing these ideas here, we can keep the issues list a bit more clean, and have a centralized place where people wanting to contribute can find potential enhancement ideas.
Also have a look at https://github.com/shaarli/Shaarli/issues/14 for other suggestions.
Sessions do not seem to work correctly on your server