Code Monkey home page Code Monkey logo

kyliux / icblog Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lukasvozda/icblog

0.0 0.0 0.0 2.45 MB

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

Home Page: https://axbkd-riaaa-aaaag-abpza-cai.icp0.io/ currently not working

License: Apache License 2.0

JavaScript 4.11% HTML 0.02% Svelte 1.53% Motoko 75.81% Shell 0.02% Python 0.10% Modelica 18.31% Makefile 0.06% Dhall 0.04%

icblog's Introduction

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

icblog's People

Contributors

lukasvozda avatar bienvenidoss avatar

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.