mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-16 14:48:11 +00:00
Some new help functions, some cleanup.
This commit is contained in:
@@ -229,13 +229,16 @@ class AccountController extends BaseController
|
||||
case 'Asset account':
|
||||
case 'Default account':
|
||||
$subTitleIcon = 'fa-money';
|
||||
$what = 'asset';
|
||||
break;
|
||||
case 'Expense account':
|
||||
case 'Beneficiary account':
|
||||
$subTitleIcon = 'fa-shopping-cart';
|
||||
$what = 'expense';
|
||||
break;
|
||||
case 'Revenue account':
|
||||
$subTitleIcon = 'fa-download';
|
||||
$what = 'revenue';
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -254,7 +257,7 @@ class AccountController extends BaseController
|
||||
}
|
||||
|
||||
|
||||
return View::make('accounts.show', compact('account', 'view', 'subTitleIcon', 'journals'))->with('account', $account)->with(
|
||||
return View::make('accounts.show', compact('account', 'what', 'view', 'subTitleIcon', 'journals'))->with('account', $account)->with(
|
||||
'subTitle', 'Details for ' . strtolower($account->accountType->type) . ' "' . $account->name . '"'
|
||||
);
|
||||
}
|
||||
|
||||
46
app/controllers/HelpController.php
Normal file
46
app/controllers/HelpController.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
class HelpController extends BaseController
|
||||
{
|
||||
public function show($route)
|
||||
{
|
||||
// no valid route
|
||||
if (!Route::has($route)) {
|
||||
$helpText = '<p>There is no help for this route!</p>';
|
||||
$helpTitle = 'Help';
|
||||
|
||||
return Response::json(['title' => $helpTitle, 'text' => $helpText]);
|
||||
}
|
||||
|
||||
// content in cache
|
||||
if (Cache::has('help.' . $route . '.title') && Cache::has('help.' . $route . '.text')) {
|
||||
$helpText = Cache::get('help.' . $route . '.text');
|
||||
$helpTitle = Cache::get('help.' . $route . '.title');
|
||||
|
||||
return Response::json(['title' => $helpTitle, 'text' => $helpText]);
|
||||
}
|
||||
|
||||
// get the help-content from Github:
|
||||
$URL = 'https://raw.githubusercontent.com/JC5/firefly-iii-help/master/' . e($route) . '.md';
|
||||
try {
|
||||
$content = file_get_contents($URL);
|
||||
} catch (ErrorException $e) {
|
||||
$content = '<p>There is no help for this route.</p>';
|
||||
}
|
||||
if (strlen($content) > 0) {
|
||||
$helpText = \Michelf\Markdown::defaultTransform($content);
|
||||
$helpTitle = $route;
|
||||
|
||||
Cache::put('help.' . $route . '.text', $helpText, 10080); // a week.
|
||||
Cache::put('help.' . $route . '.title', $helpTitle, 10080);
|
||||
|
||||
return Response::json(['title' => $helpTitle, 'text' => $helpText]);
|
||||
}
|
||||
|
||||
$helpText = '<p>There is no help for this route!</p>';
|
||||
$helpTitle = 'Help';
|
||||
|
||||
return Response::json(['title' => $helpTitle, 'text' => $helpText]);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user