Giter Club home page Giter Club logo

canvas's Introduction

Homepage for trycanvas.app

Build Status Total Downloads Latest Stable Version License

Introduction

Canvas is a fully open source package to extend your existing Laravel application and get you up-and-running with a blog in just a few minutes. In addition to a distraction-free writing experience, you can view monthly trends on your content, get insights into reader traffic and more!

System Requirements

Installation

You may use composer to install Canvas into your Laravel project:

composer require austintoddj/canvas

Publish the assets and primary configuration file using the canvas:install Artisan command:

php artisan canvas:install

Create a symbolic link to ensure file uploads are publicly accessible from the web using the storage:link Artisan command:

php artisan storage:link

Configuration

After publishing Canvas's assets, a primary configuration file will be located at config/canvas.php. This file allows you to customize various aspects of how your application uses the package.

Canvas exposes its UI at /canvas by default. This can be changed by updating either the path or domain option:

/*
|--------------------------------------------------------------------------
| Base Domain
|--------------------------------------------------------------------------
|
| This is the subdomain where Canvas will be accessible from. If the
| domain is set to null, Canvas will reside under the defined base
| path below. Otherwise, this will be used as the subdomain.
|
*/

'domain' => env('CANVAS_DOMAIN', null),

/*
|--------------------------------------------------------------------------
| Base Path
|--------------------------------------------------------------------------
|
| This is the URI where Canvas will be accessible from. If the path
| is set to null, Canvas will reside under the same path name as
| the application. Otherwise, this is used as the base path.
|
*/

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

Sometimes, you may want to apply custom roles or permissions when accessing Canvas. You can create and attach any additional middleware here:

