/**
  * Boot the service provider.
  */
 public function boot()
 {
     $appDomain = $appLocale = $appTimezone = null;
     try {
         // Get app custom configuration.
         $appDomain = Setting::get('app_domain');
         $appLocale = Setting::get('app_locale');
         $appTimezone = Setting::get('app_timezone');
         // Setup Cors.
         $allowedOrigins = $this->app->config->get('cors.defaults.allowedOrigins');
         $allowedOrigins[] = Setting::get('app_domain');
         // Add our allowed domains too.
         if ($allowedDomains = Setting::get('allowed_domains')) {
             $domains = explode(',', $allowedDomains);
             foreach ($domains as $domain) {
                 $allowedOrigins[] = $domain;
             }
         } else {
             $allowedOrigins[] = $this->app->config->get('app.url');
         }
         $this->app->config->set('cors.paths.api/v1/*.allowedOrigins', $allowedOrigins);
     } catch (Exception $e) {
         // Don't throw any errors, we may not be setup yet.
     }
     // Override default app values.
     $this->app->config->set('app.url', $appDomain ?: $this->app->config->get('app.url'));
     $this->app->config->set('app.locale', $appLocale ?: $this->app->config->get('app.locale'));
     $this->app->config->set('gitamin.timezone', $appTimezone ?: $this->app->config->get('gitamin.timezone'));
     // Set custom lang.
     $this->app->translator->setLocale($appLocale);
 }
Esempio n. 2
0
 /**
  * Run the app is installed middleware.
  *
  * We're verifying that Gitamin is correctly installed. If it is, then we're
  * redirecting the user to the dashboard so they can use Gitamin.
  *
  * @param \Illuminate\Routing\Route $route
  * @param \Closure                  $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Setting::get('app_name')) {
         return Redirect::to('dashboard');
     }
     return $next($request);
 }
Esempio n. 3
0
 /**
  * Is the subscriber functionality enabled and configured.
  *
  * @return bool
  */
 function subscribers_enabled()
 {
     $isEnabled = Setting::get('enable_subscribers', false);
     $mailAddress = Config::get('mail.from.address', false);
     $mailFrom = Config::get('mail.from.name', false);
     return $isEnabled && $mailAddress && $mailFrom;
 }
Esempio n. 4
0
 /**
  * Run the has setting middleware.
  *
  * We're verifying that the given setting exists in our database. If it
  * doesn't, then we're sending the user to the install page so that they can
  * complete the installation of Gitamin on their server.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $settingName = $this->getSettingName($request);
     try {
         if (!Setting::get($settingName)) {
             return Redirect::to('install');
         }
     } catch (Exception $e) {
         return Redirect::to('install');
     }
     return $next($request);
 }
Esempio n. 5
0
 /**
  * Index page view composer.
  *
  * @param \Illuminate\Contracts\View\View $view
  *
  * @return void
  */
 public function compose(View $view)
 {
     $view->withAppBanner(Setting::get('app_banner'));
     $view->withAppBannerStyleFullWidth(Setting::get('style_fullwidth_header'));
     $view->withAppBannerType(Setting::get('app_banner_type'));
     $view->withAppDomain(Setting::get('app_domain'));
     $view->withGitClientPath(Setting::get('git_client_path'));
     $view->withGitRepositoriesPath(Setting::get('git_repositories_path'));
     $view->withAppLocale(Setting::get('app_locale'));
     $view->withAppName(Setting::get('app_name'));
     $view->withAppStylesheet(Setting::get('app_stylesheet'));
     $view->withAppUrl(Config::get('app.url'));
 }
