Giter Site home page Giter Site logo

sztheory / markdown-live Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nickdichev/markdown-live

0.0 1.0 0.0 209 KB

[mirror] MarkdownLive is an example application using Phoenix LiveView which renders user-submitted Markdown on the server.

Home Page: http://markdown.dichev.io

Elixir 75.49% Dockerfile 4.71% CSS 5.49% JavaScript 11.72% HTML 2.59%

markdown-live's Introduction

MarkdownLive

About

MarkdownLive is an example application for Phoenix LiveView.

When a client connects to the server they are initially served some HTML content. In our case, what is initially rendered is a textarea prepopulated with some Markdown and the HTML view of that Markdown. However, this is where things get interesting. A websocket connection is opened between the client and the server. The server listens for changes in the textbox, re-renders the HTML, and sends the smallest possible change back to the client which then updates the DOM.

All of this is powered by Phoenix LiveView and the Earmark Elixir library. I used this as application as my first introduction to LiveView and I really enjoyed it. It was so simple to get the functionality working (in fact, I spent more time wrestling with CSS than Elixir...), and I can't imagine the headache I would have gone through to get this working with JavaScript.

Additionally, I wanted to learn about deployment with Kubernetes. You can see an example of this application running here.

Usage

Mix

The application can be run with mix.

mix phx.server

Now point your browser at localhost:4000 to see the application running!

Note: if you want to serve some default Markdown file when the app is launched, set the environment variable DEFAULT_MD. A sample file is provided in docker/default.md.

Docker

A Dockerfile is provided which can be used to compile and run the application:

docker build -t markdown_live:latest .
export COOKIE=$(mix phx.gen.secret 64)
docker run --env HOST="localhost" --env COOKIE="${COOKIE}" -p 4000:4000 --rm --name markdown_live markdown_live

You should be able to point your browser at localhost:4000 and see the application running!

markdown-live's People

Contributors

nickdichev avatar skade avatar

Watchers

 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.