public function test_realArticles() { $urls = array("http://spectrum.ieee.org/cars-that-think/transportation/self-driving/california-may-be-making-testing-selfdriving-cars-easier", "http://feedproxy.google.com/~r/cnx-software/blog/~3/j4GR4BG3ptY/", "http://feeds.sciencedaily.com/~r/sciencedaily/top_news/top_science/~3/vGzKzIZOy4E/160930144424.htm", "http://arstechnica.com/science/2016/10/hurricane-matthew-may-strike-the-florida-space-coast-threaten-iconic-nasa-buildings/", "http://arstechnica.com/gadgets/2016/10/galaxy-note-7-recall-part-2-samsung-admits-replacement-units-are-unsafe/"); foreach ($urls as $url) { echo "Testing against page: " . $url; $doc = new DOMDocument(); $doc->preserveWhiteSpace = FALSE; downloadArticle($doc, $url); parseArticle($doc); if (isset($GLOBALS["error"])) { echo "Error: " . $GLOBALS["error"] . "\n"; } } }
/** * Execute the console command. * * @return mixed */ public function handle() { $name = $this->argument('name'); $ext = strpos($name, '.md') ? '' : '.md'; $filepath = storage_path('app/posts') . '/' . $name . $ext; try { $inputs = parseArticle($filepath); $res = $this->post->getByColumn($inputs['slug'], 'slug'); if (is_null($res)) { $this->post->store($inputs); $this->info($name . ' parsed successfully!'); } else { $this->post->update($inputs, $res->id); $this->info($name . ' updated successfully!'); } } catch (Exception $e) { $this->error($name . ' parsed failed! Please check the syntax.', 10); } }
if (isset($_GET["debug"])) { if ($_GET["debug"] == true) { $GLOBALS["debug"] = 1; } } if (isset($_GET["academic"])) { if ($_GET["academic"] == true) { echo "<p>Was an academic source, getting access past pay-wall...</p>"; //echo "<p>Get Academic Returned: ".getAcademicPage($_GET["targetUrl"])."</p>"; @$doc->loadHTML(getAcademicPage($_GET["targetUrl"])); // we don't want to see every parse fail } } else { downloadArticle($doc, $_GET["targetUrl"]); } parseArticle($doc); } ?> <!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" type="text/css" href="styles/main.css"> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <?php echo "<title>" . $GLOBALS["title"] . "</title>"; ?> </head> <body>
/** * Upload File with Markdown Form. * @param Request $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function upload(Request $request) { $file = $request->file('upload-file'); $filename = $file->getClientOriginalName(); $filepath = storage_path('app/posts') . '/' . $filename; $file->move(storage_path('app/posts'), $filename); $parsed = parseArticle($filepath); $post = $this->blog->getByColumn($parsed['slug'], 'slug'); if (is_null($post)) { $post = new Post($parsed); $post->published = isset($parsed['publish']); return view('back.blog.create', compact('post')); } else { foreach ($parsed as $key => $value) { $post->{$key} = $value; } $post->published = isset($parsed['publish']); return view('back.blog.edit', compact('post')); } }