Esempio n. 6
0
 /**
  * Bind data to the view.
  *
  * @param \Illuminate\Contracts\View\View $view
  */
 public function compose(View $view)
 {
     // Theme colors.
     $view->withThemeBackgroundColor(Setting::get('style_background_color', '#F0F3F4'));
     $view->withThemeBackgroundFills(Setting::get('style_background_fills', '#FFFFFF'));
     $view->withThemeBannerBackgroundColor(Setting::get('style_banner_background_color', ''));
     $view->withThemeBannerPadding(Setting::get('style_banner_padding', '40px 0'));
     $view->withThemeTextColor(Setting::get('style_text_color', '#333333'));
     $view->withThemeReds(Setting::get('style_reds', '#ff6f6f'));
     $view->withThemeBlues(Setting::get('style_blues', '#3498db'));
     $view->withThemeGreens(Setting::get('style_greens', '#7ED321'));
     $view->withThemeYellows(Setting::get('style_yellows', '#F7CA18'));
     $view->withThemeOranges(Setting::get('style_oranges', '#FF8800'));
     $view->withThemeLinks(Setting::get('style_links', '#7ED321'));
 }
Esempio n. 7
0
 /**
  * Displays the explore page.
  *
  * @return \Illuminate\View\View
  */
 public function showIndex()
 {
     $today = Date::now();
     $startDate = Date::now();
     // Check if we have another starting date
     if (Binput::has('start_date')) {
         try {
             // If date provided is valid
             $oldDate = Date::createFromFormat('Y-m-d', Binput::get('start_date'));
             // If trying to get a future date fallback to today
             if ($today->gt($oldDate)) {
                 $startDate = $oldDate;
             }
         } catch (Exception $e) {
             // Fallback to today
         }
     }
     $daysToShow = Setting::get('app_issue_days', 0) - 1;
     if ($daysToShow < 0) {
         $daysToShow = 0;
         $issueDays = [];
     } else {
         $issueDays = range(0, $daysToShow);
     }
     $dateTimeZone = Setting::get('app_timezone');
     $issueVisiblity = Auth::check() ? 0 : 1;
     $allIssues = Issue::where('visible', '>=', $issueVisiblity)->whereBetween('created_at', [$startDate->copy()->subDays($daysToShow)->format('Y-m-d') . ' 00:00:00', $startDate->format('Y-m-d') . ' 23:59:59'])->orderBy('scheduled_at', 'desc')->orderBy('created_at', 'desc')->get()->groupBy(function (Issue $issue) use($dateTimeZone) {
         // If it's scheduled, get the scheduled at date.
         if ($issue->is_scheduled) {
             return (new Date($issue->scheduled_at))->setTimezone($dateTimeZone)->toDateString();
         }
         return (new Date($issue->created_at))->setTimezone($dateTimeZone)->toDateString();
     });
     // Add in days that have no issues
     foreach ($issueDays as $i) {
         $date = (new Date($startDate))->setTimezone($dateTimeZone)->subDays($i);
         if (!isset($allIssues[$date->toDateString()])) {
             $allIssues[$date->toDateString()] = [];
         }
     }
     // Sort the array so it takes into account the added days
     $allIssues = $allIssues->sortBy(function ($value, $key) {
         return strtotime($key);
     }, SORT_REGULAR, true)->all();
     return View::make('index')->withDaysToShow($daysToShow)->withAllIssues($allIssues)->withCanPageForward((bool) $today->gt($startDate))->withCanPageBackward(Issue::where('created_at', '<', $startDate->format('Y-m-d'))->count() > 0)->withPreviousDate($startDate->copy()->subDays($daysToShow)->toDateString())->withNextDate($startDate->copy()->addDays($daysToShow)->toDateString());
 }
