From: Nicolas Lœuillet
Date: Sun, 25 Aug 2013 05:43:16 +0000 (-0700)
Subject: Merge pull request #170 from NumEricR/login-button
X-Git-Tag: 1.0-beta4~12
X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=1cbd70639c5f97f6030d0df6624ca200dba86945;hp=06cf8fb9636d2fd1cc3b342b26d0fea2b404ce74;p=github%2Fwallabag%2Fwallabag.git
Merge pull request #170 from NumEricR/login-button
Login button
---
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 9d6ba132..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-language: php
-
-php:
- - 5.4
-
-branches:
- only:
- - dev
-
-before_script:
- - composer install
-
-notifications:
- email:
- - nicolas.loeuillet@gmail.com
\ No newline at end of file
diff --git a/COPYING b/COPYING.md
similarity index 100%
rename from COPYING
rename to COPYING.md
diff --git a/CREDITS b/CREDITS.md
similarity index 100%
rename from CREDITS
rename to CREDITS.md
diff --git a/TODO.md b/TODO.md
index ac3c0e98..fdba2a51 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,11 +1,9 @@
# TODO
-pouvoir annuler la suppression
-conventions codage ? phing ? vérifier error_log qui trainent
-phpDocumentor
-minifier css
-revoir tous les css
-barre fixe d'admin sur la page d'un billet ?
-revoir export (export vers pocket &cie ? )
-raccourcis clavier
-date d'ajout d'un lien
\ No newline at end of file
+* pouvoir annuler la suppression
+* conventions codage ? phing ? vérifier error_log qui trainent
+* phpDocumentor
+* minifier css
+* barre fixe d'admin sur la page d'un billet ?
+* revoir export (export vers pocket &cie ? )
+* raccourcis clavier
\ No newline at end of file
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 4832f816..cb338766 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -364,13 +364,14 @@ class Poche
/**
* import from Instapaper. poche needs a ./instapaper-export.html file
* @todo add the return value
+ * @param string $targetFile the file used for importing
* @return boolean
*/
- private function importFromInstapaper()
+ private function importFromInstapaper($targetFile)
{
# TODO gestion des articles favs
$html = new simple_html_dom();
- $html->load_file('./instapaper-export.html');
+ $html->load_file($targetFile);
Tools::logm('starting import from instapaper');
$read = 0;
@@ -403,13 +404,14 @@ class Poche
/**
* import from Pocket. poche needs a ./ril_export.html file
* @todo add the return value
+ * @param string $targetFile the file used for importing
* @return boolean
*/
- private function importFromPocket()
+ private function importFromPocket($targetFile)
{
# TODO gestion des articles favs
$html = new simple_html_dom();
- $html->load_file('./ril_export.html');
+ $html->load_file($targetFile);
Tools::logm('starting import from pocket');
$read = 0;
@@ -442,12 +444,13 @@ class Poche
/**
* import from Readability. poche needs a ./readability file
* @todo add the return value
+ * @param string $targetFile the file used for importing
* @return boolean
*/
- private function importFromReadability()
+ private function importFromReadability($targetFile)
{
# TODO gestion des articles lus / favs
- $str_data = file_get_contents("./readability");
+ $str_data = file_get_contents($targetFile);
$data = json_decode($str_data,true);
Tools::logm('starting import from Readability');
$count = 0;
@@ -499,15 +502,31 @@ class Poche
*/
public function import($from)
{
- if ($from == 'pocket') {
- return $this->importFromPocket();
+ $providers = array(
+ 'pocket' => 'importFromPocket',
+ 'readability' => 'importFromReadability',
+ 'instapaper' => 'importFromInstapaper'
+ );
+
+ if (! isset($providers[$from])) {
+ $this->messages->add('e', _('Unknown import provider.'));
+ Tools::redirect();
}
- else if ($from == 'readability') {
- return $this->importFromReadability();
+
+ $targetDefinition = 'IMPORT_' . strtoupper($from) . '_FILE';
+ $targetFile = constant($targetDefinition);
+
+ if (! defined($targetDefinition)) {
+ $this->messages->add('e', _('Incomplete inc/poche/define.inc.php file, please define "' . $targetDefinition . '".'));
+ Tools::redirect();
}
- else if ($from == 'instapaper') {
- return $this->importFromInstapaper();
+
+ if (! file_exists($targetFile)) {
+ $this->messages->add('e', _('Could not find required "' . $targetFile . '" import file.'));
+ Tools::redirect();
}
+
+ $this->$providers[$from]($targetFile);
}
/**
diff --git a/inc/poche/Url.class.php b/inc/poche/Url.class.php
index 3c74fb43..d7ee911f 100644
--- a/inc/poche/Url.class.php
+++ b/inc/poche/Url.class.php
@@ -27,9 +27,7 @@ class Url
public function isCorrect()
{
- $pattern = '|^(.*:)//([a-z\-.]+)(:[0-9]+)?(.*)$|i';
-
- return preg_match($pattern, $this->url);
+ return filter_var($this->url, FILTER_VALIDATE_URL) !== FALSE;
}
public function clean()
@@ -73,7 +71,7 @@ class Url
if (preg_replace('/\s+/', '', $body->value) !== "") {
$html = $tidy->value;
}
- }
+ }
$parameters = array();
if (isset($html) and strlen($html) > 0)
diff --git a/inc/poche/define.inc.php b/inc/poche/define.inc.php
index 2154ce88..2d0a39ec 100644
--- a/inc/poche/define.inc.php
+++ b/inc/poche/define.inc.php
@@ -29,4 +29,8 @@ define ('TPL', __DIR__ . '/../../tpl');
define ('LOCALE', __DIR__ . '/../../locale');
define ('CACHE', __DIR__ . '/../../cache');
define ('PAGINATION', '10');
-define ('THEME', 'light');
\ No newline at end of file
+define ('THEME', 'light');
+
+define ('IMPORT_POCKET_FILE', './ril_export.html');
+define ('IMPORT_READABILITY_FILE', './readability');
+define ('IMPORT_INSTAPAPER_FILE', './instapaper-export.html');
\ No newline at end of file
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
deleted file mode 100644
index e69de29b..00000000
diff --git a/tpl/config.twig b/tpl/config.twig
index 8851c3dc..89d5bf84 100644
--- a/tpl/config.twig
+++ b/tpl/config.twig
@@ -11,24 +11,21 @@
{% endblock %}
{% block content %}
-
{% trans "Poching a link" %}
You can poche a link by several methods: (?)
-
-
-
+
+
{% trans "Updating poche" %}
-
+
-
{% trans "Change your password" %}