Skip to content
/ icblog Public
forked from lukasvozda/icblog

Sample Blog app running on the Internet Computer. Backend is written in Motoko programming language and frontend in Svelte compiler.

License

Notifications You must be signed in to change notification settings

Kyliux/icblog

 
 

Repository files navigation

Current state

  • Deploy to local and works
  • Does not deploy in the IC mainnet // pls help I am lost

IC BLOG sample app

It is the icblog from @lukas_icp with some modification. This is very bad factorized and is the results of a few weeks of try and error after years of not touching IT and development. So svelte and motoko arent in my skillset yet. If you are looking for clean code, well, you can help improving this one ;D.

ChatGPT also helps me and that really helps alot.

I am adding a Gallery section having the following characteristic :

  • packery gallery
  • Dynamic upload and delete, only possible when you are connected

Backend

Image a stored on the ICP chain

Requirements

This gallery is optimised with pictures having size assembled from block of 200px.

Local deployment

We assume that you have:

Once you have cloned the repository, follow this process in your terminal:

  1. In your project directory, run this command to install JS dependencies:
$ npm install
  1. Start local Internet Computer replica (or open a new terminal window and run it without the --background parameter):
$ dfx start --background 
  1. Deploy your canisters locally:
$ dfx deploy
  1. Run local dev server:
$ npm run dev

You should see a localhost URL looking like this "Local: http://localhost:3000/" in your terminal. Open this in your web browser and see the app running.

Canisters are working in anonymous mode for local development. In production, we want create/update/delete methods to be allowed only for not anonymous users. This happens automatically based on global env variable in the frontend:

const [blog] = process.env.NODE_ENV == "production" ? useCanister("blog") : useCanister("blog", { mode: "anonymous" })

In the backend, this part of code is currently commented for local development:

if(Principal.isAnonymous(msg.caller)){ // Only allows signed users to create a posts
    return #err(#UserNotAuthenticated); // If the caller is anonymous Principal "2vxsx-fae" then return an error
};

Deploy to the mainnet DO NOT WORK; HAVE ERROR MSG

If you have working local development replica, you can deploy your project to the mainnet by running this command:

$ dfx deploy --network ic

You are going to need a cycles wallet. Go through this tutorial to make it working.

Footnote

This project was created by Lukas Vozda, big Dfinity supporter. If you want to reach out to me and ask some qustion here are my social network handles:

  • @lukas on Open Chat
  • @lukas_icp on Twitter

About

Sample Blog app running on the Internet Computer. Backend is written in Motoko programming language and frontend in Svelte compiler.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Motoko 75.9%
  • Modelica 18.3%
  • JavaScript 4.1%
  • Svelte 1.5%
  • Python 0.1%
  • Makefile 0.1%