/**
* Parses uploaded Markdown files and displays them (does NOT insert)
*
* @param Request $request
*
* @return mixed Depending on validation: Redirect or Response
*/
public function postImport(Request $request)
{
// Check if files have been uploaded
$store = Storage::disk('local');
$files = $store->files('import');
if (count($files) <= 0) {
return redirect('/import')->withErrors(['content' => 'Please input something to import!']);
}
// Now loop through all found files and extract the notes
$notes = new Collection();
$converter = new HtmlConverter(array('strip_tags' => true));
foreach ($files as $file) {
$fcontents = $store->get($file);
if (in_array(pathinfo($file, PATHINFO_EXTENSION), $this->html_extensions)) {
// We need to convert it to markdown first.
$fcontents = $converter->convert($fcontents);
}
$notes = $notes->merge($this->retrieveNotes($fcontents, $request->suggestTags, $request->headingType));
}
// Now clear the directory
$store->delete($files);
// TODO: Check for custom elements (h2, h3, ps, etc.)
// Now in $notes all h4s with trailing stuff should reside
return view('imports.confirm', compact('notes'));
}