/*
|--------------------------------------------------------------------------
| 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',
],

Canvas uses the storage disk for media uploads. You may configure the different filesystem options here:

/*
|--------------------------------------------------------------------------
| 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),

Roles & Permissions

Canvas comes with 3 pre-defined roles out-of-the-box:

  • Contributor (A user who can write and manage their own posts but cannot publish them)
  • Editor (A user who can publish and manage posts including the posts of other users)
  • Admin (A user who can do everything and see everything)

When you install a fresh version of Canvas, you'll have a default admin user set up automatically. From there, you can perform any basic CRUD actions on users, as well as assign their various roles.

Canvas UI

Want a beautiful, Medium.com-inspired frontend? Use the canvas:ui Artisan command to install the scaffolding:

php artisan canvas:ui

After generating the frontend scaffolding, your package.json file will include the necessary dependencies to install and compile:

# Using NPM
npm install
npm run dev

# Using Yarn
yarn
yarn dev

That's it! You can navigate to /canvas-ui and check it out for yourself. You're free to modify any aspect of it that you'd like.

Unsplash Integration

Want access to the entire Unsplash library? Set up a new application at https://unsplash.com/oauth/applications, grab your access key, and update 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'),
]

E-mail Notifications

Want a weekly summary? Canvas allows users to receive a weekly digest of their authored content. Once your application is configured for sending mail, update 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),
]

Since this feature runs on Laravel's Scheduler, you'll need to add the following cron entry to your server:

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

API

Installing Canvas UI will be the most efficient way to get up and running with a frontend interface to display your data. However many users will opt for creating this by hand since it gives flexibility to their design aesthetic.

Using the published scope will allow you to only retrieve posts that have a published date in the past:

Canvas\Models\Post::published()->get()

You can also retrieve the inverse with a draft scope:

Canvas\Models\Post::draft()->get()

To return a single post, you'll likely want to find it by a given slug, as well as include related entities such as:

$post = Canvas\Models\Post::with('user', 'tags', 'topic')->firstWhere('slug', $slug);

Important: In the same method that returns a post, make sure you fire the PostViewed event, or else a view/visit will not be recorded.

event(new Canvas\Events\PostViewed($post));

You can find a tag by a given slug:

Canvas\Models\Tag::with('posts')->firstWhere('slug', $slug);

And a similar query can be used for a topic:

Canvas\Models\Topic::with('posts')->firstWhere('slug', $slug);

Users can be retrieved by their id, username, or email:

$user = Canvas\Models\User::find($id);
$user = Canvas\Models\User::firstWhere('username', $username);
$user = Canvas\Models\User::firstWhere('email', $email);

Additionally, you can return the users' published posts with their associated topic:

$user->posts()->published()->with('topic')

Updates

Canvas follows Semantic Versioning and increments versions as MAJOR.MINOR.PATCH numbers.

  • Major versions will contain breaking changes, so follow the upgrade guide for a step-by-step breakdown
  • Minor and patch versions should never contain breaking changes, so you can safely update the package by following the steps below:

You may update your Canvas installation using composer:

composer update

Run any new migrations using the canvas:migrate Artisan command:

php artisan canvas:migrate

Re-publish the assets using the canvas:publish Artisan command:

php artisan canvas:publish

To keep the assets up-to-date and avoid issues in future updates, you may add the canvas:publish command to the post-update-cmd scripts in your application's composer.json file:

{
    "scripts": {
        "post-update-cmd": [
            "@php artisan canvas:publish --ansi"
        ]
    }
}

Contributing

Thank you for considering contributing to Canvas! The contribution guide can be found here.

Testing

Run the tests with:

composer test

Troubleshooting

If you're running into problems, feel free to open a new issue or check the Discussions forum to see if anyone else has run into something similar.

License

Canvas is open-sourced software licensed under the MIT license.

Credits

canvas's People

Contributors

albertoelias123 avatar austintoddj avatar darival avatar dependabot[bot] avatar erikgall avatar fergthh avatar foxted avatar graigdev avatar hayrican avatar hpez avatar imusicjj avatar itsmysterybox avatar jlaswell avatar laravel-shift avatar lszanto avatar mikemand avatar naneri avatar naoray avatar nickbasile avatar nticaric avatar padarom avatar parsingeye avatar patrickadvance avatar rdelorier avatar reliq avatar robertgarrigos avatar talvbansal avatar thewwwizard avatar trasigor avatar yo1l avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

canvas's Issues

[Suggestion] Upgrade process

What is the suggested update process? If none, how would you like to go to update a project created with Canvas?

Class 'App\Models\TNTSearch' not found

I face to problem with the fresh installation. When I tried to create new post I got an error:
FatalErrorException in Post.php line 171: Class 'App\Models\TNTSearch' not found
after I clicked the "save" button. The same error happened with tags creation. But the post/tag was created.

Compilation of Assets

In its current state, Canvas leaves much to be desired in the way of compiling assets and maintaining clean LESS code.

If you look at backend-css.blade.php and backend-js.blade.php, you'll see that all the files are kept in the assets directory and copied over to the public via gulp. The reason behind NOT using CDN's here was because I wanted to keep the integrity of the app/design/style for years to come. Using the specific stylesheets/scripts and not referencing a CDN meant that I could be 100% sure that the app itself would contain all it needed to survive. That does however take up disk space and ultimately weighs down the app with files that COULD be kept off-site. And for an app that prides itself on minimalism, this is something I've put thought into.

Curious to know anyones' thoughts on this and if someone who is very design-oriented/capable wants to take a stab at re-organizing the resource assets, I'd be excited to see what you could come up with.

Biggest stipulation here: The app needs to look/feel as it does in it's current state. Anything from animations to the styling needs to be consistent and be full-proof for future downloads. I know it's a big task, but you guys have already proven to be quite capable when it comes to helping out with this, so have at it. :)

Unit Tests for Models

PHPUnit tests should be written to cover the models of the application.

At the most basic level, these tests should cover the relationship between the models.

Example:
A post can have many tags.
A tag belongs to a post.
A user can have many posts.

The tests can be further fleshed out to protect the application from a pretty granular level.

Upload image from the editor

Hi
When i trying to upload an image from the post editor it shown me an error : Allowed memory size of 536870912 bytes exhausted (tried to allocate 213829600 bytes)

At the beginning i thought it's php.ini issue but after I doubled (more than once) the max size upload the the post size it's doesn't look like it's fixing it.
Thanks

TestItCreatesPost Failing Intermittently

On the PostTest.php method testItCreatesPost, PHPUnit will intermittently fail with this error:

screen shot 2016-07-25 at 8 36 52 pm

This has happened on multiple occasions and breaks the TravisCI build, but can be fixed with pushing another bogus commit, basically making the build restart. So running PHPUnit two times will produce different results, occasionally causing the bug.

@RDelorier Maybe you know what could fix this?

admin navbar covers modal

I noticed the modal in the admin console is partially being covered by the navbar, likely a z-index issue. I'm using chrome 51.0.2704.103 (64-bit)

image

Fatal Error During Creating New Post With Images

Hi Guys,

I have the recent pull request and tried to create a new post.
I received below error

FatalErrorException in ExceptionHandler.php line 259: Allowed memory size of 134217728 bytes exhausted (tried to allocate 35309376 bytes)

when I trying to insert 1 image into the post. I am using wampserver as virtual hosting and I did try to increase the ini_set('memory_limit', '512M') still receive the error.

Sorry if I am wrong somewhere else.

Project language reported incorrectly

Not sure if anyone has experience with fixing this, but GitHub is deciphering the project language as being 45.9% HTML, which isn't correct. It should be something like 95% PHP. I know it's something in the .gitattributes file, but not sure what the fix is.

Slug in Chinese title

Hi

Post's slug is generated by str_slug, which is a problem when users have Chinese title. Is there any idea to solve it?

Activating Markdown Mode

I have pasted some MD into the editor, but the post renders in plaintext, it doesn't convert the MD into HTML. Is there something extra I need to do to make sure this works?

Ability to edit post slug

A user should have the ability to edit the slug url of an individual post. This should take care of #36. This can be done in the post Create/Edit pages.

Show/Hide password button

BUG: On the Profile Privacy page, the password update form can sometimes submit by clicking the Show Content/Hide Content. Only the password should become visible/invisible, the form should ONLY submit when Save is clicked.

The show/hide password button currently says Show Content/Hide Content.

6c91cac6-4b29-11e6-89ea-762479abe5ea

Let's update this to simply be an icon: zmdi zmdi-eye to show the password and zmdi zmdi-eye-off to hide the password.

The color of the icon should be the primary color blue of the app.

This functionality should also exist on the Profile Privacy page, on the password update form.

Why use Job?

Why use Job here?

    public function index(Request $request)
    {
        $user = User::findOrFail(1);
        $tag = $request->get('tag');
        $data = $this->dispatch(new BlogIndexData($tag));
        $layout = $tag ? Tag::layout($tag)->first() : 'frontend.blog.index';
        return view($layout, $data)->with(compact('user'));
    }

Unit Tests for Tag Creating/Editing/Deleting

PHPUnit tests should be written to cover the applications' ability to create/edit/delete a tag.

Example:
A user visits admin/tag.
The user clicks the Create a New Tag icon.
The user fills in no information, and the form does not submit because of validation errors.
The user fills in all of the necessary information.
The user clicks Save and is redirected back to the admin/tag page.

Check that the tag was created in the database.

Same process needs to be tested for editing/deleting a tag.

Controller: TagController.php
Current Test File: /tests/Acceptance/TagTest.php

Application Controller tests

PHPUnit tests should be written to cover the controllers of the application.

At the most basic level, these tests should cover the controller responses and data passed back and forth between the controller methods and views.

Example:
The index() method in the PostController should return a view, with $data passed to the view.

These tests can be further fleshed out to protect the application from a pretty granular level.

Date/Time picker highlight today

The highlight today portion of the datetime picker is just a tiny bit off, design-wise. Instead of the broken circle, it should be a full circle.
screen shot 2016-07-07 at 8 01 46 am

php artisan canvas:install error

After running composer create-project austintoddj/canvas canvas I run php artisan canvas:install, then I get the following error.

[Symfony\Component\Console\Exception\CommandNotFoundException]
There are no commands defined in the "canvas" namespace.

Blog configuration settings

Right now, the blog configuration exists only in config/blog.php. This works for now, at least for the initial installation of Canvas. These values should be persisted to the database however and then be able to be modified from a Blog Settings page.

This will streamline the blog administration for people who are a little less-familiar with Laravel to update their application settings and open this project up to a larger audience.

Upload preview

  1. There is a 404 error in this template resources/views/backend/upload/partials/modals/files/preview.blade.php trying to load an non-existing image on page load. Obviously this modal is used for the file preview. A simple fix might be to create a fake transparent pixel gif to avoid the 404
    screen shot 2016-08-06 at 12 56 14 am
  2. The preview modal should also be triggered by clicking the name of the file. For now, only the magnifying glass icon can trigger it.

Media Library Feature

Add a media library where users can browser currently uploaded images. A user should also be able to select page images from this library when creating/editing posts.

Slug in Chinese title

Hi

Post's slug is generated by str_slug, which is a problem when users have Chinese title. Is there any idea to solve it?

Issue with TNTSearch

Hi guys, after I combine the tntsearch features, I facing below error. Izzit my problem or I miss out some set up.

PDOException in TNTSearch.php line 297: SQLSTATE[HY000]: General error: 1 no such table: info
PDO->query('SELECT * FROM info WHERE key = 'stemmer'') in TNTSearch.php line 297
Because my database does not have the info table.

I tried to search the original tntsearch github guide. Apparently there is not additional migration needed.
Any idea?

Unit Tests for Profile Editing

PHPUnit tests should be written to cover the applications' ability to edit various profile settings.

Example:
A user visits admin/profile.
If the users' phone number is not set, it should not be showing up.
If the users' address is not set, it should not be showing up.
The user clicks the Settings tab.
The user name or email is deleted and the user clicks Save.
The form does not submit due to validation errors.
The user then fills out all the settings options.
The user clicks Saveand is redirected back to the admin/profile page.
Check that all the items saved in the profile are showing up on the profile page.

Controller: ProfileController.php

[Suggestion] Preview mode

Any way to preview posts before publishing them? If not, maybe add it? Really important, especially when people have RSS feeds.

Unit Tests for Folder Creating/Deleting

PHPUnit tests should be written to cover the applications' ability to create and delete a folder.

Example:
A user visits admin/upload.
The user clicks the New Folder icon.
The modal form is presented and is validated for errors.
The user clicks Saveand is redirected back to the admin/upload page.
Check that the folder was created in public/uploads.

Same process needs to be tested for deleting a folder.

Controller: UploadController.php

Running migrations on sqlite throws an exception

I was getting this error when trying to migrate the database with the sqlite driver.

$ php artisan migrate
Migration table created successfully.

  [Illuminate\Database\QueryException]
  SQLSTATE[HY000]: General error: 1 Cannot add a NOT NULL column with default value NULL (SQL: alter table "posts" add col
  umn "subtitle" varchar not null)

  [PDOException]
  SQLSTATE[HY000]: General error: 1 Cannot add a NOT NULL column with default value NULL

Missing support for other countries

Two things I've noticed are currently US specific and don't work for other countries:

  • Phone number formats
  • State

While it is usual to specify the state in the US, this is not the case for every country. I live in Germany and here we mostly omit the state in our address. Also there's no commonly known two-character abbreviation for our states, so even though I put in "BY" (for Bavaria/Bayern) this might not be understood by everyone.

I suggest removing the state as a required field and adding a country field to the user profile. As for the phone number I don't have a clear solution in mind, perhaps it should just be taken care of by the admin/developer of the blog.

Whether or not to set up StyleCI

Want your feedback here. I was looking into setting up StyleCI to maintain a consistent code style throughout the app. In your opinion, would this make it more difficult for you guys creating pull requests, or would this be a good thing to make sure it's got the same format every time you touch it? Not a wrong answer here, just want to get some feedback before implementing something that would essentially set the standard for commits/merges.

Search Function Tests

PHPUnit tests should be written to test the search bar and its results in the application.

Example:
A user visits any page in the backend, clicks the Search icon in the top bar, and types example.
The user taken to the search results page and sees Search Results for example.

Model not found

@nticaric Real quick, if you drop your database, create a new one, and run php artisan migrate --seed, do you get a Class 'App\Models\TNTSearch' not found?

Exception is thrown when trying to format a non existent Phone number

If you edit your profile and fail to enter a phone number, you get a ErrorException thrown.

ErrorException in User.php line 49:
Undefined offset: 1

The phone field should either be required, or some checking should be put in place to prevent exceptions on a null value.

I'll submit a PR.

Unit Tests for Image Uploading/Deleting

PHPUnit tests should be written to cover the applications' ability to create and delete a file/image.

Example:
A user visits admin/upload.
The user clicks the Upload File icon.
The modal form is presented and is validated for errors.
The user clicks Saveand is redirected back to the admin/upload page.
Check that the file was created in public/uploads.

Same process needs to be tested for deleting a file/image.

Controller: UploadController.php

Profile information isset() error

On the profile settings page, if you delete the bio content and save, go back to the main profile page, the heading of Summary will still be present. This is supposed to be being checked by isset($data['bio']), but it's currently not blocking it from showing up.

When you use @if($data['bio'] != '') , the content is hidden if bio does not have a value present, but it breaks the unit test for the profile page.

[Solved] Freeze on creating the admin user process.

 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Success! The blog description has been saved.

 Step 4: Author of your blog:
 > olgierd

Saving author name...
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Success! The author name has been saved.

 Step 5: Number of posts to display on the Blog Index page:
 > 10

Saving posts per page...
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Success! The number of posts per page has been saved.

Creating the admin user...

I have downloaded with github clone and type composer install.

And how to run? I can't find index page.

Post subtitle or excerpt

I've noticed that the subtitle of a post is not displayed in any of the templates. Was it planned to have it be displayed in the same fashion, as the tag subtitle on a tag page?

If not, would it make sense to perhaps use it as an excerpt/description to be displayed on the post overview?

Link to GitHub page in "Edit Profile" page uses the configured Facebook username

The link to the user's GitHub profile in the left column of the "Edit Profile" page in the admin dashboard uses the username that is configured for Facebook. Facebook itself uses the correct username, but the GitHub uses the configured Facebook username as well.

This issue is local to the "Edit Profile" page from what I've seen. The frontpage of the blog generates and displays URLs properly as it should.

Unit Tests for Post Creating/Editing/Deleting

PHPUnit tests should be written to cover the applications' ability to create/edit/delete a post.

Example:
A user visits admin/post.
The user clicks the Create a New Post icon.
The user fills in no information, and the form does not submit because of validation errors.
The user fills in all of the necessary information.
The user clicks Save and is redirected back to the admin/post page.

Check that the post was created in the database.

Same process needs to be tested for editing/deleting a post.

Controller: PostController.php
Current Tests: /tests/Acceptance/PostTest.php

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.