/** * Generate social network link. * * @param string $network * @param Content $page * @return string */ public static function generate($network, Content $page) { // Get text $text = self::truncate($page->description, 137); // Replace template with values return str_replace(['{url}', '{title}', '{text}', '{image}'], [urlencode($page->url), urlencode($page->title), urlencode($text), urlencode($page->get('image'))], self::$templates[$network]); }
public function __construct(SplFileInfo $file, Builder $builder) { parent::__construct($file, $builder); // Get Category $this->category = $this->getCategory(); // Set tags $this->tags = $this->getHumanTags(); $this->tag_class = $this->getTagClassNames(); // Set date if ($this->has('date')) { $this->date = new Carbon($this->get('date'), date_default_timezone_get()); } else { $this->date = Carbon::createFromTimestamp($file->getMTime()); } // Set excerpt if ($this->has('excerpt')) { $this->excerpt = $this->get('excerpt'); } else { $this->excerpt = $this->getExcerpt($this->content); } // Set author $this->author = $this->get('author', $this->author); // Set Images if ($this->has('image')) { $fileinfo = pathinfo($this->get('image')); $template = $this->builder->getUrl("{$fileinfo['dirname']}/{$fileinfo['filename']}-%SIZE%.{$fileinfo['extension']}"); $this->image = ['full' => $this->builder->getUrl($this->get('image')), 'medium' => str_replace('%SIZE%', 'medium', $template), 'thumb' => str_replace('%SIZE%', 'thumb', $template)]; } // Remove content HTML comments $this->content = preg_replace('/<!--(.*)-->/Uis', '', $this->content); }
public function __construct(SplFileInfo $file, Builder $builder) { parent::__construct($file, $builder); // Get Category $this->category = $this->getCategory(); // Set chapter $this->chapter = $this->get('chapter'); // Set date if ($this->has('date')) { $this->date = strtotime($this->get('date')); } else { $this->date = $file->getMTime(); } }
public function __construct(SplFileInfo $file, Builder $builder) { parent::__construct($file, $builder); // Get date file was last modified $this->date = $file->getMTime(); }
/** * Renders content * * @param Content $content * @return mixed */ private function renderContent(Content $content) { $tpl = $content->has('template') ? " <comment>({$content->template})</comment>" : ""; $this->app->writeln("Rendering: <info>{$content->target}</info>{$tpl}"); // Only template files are run through Twig (template can be "none") if ($content->has('template')) { if ($content->paginate) { return $this->paginate($content); } else { $html = $this->twig->render($content->id, ['page' => $content, 'posts' => $this->getPosts($content), 'parent' => $this->getParent($content->parentId)]); } } else { $template = $this->twig->createTemplate($content->content); $html = $template->render([]); } // Save Content $this->savePage($content->target, $html); }