/** * Index page view composer. * * @param \Illuminate\Contracts\View\View $view * * @return void */ public function compose(View $view) { $view->withAboutApp(Markdown::convertToHtml($this->config->get('setting.app_about'))); $view->withAppAnalytics($this->config->get('setting.app_analytics')); $view->withAppAnalyticsGoSquared($this->config->get('setting.app_analytics_gs')); $view->withAppAnalyticsPiwikUrl($this->config->get('setting.app_analytics_piwik_url')); $view->withAppAnalyticsPiwikSiteId($this->config->get('setting.app_analytics_piwik_site_id')); $view->withAppBanner($this->config->get('setting.app_banner')); $view->withAppBannerStyleFullWidth($this->config->get('setting.style_fullwidth_header')); $view->withAppBannerType($this->config->get('setting.app_banner_type')); $view->withAppDomain($this->config->get('setting.app_domain')); $view->withAppGraphs($this->config->get('setting.display_graphs')); $view->withAppLocale($this->config->get('setting.app_locale')); $view->withAppStylesheet($this->config->get('setting.stylesheet')); $view->withAppUrl($this->config->get('app.url')); $view->withAppHeader($this->config->get('setting.header')); $view->withAppFooter($this->config->get('setting.footer')); $view->withAppName($this->config->get('setting.app_name')); $view->withShowSupport($this->config->get('setting.show_support')); $view->withAutomaticLocalization($this->config->get('setting.automatic_localization')); $view->withEnableExternalDependencies($this->config->get('setting.enable_external_dependencies')); $view->withShowTimezone($this->config->get('setting.show_timezone')); $view->withTimezone($this->dates->getTimezone()); $view->withSiteTitle($this->config->get('setting.app_name')); $view->withFontSubset($this->config->get('langs.' . $this->config->get('app.locale') . '.subset', 'latin')); }
/** * Index page view composer. * * @param \Illuminate\Contracts\View\View $view * * @return void */ public function compose(View $view) { $view->withAboutApp(Markdown::convertToHtml(Config::get('setting.app_about'))); $view->withAppAnalytics(Config::get('setting.app_analytics')); $view->withAppAnalyticsGoSquared(Config::get('setting.app_analytics_go_squared')); $view->withAppAnalyticsPiwikUrl(Config::get('setting.app_analytics_piwik_url')); $view->withAppAnalyticsPiwikSiteId(Config::get('setting.app_analytics_piwik_site_id')); $view->withAppBanner(Config::get('setting.app_banner')); $view->withAppBannerStyleFullWidth(Config::get('setting.style_fullwidth_header')); $view->withAppBannerType(Config::get('setting.app_banner_type')); $view->withAppDomain(Config::get('setting.app_domain')); $view->withAppGraphs(Config::get('setting.display_graphs')); $view->withAppLocale(Config::get('setting.app_locale')); $view->withAppStylesheet(Config::get('setting.stylesheet')); $view->withAppUrl(Config::get('app.url')); $view->withAppHeader(Config::get('setting.header')); $view->withAppFooter(Config::get('setting.footer')); $view->withAppName($name = Config::get('setting.app_name')); $view->withShowSupport($support = Config::get('setting.show_support')); if ($support) { $view->withSiteTitle(Config::get('setting.app_name') . ' | Cachet'); } else { $view->withSiteTitle(Config::get('setting.app_name')); } }
/** * Index page view composer. * * @param \Illuminate\Contracts\View\View $view * * @return void */ public function compose(View $view) { $isEnabled = (bool) Setting::get('enable_subscribers', false); $mailAddress = env('MAIL_ADDRESS', false); $mailFrom = env('MAIL_NAME', false); $view->withSubscribersEnabled($isEnabled && $mailAddress && $mailFrom); $view->withAboutApp(Markdown::convertToHtml(Setting::get('app_about'))); }
/** * Bind data to the view. * * @param View $view * * @return void */ public function compose(View $view) { $locale = app()->getLocale(); $filename = Request::route()->getName() . '.md'; $filepath = 'userhelp' . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $filename; $help = Storage::exists($filepath) ? Markdown::convertToHtml(Storage::get($filepath)) : ''; $view->with('help', $help); }
public function formattedTarget() { if ($this->wrappedObject->target instanceof Comment) { return Markdown::convertToHtml($this->wrappedObject->target->message); } elseif ($this->wrappedObject->target instanceof Issue) { return Markdown::convertToHtml($this->wrappedObject->target->description); } elseif ($this->wrappedObject->target instanceof Project) { return Markdown::convertToHtml($this->wrappedObject->target->description); } }
/** * 分享页面 * @param $slug * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function share($slug) { $data = Cache::remember('com.tanteng.share.page.' . $slug, self::CACHE_TIME, function () use($slug) { $content = $this->content->getContent($slug); $content->content = Markdown::convertToHtml($content->content); return ['content' => $content]; }); $content = $data['content']; return view('content.page', compact('content')); }
/** * Display the specified resource. * * @param string $slug * @return \Illuminate\Http\Response */ public function show($slug) { $page = Page::where('slug', '=', $slug)->first(); if ($page == null) { abort(404, "Page not found."); } if ($page->is_member_only && !(Auth::check() && Auth::user()->member != null)) { abort(403, "You need to be a member of S.A. Proto to see this page."); } return view('pages.show', ['page' => $page, 'parsedContent' => Markdown::convertToHtml($page->content)]); }
/** * Handle the signup with invite. * * @param string|null $code * * @return \Illuminate\View\View */ public function getSignup($code = null) { if (is_null($code)) { throw new NotFoundHttpException(); } $invite = Invite::where('code', '=', $code)->first(); if (!$invite || $invite->claimed()) { throw new BadRequestHttpException(); } return View::make('signup')->withPageTitle(Setting::get('app_name'))->withAboutApp(Markdown::convertToHtml(Setting::get('app_about')))->withCode($invite->code)->withUsername(Binput::old('username'))->withEmail(Binput::old('emai', $invite->email)); }
public function markdownRender($text, $safe = true) { // $converter = new CommonMarkConverter(); // if ($safe) { // return htmlentities($converter->convertToHtml($text)); // } else { // return $converter->convertToHtml($text); // } \Config::set(['markdown' => ['safe' => $safe]]); return Markdown::convertToHtml($text); }
/** * Returns the rendered Blade templates. * * @return \Illuminate\View\View */ public function showIndex() { $components = Component::orderBy('order')->orderBy('created_at')->get(); $allIncidents = []; $incidentDays = Setting::get('app_incident_days') ?: 7; foreach (range(0, $incidentDays) as $i) { $date = Carbon::now()->subDays($i); $incidents = Incident::whereBetween('created_at', [$date->format('Y-m-d') . ' 00:00:00', $date->format('Y-m-d') . ' 23:59:59'])->orderBy('created_at', 'desc')->get(); $allIncidents[] = ['date' => $date->format('jS F Y'), 'incidents' => $incidents]; } return View::make('index', ['components' => $components, 'allIncidents' => $allIncidents, 'pageTitle' => Setting::get('app_name'), 'aboutApp' => Markdown::render(Setting::get('app_about'))]); }
/** * Returns the rendered Blade templates. * * @return \Illuminate\View\View */ public function showIndex() { $today = Date::now(); $startDate = Date::now(); segment_page('Status Page'); // 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')); segment_track('Status Page', ['start_date' => $oldDate->format('Y-m-d')]); // If trying to get a future date fallback to today if ($today->gt($oldDate)) { $startDate = $oldDate; } } catch (Exception $e) { // Fallback to today } } $metrics = null; if ($displayMetrics = Setting::get('display_graphs')) { $metrics = Metric::where('display_chart', 1)->get(); } $daysToShow = Setting::get('app_incident_days') ?: 7; $incidentDays = range(0, $daysToShow - 1); $dateTimeZone = Setting::get('app_timezone'); $incidentVisiblity = Auth::check() ? 0 : 1; $allIncidents = Incident::notScheduled()->where('visible', '>=', $incidentVisiblity)->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 (Incident $incident) use($dateTimeZone) { return (new Date($incident->created_at))->setTimezone($dateTimeZone)->toDateString(); }); // Add in days that have no incidents foreach ($incidentDays as $i) { $date = (new Date($startDate))->setTimezone($dateTimeZone)->subDays($i); if (!isset($allIncidents[$date->toDateString()])) { $allIncidents[$date->toDateString()] = []; } } // Sort the array so it takes into account the added days $allIncidents = $allIncidents->sortBy(function ($value, $key) { return strtotime($key); }, SORT_REGULAR, true)->all(); // Scheduled maintenance code. $scheduledMaintenance = Incident::scheduled()->orderBy('scheduled_at')->get(); // Component & Component Group lists. $usedComponentGroups = Component::where('group_id', '>', 0)->groupBy('group_id')->lists('group_id'); $componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get(); $ungroupedComponents = Component::where('group_id', 0)->orderBy('order')->orderBy('created_at')->get(); $canPageBackward = Incident::notScheduled()->where('created_at', '<', $startDate->format('Y-m-d'))->count() != 0; return View::make('index', ['componentGroups' => $componentGroups, 'ungroupedComponents' => $ungroupedComponents, 'displayMetrics' => $displayMetrics, 'metrics' => $metrics, 'allIncidents' => $allIncidents, 'scheduledMaintenance' => $scheduledMaintenance, 'aboutApp' => Markdown::convertToHtml(Setting::get('app_about')), 'canPageForward' => (bool) $today->gt($startDate), 'canPageBackward' => $canPageBackward, 'previousDate' => $startDate->copy()->subDays($daysToShow)->toDateString(), 'nextDate' => $startDate->copy()->addDays($daysToShow)->toDateString(), 'pageTitle' => Setting::get('app_name') . ' Status']); }
public function detail($slug = false) { $navFlag = $this->navFlag; $detail = English::where('slug', $slug)->firstOrFail(); $prevSlug = $this->getSlug($detail['id'], 'prev'); $nextSlug = $this->getSlug($detail['id'], 'next'); $latest = $this->latest(10); $phrase = $detail['phrase']; $seoTitle = $detail['seo_title'] . '_英语_tanteng.me'; $description = $detail['description']; $content = Markdown::convertToHtml($detail['content']); $compact = compact('navFlag', 'slug', 'phrase', 'seoTitle', 'description', 'content', 'canonical', 'latest', 'prevSlug', 'nextSlug'); return view('english.how-to-say', $compact); }
/** * Index page view composer. * * @param \Illuminate\Contracts\View\View $view * * @return void */ public function compose(View $view) { $view->withAboutApp(Markdown::convertToHtml(Setting::get('app_about'))); $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')); }
/** * Displays the status 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_incident_days', 0) - 1; if ($daysToShow < 0) { $daysToShow = 0; $incidentDays = []; } else { $incidentDays = range(0, $daysToShow); } $dateTimeZone = Setting::get('app_timezone'); $incidentVisiblity = Auth::check() ? 0 : 1; $allIncidents = Incident::notScheduled()->where('visible', '>=', $incidentVisiblity)->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 (Incident $incident) use($dateTimeZone) { // If it's scheduled, get the scheduled at date. if ($incident->is_scheduled) { return (new Date($incident->scheduled_at))->setTimezone($dateTimeZone)->toDateString(); } return (new Date($incident->created_at))->setTimezone($dateTimeZone)->toDateString(); }); // Add in days that have no incidents foreach ($incidentDays as $i) { $date = (new Date($startDate))->setTimezone($dateTimeZone)->subDays($i); if (!isset($allIncidents[$date->toDateString()])) { $allIncidents[$date->toDateString()] = []; } } // Sort the array so it takes into account the added days $allIncidents = $allIncidents->sortBy(function ($value, $key) { return strtotime($key); }, SORT_REGULAR, true)->all(); return View::make('index')->withDaysToShow($daysToShow)->withAllIncidents($allIncidents)->withAboutApp(Markdown::convertToHtml(Setting::get('app_about')))->withCanPageForward((bool) $today->gt($startDate))->withCanPageBackward(Incident::notScheduled()->where('created_at', '<', $startDate->format('Y-m-d'))->count() > 0)->withPreviousDate($startDate->copy()->subDays($daysToShow)->toDateString())->withNextDate($startDate->copy()->addDays($daysToShow)->toDateString()); }
public function createNewPost(Request $request) { $data = ["title" => $request->title, "link" => $request->link, "body" => $request->body, "body_html" => Markdown::convertToHtml($request->body), "user_id" => Auth::user()->id, "subreddit_id" => $request->subreddit_id]; $slugify = new Slugify(); $data['slug'] = $slugify->slugify($request->get('title'), '_'); if (strlen($data['slug']) > 46) { $data['slug'] = substr($data['slug'], 0, 46); } //6 character string for a permalink $permalink = $this->generateRandomString(); //Make sure the permalink is unique while (Post::wherePermalink($permalink)->exists()) { $permalink = $this->generateRandomString(); } $data['permalink'] = $permalink; Post::create($data); return redirect('/r/' . Subreddit::whereId($request->subreddit_id)->firstOrFail()->name . '/comments/' . $data['permalink'] . '/' . $data['slug']); }
/** * Index page view composer. * * @param \Illuminate\Contracts\View\View $view * * @return void */ public function compose(View $view) { $view->withAboutApp(Markdown::convertToHtml(Setting::get('app_about'))); $view->withAppAnalytics(Setting::get('app_analytics')); $view->withAppAnalyticsGoSquared(Setting::get('app_analytics_gs')); $view->withAppAnalyticsPiwikUrl(Setting::get('app_analytics_piwik_url')); $view->withAppAnalyticsPiwikSiteId(Setting::get('app_analytics_piwik_siteid')); $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->withAppGraphs(Setting::get('display_graphs')); $view->withAppLocale(Setting::get('app_locale')); $view->withAppName(Setting::get('app_name')); $view->withAppStylesheet(Setting::get('app_stylesheet')); $view->withAppUrl(Config::get('app.url')); $view->withShowSupport(Setting::get('show_support')); }
/** * Parses raw md file contents. Extracts headers * and creates html from contents * * @param $contents * @return $this */ protected function markdownParse($contents) { $frontmatter_regex = "/^---\n(.+?)\n---\n{0,}(.*)\$/uis"; /* Make line endings compatible with Unix format */ $contents = preg_replace("/(\r\n|\r)/", "\n", $contents); /* Parse header */ preg_match($frontmatter_regex, ltrim($contents), $frontMatterRaw); if (!empty($frontMatterRaw)) { $frontmatter = preg_replace("/\n\t/", "\n ", $frontMatterRaw[1]); $this->setParams((array) Yaml::parse($frontmatter)); $this->setContent(Markdown::convertToHtml($frontMatterRaw[2])); } else { $this->setParams([]); $this->setContent(Markdown::convertToHtml($contents)); } return $this; }
/** * Show the subscribe by email page. * * @return \Illuminate\View\View */ public function showSubscribe() { return View::make('subscribe')->withAboutApp(Markdown::convertToHtml(Setting::get('app_about'))); }
/** * Get the article's html * * @return string */ public function getHtmlAttribute() { return Markdown::convertToHtml($this->content); }
/** * Renders the message from Markdown into HTML. * * @return string */ public function formattedMessage() { return Markdown::convertToHtml($this->wrappedObject->message); }
/** * Get the content. * * @return string */ public function content() { return Markdown::convertToHtml($this->getWrappedObject()->body); }
/** * 游记详情 * @param $slug string * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function travelDetail($slug) { $data = Cache::remember("travel.detail.{$slug}", self::CACHE_TIME, function () use($slug) { $destinationList = $this->destination->getList(12); $detail = $this->travel->where('slug', $slug)->firstOrFail(); $detail->content = Markdown::convertToHtml($detail->content); $destinationInfo = $detail->destination; $travelList = $this->travel->where('destination_id', $destinationInfo['id'])->where('id', '<>', $detail->id)->latest('begin_date')->take(5)->get(); //10篇同目的地的最新游记 $travelList = !$travelList->isEmpty() ? $travelList : ''; return ['destinationList' => $destinationList, 'destinationInfo' => $destinationInfo, 'detail' => $detail, 'travelList' => $travelList]; }); $destinationList = $data['destinationList']; $destinationInfo = $data['destinationInfo']; $detail = $data['detail']; $travelList = $data['travelList']; $seoSuffix = "_{$destinationInfo->destination}游记_tanteng.me"; return view('travel.detail', compact('detail', 'destinationList', 'destinationInfo', 'travelList', 'seoSuffix')); }
public function bodyToHtml() { return Markdown::convertToHtml($this->body); }
/** * Adds an item to the feed. * * @param \CachetHQ\Cachet\Models\Incident $incident * @param bool $isRss */ private function feedAddItem(Incident $incident, $isRss) { $this->feed->add($incident->name, Setting::get('app_name'), Str::canonicalize(route('incident', ['id' => $incident->id])), $isRss ? $incident->created_at->toRssString() : $incident->created_at->toAtomString(), $isRss ? $incident->message : Markdown::convertToHtml($incident->message)); }
/** * Adds an item to the feed. * * @param \Roumen\Feed\Facades\Feed $feed * @param \CachetHQ\Cachet\Models\Incident $incident * * @return void */ private function feedAddItem(&$feed, $incident) { $feed->add($incident->name, Setting::get('app_name'), Str::canonicalize(Setting::get('app_domain')) . '#' . $incident->id, $incident->created_at->toAtomString(), Markdown::convertToHtml($incident->message)); }
public function store() { Markdown::convertToHtml('foo'); dd(Request::all()); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(ArticleRequest $request, $id) { $article = Article::findOrFail($id); if (Permissions::check('article.edit') or Permissions::check('article.editown') and $article->user_id == Auth::user()->id and $article->published == 0) { $article->title = $request->input('title'); $article->slug = $request->input('slug'); $article->temporary_jumbo_image = $request->input('temporary_jumbo_image'); $article->store = $request->input('store'); $article->store_app_id = $request->input('store_app_id'); $article->subreddit = $request->input('subreddit'); $article->score = $request->input('score'); $article->titletext = $request->input('titletext'); $article->score_text_md = $request->input('score_text_md'); $article->gameplay_md = $request->input('gameplay_md'); $article->story_md = $request->input('story_md'); $article->graphics_md = $request->input('graphics_md'); $article->conclusion_md = $request->input('conclusion_md'); $article->screenshots_md = $request->input('screenshots_md'); $article->intro_md = $request->input('intro_md'); //actual fields $article->score_text = Markdown::convertToHtml($request->input('score_text_md')); $article->gameplay = Markdown::convertToHtml($request->input('gameplay_md')); $article->story = Markdown::convertToHtml($request->input('story_md')); $article->graphics = Markdown::convertToHtml($request->input('graphics_md')); $article->conclusion = Markdown::convertToHtml($request->input('conclusion_md')); $article->screenshots = Markdown::convertToHtml($request->input('screenshots_md')); $article->intro = Markdown::convertToHtml($request->input('intro_md')); $article->save(); $screenshots = array(); if ($request->input('screenshot') != null) { foreach ($request->input('screenshot') as $key => $screenshot) { $screenshots[$key]['image_id'] = $screenshot; $screenshots[$key]['article_id'] = $article->id; $screenshots[$key]['ip_address'] = inet_pton($request->getClientIp()); } } ArticleScreenshot::insert($screenshots); return redirect()->action('ArticleController@show', [$article->slug]); } abort(403); }
/** * Returns matches in the note table for the given term * * @param string $term The search term * * @return mixed Response or Collection depending on validation */ public function getNoteSearch($term) { // TODO: implement a "good" fulltext search. $notes = Note::where('content', 'LIKE', '%' . $term . '%')->orWhere('title', 'LIKE', '%' . $term . '%')->limit(15)->get(['content', 'title', 'id']); // Do we have a search result? if (!$notes) { return response()->json(['message', 'No search results'], 404); } else { foreach ($notes as $note) { $note->content = strip_tags(Markdown::convertToHtml(str_limit($note->content, 120, '…'))); } return $notes; } }
/** * Show the subscribe by email page. * * @return \Illuminate\View\View */ public function showSubscribe() { return View::make('subscribe', ['page_title' => Setting::get('app_name'), 'aboutApp' => Markdown::convertToHtml(Setting::get('app_about'))]); }
public function getParseContent() { return Markdown::convertToHtml($this->content); }