cnvs/canvas

此包已被废弃,不再维护。作者建议使用 austintoddj/canvas 包。

一个 Laravel 发布平台

资助包维护!
austintoddj

安装数: 39,467

依赖者: 2

建议者: 0

安全: 0

星标: 2,380

关注者: 80

分支: 400

开放问题: 29


README

HEADER.png

Build Status 68747470733a2f2f706f7365722e707567782e6f72672f636e76732f63616e7661732f646f776e6c6f616473 68747470733a2f2f706f7365722e707567782e6f72672f636e76732f63616e7661732f762f737461626c65 68747470733a2f2f706f7365722e707567782e6f72672f636e76732f63616e7661732f6c6963656e7365

简介

Canvas 是一个完全开源的包,可以扩展您的现有 Laravel 应用程序,并让您在几分钟内就能搭建一个博客。除了无干扰的写作体验外,您还可以查看您的内容的月度趋势,深入了解读者流量等等!

要求

  • PHP >= 7.2
  • Laravel >= 6.0
  • 由 Laravel 支持的四种数据库之一

安装

注意: Canvas 需要在安装之前设置用户身份验证。请参阅官方指南开始。

您可以使用 composer 将 Canvas 安装到您的 Laravel 项目中

composer require austintoddj/canvas

使用 canvas:install Artisan 命令发布资产和主要配置文件

php artisan canvas:install

使用 storage:link Artisan 命令创建符号链接,以确保文件上传可以从网络公开访问

php artisan storage:link

配置

在发布 Canvas 的资产后,主要配置文件将位于 config/canvas.php。此文件允许您自定义应用程序使用此包的各种方面。

Canvas 默认在 /canvas 展示其 UI。这可以通过更新 path 选项来更改

/*
|--------------------------------------------------------------------------
| Base Route
|--------------------------------------------------------------------------
|
| This is the URI path where Canvas will be accessible from. You are free
| to change this path to anything you like. Note that the URI will not
| affect the paths of its internal API that aren't exposed to users.
|
*/

'path' => env('CANVAS_PATH_NAME', 'canvas'),

如果您的应用程序有一个自定义的用户模型,请在 user 选项中定义完全限定的路径

/*
|--------------------------------------------------------------------------
| User Model
|--------------------------------------------------------------------------
|
| Next, you may define a specific user model that your application will
| use for authentication. This will define the relationships between
| a user and their posts, tags, and topics that they author.
|
*/

'user' => Illuminate\Foundation\Auth\User::class,

有时,您可能希望将角色或权限基于的访问应用于 Canvas。您可以在其中创建和附加任何额外的中间件

/*
|--------------------------------------------------------------------------
| Route Middleware
|--------------------------------------------------------------------------
|
| These middleware will be attached to every route in Canvas, giving you
| the chance to add your own middleware to this list or change any of
| the existing middleware. Or, you can simply stick with the list.
|
*/

'middleware' => [
    'web',
    'auth',
],

Canvas 使用存储磁盘进行媒体上传。您可以在其中配置不同的文件系统选项

/*
|--------------------------------------------------------------------------
| Storage
|--------------------------------------------------------------------------
|
| This is the storage disk Canvas will use to put file uploads. You may
| use any of the disks defined in the config/filesystems.php file and
| you may also change the maximum upload size from its 3MB default.
|
*/

'storage_disk' => env('CANVAS_STORAGE_DISK', 'local'),

'storage_path' => env('CANVAS_STORAGE_PATH', 'public/canvas'),

'upload_filesize' => env('CANVAS_UPLOAD_FILESIZE', 3145728),

可用选项

注意:以下功能完全是可选的,您不需要使用它们。

前端

虽然 Canvas 没有指定您的前端特定设计,但它确实提供了一个使用 BootstrapVue 的基本起点,这将对许多应用程序很有帮助。脚手架位于 austintoddj/studio Composer 包中,可以使用 Composer 安装

composer require austintoddj/studio

安装 austintoddj/studio Composer 包后,您可以使用 studio:install Artisan 命令安装前端脚手架

php artisan studio:install

安装 austintoddj/studio Composer 包并生成前端脚手架后,您的 package.json 文件将包括安装和编译所需的必要依赖项

# Using NPM
npm install
npm run dev

# Using Yarn
yarn
yarn dev

Unsplash

想要访问整个Unsplash库?https://unsplash.com/oauth/applications上设置新的应用程序,获取您的访问密钥,并更新config/canvas.php

/*
|--------------------------------------------------------------------------
| Unsplash Integration
|--------------------------------------------------------------------------
|
| Visit https://unsplash.com/oauth/applications to create a new Unsplash
| app. Use the confidential Access Key given to you to integrate with
| the API. Note that demo apps are limited to 50 requests per hour.
|
*/

'unsplash' => [
    'access_key' => env('CANVAS_UNSPLASH_ACCESS_KEY'),
]

每周摘要

想要每周摘要吗? Canvas 允许用户接收其创作的内容的每周总结。一旦您的应用程序配置为发送邮件,请更新config/canvas.php

/*
|--------------------------------------------------------------------------
| E-Mail Notifications
|--------------------------------------------------------------------------
|
| This option controls e-mail notifications that will be sent via the
| default application mail driver. A default option is provided to
| support the notification system as an opt-in feature.
|
|
*/

'mail' => [
    'enabled' => env('CANVAS_MAIL_ENABLED', false),
]

由于每周摘要是在Laravel的调度器上运行的,您需要在服务器上添加以下cron条目

* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

更新

Canvas大致遵循语义化版本控制,并按MAJOR.MINOR.PATCH数字递增版本

  • 主版本或次版本可能包含破坏性变更,因此请遵循升级指南以获取逐步说明
  • 补丁版本将保持向后兼容,因此您可以安全地按照以下步骤更新包

您可以使用composer更新您的Canvas安装

composer update

运行任何新的迁移使用migrate Artisan命令

php artisan migrate

使用canvas:publish Artisan命令重新发布资源

php artisan canvas:publish

贡献

感谢您考虑为Canvas做出贡献!您可以使用贡献指南来帮助您为开发设置包。

测试

使用以下命令运行测试

composer test

翻译

Canvas团队的目标之一是确保应用程序的正确本地化。如果您发现任何翻译错误或问题并希望做出贡献,请创建一个pull request。如果您在resources/lang目录中没有看到您的母语,请随时添加它。

许可

Canvas是开源软件,许可协议为MIT许可证

鸣谢