austintoddj / canvas

Publishing on your own terms
http://trycanvas.app
MIT License
3.25k stars 520 forks source link

Allow guest to view all post #473

Closed kavierkoo closed 5 years ago

kavierkoo commented 5 years ago

Hi,

Apologize if newbie question asked, newbie hobbyist trying to develop something here.

I am thinking to make a personal blog as portfolio and came across Canvas, it is awesome, clean and it works.

bumped into few errors like defaultStringLength and MariaDB not support JSON, managed to solve it.

and I am lost as my objective is to allow visitor to see all published posts without require to Login but not able edit anything.

I can see middleware in vendor\cnvs\canvas\config\canvas.php also routes mention that initial xx.xx.xx.com/canvas using StatsController but I have no clue how to modify to achieve my objective.

Could shed some light on how could I achieve that?

Thanks in advance!

austintoddj commented 5 years ago

Glad you like it!

As far as your objective is concerned, are you saying that you'd like visitors to be able to access the /canvas routes but not able to create/edit/delete things?

The middleware you're seeing is simply verifying that authenticated users are accessing Canvas, since the user id is stored in the posts table to notate authorship.

If you wouldn't mind re-wording your question, perhaps I could be of more help.

kavierkoo commented 5 years ago

Hi Austin, Thanks for the patients and my apology for the confusion, Let me rephrase my words

The goal is just like blogs on blogspot / wordpress where:

Conclusion: 2 types of user:

I have no clue on how to achieve to only use Middleware when someone access 127.0.0.1:8000/login but all Posts are visible to all visitors with no login required

I only manage to do some changes on the routes and views to fit my personal requirement.

So would be very appreciate if you shed some light on how to do so.

Thanks Regards

austintoddj commented 5 years ago

Ah, I think I see where you're going. Correct me if I'm wrong..

Canvas has a built-in Artisan command to generate routes, views, and a controller which makes the posts(published), tags, and topics visible to non-authenticated users. In simpler terms, it generates a frontend.

Check the documentation section here and simply run php artisan canvas:setup and you'll be able to visit http://your-app.test/blog to see the content you've created with Canvas.

Does that answer your question?

kavierkoo commented 5 years ago

Thanks for the prompt response, let me check and test it out first! Appreciate for the advise!! Come back to you if I am still stuck!!

Thanks Austin!!

kavierkoo commented 5 years ago

Hi Austin,

It works as you describe!! Apologize for overlooked the php artisan canvas:setup in documentation!

The blog looks awesome!!

Thanks!! Kudos to yall!!

noahdigesu commented 1 year ago

Hi !

I would like to achieve the exact same result as @kavierkoo, however the php artisan canvas:setup command is not available anymore. How should I go about this ?

Thank you in advance :)

austintoddj commented 1 year ago

@noahdigesu The command you're looking for is install. See it here in the documentation.

noahdigesu commented 1 year ago

Hey ! :) Thanks for the quick answer @austintoddj, but I think there is a misunderstanding.

When I said "I would like to achieve the exact same result as @kavierkoo" I was not referring about the command but about this :

Hi Austin, Thanks for the patients and my apology for the confusion, Let me rephrase my words

The goal is just like blogs on blogspot / wordpress where:

  • Author require to access /login and login to publish / create / modify / delete posts.
  • Visitor can access 127.0.0.1:8000/ and see all the posts in canvas with no login required

Conclusion: 2 types of user:

  • Author, login required, Can do anything (actually there will be only 1 author which is me)
  • Visitor, No login required, No permission to do anything, Only view all the posts

I have no clue on how to achieve to only use Middleware when someone access 127.0.0.1:8000/login but all Posts are visible to all visitors with no login required

[...]

I thought php artisan canvas:setup would allow me to achieve such result, but since the command does not exist anymore, I am wondering how to go about this.

My usage for canvas would be to keep a detailed monthly newsletter under the shape of articles for my app. Anyone on the internet would be able to look at such articles, but I would be the only one allowed to create them (see this medium list for a more concrete example).

austintoddj commented 1 year ago

Anyone on the internet would be able to look at such articles

I see. So it sounds like you're trying to create a frontend to display posts publicly, is that correct?

If so, you can achieve that with the canvas:ui Anyone on the internet would be able to look at such articles.

noahdigesu commented 1 year ago

Nice ! Thanks ! :D I feel like the README might not be super clear about this - I thought canvas:ui was an alternative to the "default" look of canvas. Maybe mention "Want to enable guest users to access your articles ?" or something similar to make it more explicit ?

austintoddj commented 1 year ago

Understood. Thanks for brining up that it was difficult reading between the lines on that. I'll see what it looks like updating that in the next release.