Giter Club home page Giter Club logo

digist's Introduction

Digist

Today's code snippets are ugly, static, and self-contained. Digist transforms your GitHub Gists into highly functional code snippets for the web that mimic the look and feel of VS Code. Your functions, classes, and random blobs of code have never looked better!

Getting Started

Vocabulary

  • Gist: a set of files stored on GitHub's Gist service
  • Slice: a subsection of a Gist for a certain file (e.g., main.js:4:6)
  • Snippet: an embedded code viewer with two states: collapsed and expanded

Installation

Installing Digist is a walk in the park. Just clone this repo, install its dependencies with npm, and start the Express server.

npm install

# Start Express server on port 3000
npm start

Usage

Render a Snippet

localhost:3000/gist/{gist_id}?file={file}&slice={slice}&theme={theme}

Name Description
gist_id Gist ID from GitHub
file The default file shown by the snippet
slice The lines of file shown by the snippet, formatted as {startLine}:{endLine}
theme Optional: either dark (default) or light

Here's a sample request:

localhost:3000/gist/26b7cb6545cb1cb56d9dc8ac273ee4fc?file=Person.ts&slice=4:6&theme=dark

Here's the result:

Sample of rendered snippet

Beautiful! ๐Ÿ˜

digist's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

digist's Issues

Create a snippet-page template in Pug

We should separate snippet.pug (just the snippet code) from the page it's rendered on. This will give us more flexibility when embedding the snippet directly on someone else's page.

Create a "View on GitHub" button

This needs to end up in our Pug template file, but you can prototype it using our demo-page.html. We need to convert the right-side button to link to GitHub.

Combine stylesheets using CSS magic

snippet {
    /* shared style */
}

snippet--dark {
    /* dark style */
}

snippet--light {
    /* light style */
}

I'm marking this as a bug because our current approach of two stylesheets is error-prone.

Pug output should not contain the ' character

This bug makes it really annoying to write to the DOM. Our code will be wrapped in document.write('...'), so any single quote characters will break the system. This makes me feel like we are overlooking a step, but in the Spirit of the Hackathon I say we choose the quick fix.

Mimic GitHub readme format for parameters table

Here's an example:

Render a snippet

https://digist.azurewebsites.net/gist/{gist_id}?file={file}&slice={slice}&theme={theme}

Name Description
gist_id Gist ID from GitHub
file The default file shown by the snippet
slice The lines of file shown by the snippet, formatted as {startLine}:{endLine}
theme Optional: either dark (default) or light

Originally posted by @jungaretti in #63 (comment)

Demo with localhost instead of Azure

Azure App Service deployment is broken up after each commit until I toggle the plan from free to paid to free, so README.md should probably include directions for running Digist locally

An entire file should be a valid slice range

Repro Steps

I'd expect https://digist.azurewebsites.net/gist/b8bcfe1023296fabe6eb66dbfbaa684e?file=test.cpp&slice=14:34 to be a valid request since test.cpp has 34 lines.

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.