1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-09-15 18:57:05 +00:00

Merge remote-tracking branch 'upstream/dev' into dev

This commit is contained in:
Vincent Malley 2015-06-02 11:09:37 -04:00
commit 900f2a9160
8 changed files with 60 additions and 19 deletions

View file

@ -732,6 +732,27 @@ class Poche
$html->load_file($_FILES['file']['tmp_name']); $html->load_file($_FILES['file']['tmp_name']);
$data = array(); $data = array();
$read = 0; $read = 0;
if (Tools::get_doctype($html)->innertext == "<!DOCTYPE NETSCAPE-Bookmark-file-1>") {
// Firefox-bookmarks HTML
foreach (array('DL','ul') as $list) {
foreach ($html->find($list) as $ul) {
foreach ($ul->find('DT') as $li) {
$tmpEntry = array();
$a = $li->find('A');
$tmpEntry['url'] = $a[0]->href;
$tmpEntry['tags'] = $a[0]->tags;
$tmpEntry['is_read'] = $read;
if ($tmpEntry['url']) {
$data[] = $tmpEntry;
}
}
# the second <ol/ul> is for read links
$read = ((sizeof($data) && $read)?0:1);
}
}
} else {
// regular HTML
foreach (array('ol','ul') as $list) { foreach (array('ol','ul') as $list) {
foreach ($html->find($list) as $ul) { foreach ($html->find($list) as $ul) {
foreach ($ul->find('li') as $li) { foreach ($ul->find('li') as $li) {
@ -749,6 +770,7 @@ class Poche
} }
} }
} }
}
// for readability structure // for readability structure
@ -766,7 +788,7 @@ class Poche
$urlsInserted = array(); //urls of articles inserted $urlsInserted = array(); //urls of articles inserted
foreach($data as $record) { foreach($data as $record) {
$url = trim(isset($record['article__url']) ? $record['article__url'] : (isset($record['url']) ? $record['url'] : '')); $url = trim(isset($record['article__url']) ? $record['article__url'] : (isset($record['url']) ? $record['url'] : ''));
if ($url and !in_array($url, $urlsInserted)) { if (filter_var($url, FILTER_VALIDATE_URL) and !in_array($url, $urlsInserted)) {
$title = (isset($record['title']) ? $record['title'] : _('Untitled - Import - ') . '</a> <a href="./?import">' . _('click to finish import') . '</a><a>'); $title = (isset($record['title']) ? $record['title'] : _('Untitled - Import - ') . '</a> <a href="./?import">' . _('click to finish import') . '</a><a>');
$body = (isset($record['content']) ? $record['content'] : ''); $body = (isset($record['content']) ? $record['content'] : '');
$isRead = (isset($record['is_read']) ? intval($record['is_read']) : (isset($record['archive']) ? intval($record['archive']) : 0)); $isRead = (isset($record['is_read']) ? intval($record['is_read']) : (isset($record['archive']) ? intval($record['archive']) : 0));

View file

@ -141,7 +141,7 @@ class Routing
$pdf->producePDF(); $pdf->producePDF();
} elseif (isset($_GET['import'])) { } elseif (isset($_GET['import'])) {
$import = $this->wallabag->import(); $import = $this->wallabag->import();
$tplVars = array_merge($this->vars, $import); $this->vars = array_merge($this->vars, $import);
} elseif (isset($_GET['empty-cache'])) { } elseif (isset($_GET['empty-cache'])) {
Tools::emptyCache(); Tools::emptyCache();
} elseif (isset($_GET['export'])) { } elseif (isset($_GET['export'])) {

View file

@ -420,4 +420,23 @@ final class Tools
return str_replace('+', '', $token); return str_replace('+', '', $token);
} }
/**
*
* Returns the doctype for an HTML document (used for Mozilla Bookmarks)
* @param simple_html_dom $doc
* @return doctype $el
*
*/
public static function get_doctype($doc)
{
$els = $doc->find('unknown');
foreach ($els as $e => $el)
if ($el->parent()->tag == 'root')
return $el;
return NULL;
}
} }

View file

@ -36,8 +36,6 @@ if (isset($_SERVER['HTTP_COOKIE'])) {
if (isset($_SESSION['poche_user'])) { if (isset($_SESSION['poche_user'])) {
unset($_SESSION['poche_user']); unset($_SESSION['poche_user']);
} }
session_destroy();
if (isset($_GET['clean'])) { if (isset($_GET['clean'])) {
if (is_dir('install')){ if (is_dir('install')){

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -2,11 +2,13 @@
<!-- <!--
$(document).ready(function() { $(document).ready(function() {
$("body").css("cursor", "wait"); $("body").css("cursor", "wait");
$("#content").css("display", "none");
setTimeout(function(){ setTimeout(function(){
window.location = './?import'; window.location = './?import';
}, {{ import.delay }} ); }, {{ import.delay }} );
}); });
//--> //-->
</script> </script>
<div class="messages warning"> <div class="messages warning">