Code Monkey home page Code Monkey logo

polarite's Introduction


Polarite is a Pastebin alternative made for simplicity written in Go.

Usage

Web Interface

Visit https://polarite.teknologiumum.com

API

Send a POST request to https://polarite.teknologiumum.com with:

  • Content-Type header with the value of text/plain
  • Non-empty request body consisting of the text you want to store
  • Authorization header with the value of Your Name <your email> with a minimum of 15 characters.

Example request:

  • cURL
curl \
    -H "Content-Type: text/plain" \
    -H "Authorization: John Doe <[email protected]>" \
    -X POST \
    -d "Hello World" \
    https://polarite.teknologiumum.com/
  • Javascript (via Fetch API)
fetch("https://polarite.teknologiumum.com/", {
    method: "POST",
    headers: {
        "Content-Type": "text/plain",
        "Authorization": "John Doe <[email protected]>"
    },
    body: "Hello world!"
})
  • Go
import (
    "net/http"
    "strings"
)

func Polarite() {
    body := strings.NewReader("Hello world")
    req, err := http.NewRequest(http.MethodPost, "https://polarite.teknologiumum.com/", body)
    req.Header.Add("Content-Type", "text/plain")
    req.Header.Add("Authorization", "John Doe <[email protected]>")

    client := &http.Client{}
    resp, err := client.Do(req)
}
  • C#
using System.Net.Http;

var client = new HttpClient();
var request = new HttpRequestMessage() {
    RequestUri = new Uri("https://polarite.teknologiumum.com/"),
    Method = HttpMethod.Post,
    Headers = {
        { "Authorization", "John Doe <[email protected]>" },
        { "ContentType", "text/plain" }
    },
    Content = new StringContent("Hello world", Encoding.UTF8, "text/plain")
};

var task = await client.SendAsync(request);

Available Options

Polarite uses alecthomas/chroma. You can pass some options to the highlighter by appending these parameters in the URL. If none of these options are passed, you will get a plain text without any highlighting

  • lang

    This option decides which language to use. See alecthomas/chroma#supported-languages for supported languages.

    • https://polarite.teknologiumum.com/your-unique-id?lang=go
    • https://polarite.teknologiumum.com/your-unique-id?lang=rust
  • theme

    This option decides which theme to use. The default theme is dracula.

    • https://polarite.teknologiumum.com/your-unique-id?theme=monokai
    • https://polarite.teknologiumum.com/your-unique-id?theme=nord
    Click here to see all valid themes
    • abap
    • algol
    • algol_nu
    • arduino
    • autumn
    • base16-snazzy
    • bw
    • borland
    • colorful
    • doom-one
    • doom-one2
    • dracula
    • emacs
    • friendly
    • fruity
    • github
    • hrdark
    • hr_high_contrast
    • igor
    • lovelace
    • manni
    • monokai
    • monokailight
    • murphy
    • native
    • nord
    • onesenterprise
    • paraiso-dark
    • paraiso-light
    • pastie
    • perldoc
    • pygments
    • rainbow_dash
    • rrt
    • solarized-dark
    • soldarized-dark256
    • solarized-light
    • swapoff
    • tango
    • trac
    • vim
    • vs
    • vulcan
    • xcode
    • xcode-dark
  • linenr

    This option decides whether to enable line number or not. A non empty value is considered as true.

    • https://polarite.teknologiumum.com/your-unique-id?linenr=yes
    • https://polarite.teknologiumum.com/your-unique-id?linenr=true This is also valid

You can, of course, combine the options. For example: https://polarite.teknologiumum.com/your-unique-id?lang=rust&theme=nord&linenr=true

Why the name, Polarite?

In the dawn of time, it began with the birth of Graphene repository, which its' name was picked from the name of a mineral. Then, not so long after, another repository called Flourite emerged. It's actually a typo of Fluorite, another name of a mineral. Now, where mankind stands, we want to continue that convention, to pick a name from a list of mineral on Wikipedia.

License

   Copyright 2021-present Teknologi Umum <[email protected]>

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

See LICENSE

polarite's People

Contributors

aldy505 avatar artileda avatar dependabot[bot] avatar elianiva avatar kokizzu avatar muktiarafi avatar ronnygunawan avatar zasdaym avatar

Stargazers

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

Watchers

 avatar

polarite's Issues

Support dark mode

GET / and GET /:id should support dark mode (with @media prefers-color-scheme) when an Accept headers of text/html or text/html; charset=utf-8 is present. If the Accept header is not those, it will return just a plain text.

If a query is present (like the theme and whatnot as defined here: https://github.com/teknologi-umum/polarite/blob/master/business/models/query.go), the dark mode support will be disabled and will reflect the theme asked by the client.

This can be done by simply changing the CSS of the HTML template. You can see how Fiber can output HTML template here: https://docs.gofiber.io/guide/templates

For the constant of the MIME Type of text/html and text/html; charset=utf-8, please refer to the constants available on the Fiber documentation: https://pkg.go.dev/github.com/gofiber/fiber/[email protected]?utm_source=gopls#pkg-constants

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.