Coder Social home page Coder Social logo

jackyzha0 / ctrl-v Goto Github PK

View Code? Open in Web Editor NEW
114.0 3.0 6.0 934 KB

๐Ÿ“‹ a modern, open-source pastebin with latex and markdown rendering support

Home Page: https://ctrl-v.app/

Go 23.98% Dockerfile 1.01% Makefile 1.30% JavaScript 73.70%
pastebin go react open-source nextjs vercel

ctrl-v's Introduction

ctrl-v

A modern, open-source pastebin with latex and markdown rendering support

Frontend is in React + Next.js and backend is in Go. Deployed via Vercel and Google Cloud Run.

Go Paste Example Markdown Rendering Showing off another theme! Latex Rendering

Public API

The ctrl-v API is provided for free for other developers to easily develop on top of it. It can be reached at https://api.ctrl-v.app/.

GET /health

# get the health of the API
curl https://api.ctrl-v.app/health

# 200 OK
# > "status ok"

POST /api

# create a new paste
curl -L -X POST 'https://api.ctrl-v.app/api' \
    -F 'expiry=2021-03-09T01:02:43.082Z' \
    -F 'content=print(\"test content\")' \
    -F 'title=test paste' \
    -F 'language=python'

# or with a password
curl -L -X POST 'https://api.ctrl-v.app/api' \
    -F 'expiry=2021-03-09T01:02:43.082Z' \
    -F 'content=print(\"test content\")' \
    -F 'title=test paste' \
    -F 'language=python' \
    -F 'password=hunter2'

# 200 OK
# > { "hash": "6Z7NVVv" }

# 400 BAD_REQUEST
# happens when title/body is too long, password couldnt
# be hashed, or expiry is not in RFC3339 format

GET /api/{hash}

# get unprotected hash
curl https://api.ctrl-v.app/api/1t9UybX

# 200 OK
# > {
# >   "content": "print(\"test content\")",
# >   "expiry": "2021-03-09T01:02:43.082Z",
# >   "language": "python",
# >   "timestamp": "2021-03-02T01:06:16.209501971Z",
# >   "title": "test paste"
# > }

# 401 BAD_REQUEST
# happens when paste is password protected. when this happens, try the authenticated alternative using POST
# 404 NOT_FOUND
# no paste with that ID found

POST /api/{hash}

# get unprotected hash
curl -L -X POST 'https://api.ctrl-v.app/api/1t9UybX' \
  -F 'password=hunter2'

# 200 OK
# > {
# >   "content": "print(\"test content\")",
# >   "expiry": "2021-03-09T01:02:43.082Z",
# >   "language": "python",
# >   "timestamp": "2021-03-02T01:06:16.209501971Z",
# >   "title": "test paste"
# > }

# 401 BAD_REQUEST
# wrong password
# 404 NOT_FOUND
# no paste with that ID found

Developing

when doing local backend development, make sure you change the backend address to be localhost. You can find this on Line 4 of frontend/src/http/shared.js

Common

make dev โ€” starts React development server on :3000 and backend on :8080

Frontend

make fe-run โ€” starts React development server on :3000

make fe-build โ€” builds development release of frontend in frontend/build

Backend

make run โ€” starts backend on :8080

make lint โ€” lints all Go files

make docker-build โ€” builds Docker image of current backend

make docker-run โ€” runs built Docker image on :8080

ctrl-v's People

Contributors

dependabot[bot] avatar ianmah avatar jackyzha0 avatar rmehri01 avatar siddhant-k-code avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ctrl-v's Issues

๐ŸŒ™ Dark mode

'nuff said

const theme = {
  colors: {
    background: '#111111',
    codeHighlight: '#ffffff08',
    border: '#565656',
    text: '#faf9f5',
    error: '#ee1111',
  },
}

AC:

  • Add toggle to switch themes
  • Persist option to local storage

Add line number selection

Would be nice to be able to create permalinks for pastes too, similar to what GitHub offers: https://docs.github.com/en/github/managing-your-work-on-github/creating-a-permanent-link-to-a-code-snippet

Example URL would be https://ctrl-v.app/2uKMJEu#L1-L14

Good place to start would be the lineProps prop on the syntax highlighter: https://www.npmjs.com/package/react-syntax-highlighter

AC:

  • After a paste has been created, users should be able to click on the line number gutter to highlight/select lines
  • Selecting lines should bring up the option to copy a permalink to those lines
  • Viewing a paste with permalink anchors should highlight those lines

Setup CI/CD Workflows

AC:

  • Changes to backend are deployed to GCR
  • Changes to frontend are deployed to Firebase Hosting

Markdown Code Rendered Differently in Preview

When previewing markdown on the main page, both code blocks and inline code are displayed without the background:

image

The render of the actual paste:

image

Also syntax highlighting would be nice if it isn't too hard.

Ability to 'fork' a paste

Would be nice to be able to copy content of an existing paste and make a new one with its contents

AC:

  • Add a 'fork' button to view paste page
  • Add new backend endpoint to create paste with content

Text Area control are finicky

Indenting and unindenting text kinda sucks right now

AC:

  • Properly support tabbing and shift-tabbing
  • Set tab spacing to 2 spaces

UI is unclear

AC:

  • Make password field description
  • Rename 'new paste' to 'create paste'
  • Add spinner to indicate loading

fix and refactor makefile

  1. fix docker-all to properly depend on docker-build
  2. move all backend related makefile stuff into backend and reference it using -C flag
  3. move all frontend related makefile stuff into frontend and reference it using -C flag

Style Tags Not Working

<p style="color: blue">Siddhant</p>

This Should Render to:

image

But, it is rendering like this:
image

fix mobile view

website looks like garbage on mobile, pls fix
probably just use media queries? @ianmah lmk if you have experience w responsive react

AC

  • mobile no longer looks like ass

Related to all CSS issues

  • Responsive Watermark at Bottom Left
  • Password TextBox

Please add more to the list, if you find any!

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.