Esempio n. 8
0
 /**
  * Displays the explore page.
  *
  * @return \Illuminate\View\View
  */
 public function indexAction()
 {
     $this->subMenu['explore']['active'] = true;
     $today = Date::now();
     $startDate = Date::now();
     // Check if we have another starting date
     if (Request::has('start_date')) {
         try {
             // If date provided is valid
             $oldDate = Date::createFromFormat('Y-m-d', Request::get('start_date'));
             // If trying to get a future date fallback to today
             if ($today->gt($oldDate)) {
                 $startDate = $oldDate;
             }
         } catch (Exception $e) {
             // Fallback to today
         }
     }
     $daysToShow = Setting::get('app_issue_days', 0) - 1;
     if ($daysToShow < 0) {
         $daysToShow = 0;
         $issueDays = [];
     } else {
         $issueDays = range(0, $daysToShow);
     }
     $dateTimeZone = Setting::get('app_timezone');
     $allIssues = Issue::whereBetween('created_at', [$startDate->copy()->subDays($daysToShow)->format('Y-m-d') . ' 00:00:00', $startDate->format('Y-m-d') . ' 23:59:59'])->orderBy('created_at', 'desc')->get()->groupBy(function (Issue $issue) use($dateTimeZone) {
         return (new Date($issue->created_at))->setTimezone($dateTimeZone)->toDateString();
     });
     // Add in days that have no issues
     foreach ($issueDays as $i) {
         $date = (new Date($startDate))->setTimezone($dateTimeZone)->subDays($i);
         if (!isset($allIssues[$date->toDateString()])) {
             $allIssues[$date->toDateString()] = [];
         }
     }
     // Sort the array so it takes into account the added days
     $allIssues = $allIssues->sortBy(function ($value, $key) {
         return strtotime($key);
     }, SORT_REGULAR, true)->all();
     return View::make('explore.index')->withPageTitle(trans('dashboard.explore'))->withProjects([])->withSubMenu($this->subMenu)->withDaysToShow($daysToShow)->withAllIssues($allIssues)->withCanPageForward((bool) $today->gt($startDate))->withCanPageBackward(Issue::where('created_at', '<', $startDate->format('Y-m-d'))->count() > 0)->withPreviousDate($startDate->copy()->subDays($daysToShow)->toDateString())->withNextDate($startDate->copy()->addDays($daysToShow)->toDateString());
 }
Esempio n. 9
0
 public function showTree($repo, $path)
 {
     $repository = $this->getRepositoryFromName([Setting::get('git_repositories_path')], $repo);
     if (!$path) {
         $path = $repository->getHead();
     }
     if (strpos($path, '/') !== false) {
         $branch = strstr($path, '/', true);
         $tree = str_replace($branch . '/', '', $path);
     } else {
         $branch = $path;
         $tree = '';
     }
     $parent = null;
     if (($slash = strrpos($tree, '/')) !== false) {
         $parent = substr($tree, 0, $slash);
     } elseif (!empty($tree)) {
         $parent = '';
     }
     $files = $repository->getTree($tree ? "{$branch}:\"{$tree}\"/" : $branch);
     $pageTitle = sprintf('"%s" - %s - %s', 'project title', trans('dashboard.projects.edit.title'), trans('dashboard.dashboard'));
     return View::make('dashboard.repositories.tree')->withPageTitle($pageTitle)->withRepository($repository)->withRepo($repo)->withCurrentBranch($branch)->withBranches($repository->getBranches())->withPath($tree ? $tree . '/' : $tree)->withParentPath($parent)->withFiles($files->output());
 }
Esempio n. 10
0
 /**
  * Show the subscribe by email page.
  *
  * @return \Illuminate\View\View
  */
 public function showSubscribe()
 {
     return View::make('subscribe')->withAboutApp(Markdown::convertToHtml(Setting::get('app_about')));
 }
Esempio n. 11
0
 /**
  * Creates a new dashboard controller.
  */
 public function __construct()
 {
     $this->startDate = new Date();
     $this->dateTimeZone = Setting::get('app_timezone');
 }
Esempio n. 12
0
 /**
  * Adds an item to the feed.
  *
  * @param \Gitamin\Models\Issue     $issue
  */
 private function feedAddItem($issue)
 {
     $this->feed->add($issue->name, Setting::get('app_name'), Str::canonicalize(route('issue', ['id' => $issue->id])), $this->isRss ? $issue->created_at->toRssString() : $issue->created_at->toAtomString(), $this->isRss ? $issue->message : Markdown::convertToHtml($issue->message));
 }