定制 saywebsolutions/lets-blog 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

saywebsolutions/lets-blog

Composer 安装命令:

composer require saywebsolutions/lets-blog

包简介

Blogging package for Laravel 5

README 文档

README

A simple command line, markdown based blog add-on package for Laravel including support for tags and series of related posts.

Install and Quick Start

Include the package via composer:

composer require "saywebsolutions/letsblog"

Add the service provider to config/app.php:

'providers' => [
    ...
	SayWebSolutions\LetsBlog\Providers\LetsBlogServiceProvider::class,
	...
]

Publish the Config File

The best way to get a sense of the config options is to publish the config and take a look at the file:

php artisan vendor:publish --provider="SayWebSolutions\LetsBlog\Providers\LetsBlogServiceProvider" --tag=config

Find the config file in config/letsblog.php.

Migrate the Let's Blog Tables:

php artisan migrate --path=/vendor/saywebsolutions/lets-blog/database/migrations

Your main blade layout must be named app.blade.php for the default theme to work out of the box; if not, there is a config key theme_extends that will allow you to define the blade layout to extend.

Navigate to /blog and see the default blog page.

Adding & Updating Posts

Write posts using the markdown format, and by default posts should go in the ./blog/posts directory.

After adding/editing a post run the letsblog:build command to add the new post(s) and/or apply your edits:

php artisan letsblog:build

The main key used for checking existing posts will be the identifier field which by default uses the filename.

Post Format

The post format should look like the following:

---
title: LetsBlog Package Released
slug: letsblog-package-released-laravel
meta: LetsBlog package released for Laravel.
keywords: letsblog, package, laravel, release
published_at: 2018-03-17
tags: LetsBlog, Laravel
---

## Post Title

Post contents...

You can set any fields in the top section (front matter) of the file. The available parsers recieve the data defined in the front matter for each field, and can manipulate that data prior to being saved to the posts table.

Current parsers are:

  • Title
  • Meta (description)
  • Body
  • PublishedAt
  • Slug (if not defined will fallback to filename)
  • Tags
  • Series (optional name of the series to which to post belongs)

Migrations

The migration can be run directly from the packages migrations folder:

php artisan migrate --path=/vendor/saywebsolutions/lets-blog/database/migrations
php artisan migrate:rollback

If the migrations need to be published to the parent app, use the vendor:publish command:

php artisan vendor:publish --provider="SayWebSolutions\LetsBlog\Providers\LetsBlogServiceProvider" --tag=migrations

Themes

To set a theme set the 'letsblog.theme' property in the config. To simplify things ALL views should simply use letsblog::theme.master as the main view. Then a view is set as part of the data sent to the view.

return view('letsblog::themes.master', [
    'view' => lb_view('post.show'),
]);

The lb_view is a shortcut helper to use to avoid having to set the full path with the theme each time. This allows easy swapping of themes by only having to change the config parameter.

So far the currently supported themes are:

  • default
  • extension

Default Theme

The default theme is currently untested, and may or may not be working.

Extension Theme

The extension theme is useful if you have an existing blade layout you'd like to embed the blog in. Right now the extension theme expects Bootstrap 3 to be available in the parent application.

Make sure to have a yield directive for javascript in your parent layout, ex.):

@yield ('javascript')

Overriding Layouts

In many cases you will want to add some customization to the layout to include some analytics tracking or ads for instance. To allow this the themes include many section blocks that can replace or modify existing layout.

To start, create an overrides file in the views directory:

/resources/views/vendor/lets-blog/themes/overrides.blade.php

From there the following section blocks can be used which hopefully are self explanatory.

  • meta.opensearch
  • meta.title
  • meta.keywords
  • meta.description
  • meta.og
  • head.files
  • head.styles
  • sidebar.series
  • sidebar.popular
  • component.search
  • component.related
  • footer-nav.left
  • footer-nav.right
  • post.list
  • post.head
  • post.series
  • post.body
  • post.related
  • page.head
  • page.body
  • layout.view
  • layout.end

Customize

For customization the LetsBlog facade may be used.

'aliases' => [
  'Blog'      => SayWebSolutions\LetsBlog\Facades\LetsBlogFacade::class,
  ...
]

The facade provides access to the following shortcut functions:

  • published() - Paginated list of posts.
  • search($q) - Paginated list of posts by search.
  • all() - All posts.
  • last() - Last post (by published_at date).
  • post($slug) - Post or page by slug.
  • count() - Post count.
  • top($amount) - Top posts (default 10).
  • tags() - All tags.
  • publishedWhereTag($tag) - Paginated list of posts by tag.

Assets

Publish all files from the package:

php artisan vendor:publish --provider="SayWebSolutions\LetsBlog\Providers\LetsBlogServiceProvider"

Or publish separately:

php artisan vendor:publish --provider="SayWebSolutions\LetsBlog\Providers\LetsBlogServiceProvider" --tag=migrations
php artisan vendor:publish --provider="SayWebSolutions\LetsBlog\Providers\LetsBlogServiceProvider" --tag=views
php artisan vendor:publish --provider="SayWebSolutions\LetsBlog\Providers\LetsBlogServiceProvider" --tag=config
php artisan vendor:publish --provider="SayWebSolutions\LetsBlog\Providers\LetsBlogServiceProvider" --tag=assets

Headers & Footers

Each theme should also support a header and footer section (and perhaps more standard sections to follow). The idea is that a list of views can be provided and they will be included in that order.

This allows the inclusion of any ads or analytics tracking codes.

Adding Parser

To add a parser, create a class with the name of the key being parsed. So title would look for SayWebSolutions\LetsBlog\Parser\Field\Title. This way additional fields may be added or existing ones overridden.

To Do

Some things that still need to be done.

  • Admin section (with WYSIWYG MD editor)
  • Additional themes
  • Comments

saywebsolutions/lets-blog 适用场景与选型建议

saywebsolutions/lets-blog 是一款 基于 HTML 开发的 Composer 扩展包,目前已累计 45 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 04 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「blog」 「cms」 「blogging」 「laravel」 「publishing」 「laravel 5」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 saywebsolutions/lets-blog 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 saywebsolutions/lets-blog 我们能提供哪些服务?
定制开发 / 二次开发

基于 saywebsolutions/lets-blog 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 45
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 12
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: HTML

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-28