Giter VIP home page Giter VIP logo

enchant97 / hasty-paste Goto Github PK

View Code? Open in Web Editor NEW
195.0 2.0 9.0 506 KB

A fast and minimal paste bin.

Home Page: http://enchantedcode.co.uk/hasty-paste/

License: GNU Affero General Public License v3.0

Python 78.17% Jinja 5.95% CSS 11.38% Dockerfile 1.07% Shell 1.94% JavaScript 1.35% Makefile 0.14%
python asynchronous asyncio docker flatfile pastebin pastebin-api python-3 quart rest-api

hasty-paste's Introduction

Hi there ๐Ÿ‘‹

I am Leo Spratt.

Support Me

Buy Me A Coffee

๐Ÿ“ซ How to reach me

Service Link
Email contact(at)enchantedcode.co.uk
Discord Server https://discord.gg/nryzEvGDQV
Matrix Space https://matrix.to/#/#enchanted-people:matrix.org
More https://enchantedcode.co.uk/about#contact-me

๐Ÿ”ญ Iโ€™m currently working on

Notable Projects

โšก Fun fact

Python and Rust are my favorite languages

๐ŸŒฑ Iโ€™m currently learning

  • WASM
  • Ansible

hasty-paste's People

Contributors

dependabot[bot] avatar enchant97 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

hasty-paste's Issues

Default to new paste page

Rather than the home page showing app info, move this to an about page, and make the home page the new paste page.

Normal workflow is that you go to the app url to do a new paste, so the extra click to get there is not a great flow.

Multilingual Internationalization

This allows for program to be used by people with a different language. This could be accomplished by using I18N with gettext in Python.

If anyone would like to help provide translations (or provide the code to load them) it would be greatly appreciated.

Display loaded settings in stdout

Currently, in Docker logs, the only logs are:

[2022-12-13 16:57:41 +0000] [8] [INFO] Running on http://0.0.0.0:8000 (CTRL + C to quit)
INFO:hypercorn.error:Running on http://0.0.0.0:8000 (CTRL + C to quit)

It may prove fruitful, especially for troubleshooting, to display the current settings.

E.g. (obviously just c+p'd from compose, I'm sure the setting names may be different internally):

[2022-12-13 16:57:41 +0000] [8] [INFO] Running on http://0.0.0.0:8000 (CTRL + C to quit)
INFO:hypercorn.error:Running on http://0.0.0.0:8000 (CTRL + C to quit)
Current settings:
NEW_AT_INDEX=true
ENABLE_PUBLIC_LIST=false
TIME_ZONE=Europe/London
CACHE__INTERNAL_MAX_SIZE=4
UI_DEFAULT__EXPIRE_TIME__ENABLE=true
UI_DEFAULT__EXPIRE_TIME__DAYS=30
UI_DEFAULT__USE_LONG_ID=false
BRANDING__HIDE_VERSION=true

This would also allow for users to see all the variables that they may be able to use in docker compose allowing for easier customisation without finding all the variables within the docs.

Add a paste title field

Is your feature request related to a problem? Please describe.
no

Describe the solution you'd like
Introduce a paste title field, to offer a simple way to classify the pastes.

Describe alternatives you've considered
n/a

Additional context
n/a

Auto Syntax Highlighting

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
Hastebin offers a way to automatically detect (granted, not always perfect) the syntax highlighting and applies to the code automatically.

Feature 1:

  • Allow for empty highlighting

Feature 2:

  • Allow for auto highlighting, with changable language in URL (possibly the simplest way (maybe?)).

For example:

This would allow for easy syntax highlighting changes post paste also in case a user got it wrong the first time/found a better highlighting language for something non-standard.

Describe alternatives you've considered
n/a

Additional context
n/a

Add Optional in-memory caching

  • Use Memcached
  • Must be optional
  • Cache Items
    • Processed paste meta
    • Rendered content
  • Provide docker-compose file pre-configured for easier deployment

Extension in paste url does not get used

When using a custom extension in the paste url e.g. example.com/2fCj3W3QOQ.py the original set lexer gets used instead.

This is due to how the cache works. Once a rendered paste is cached it will use it every time, even if a override lexer name is given.

Fix for V1.6.x

This will be fixed with only caching original set lexer, every time a override lexer is given it will not use the cache. In V1.7 it is planned to have a much better caching & storage system.

Remove paste(s) feature

Is your feature request related to a problem? Please describe.
There is no "simple" way to remove old posts

Describe the solution you'd like
Provide an admin feature to view all pastes, which offers a delete feature.

Describe alternatives you've considered

  • Opening every paste folder and file, then examining the paste to see if you need to keep it.
  • Having the option to blanket-delete all pastes older than a set time.

Custom/default error page for deleted/not found pastes

Currently, if you go to an expired paste, or get the URL wrong, you get:

Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

Aesthetically speaking, this could potentially be improved by having a default "404 not found" page which fits into the hasty-paste theme.

Change options layout

Update layout for expires at (could be just 'expiry'), long ID, and syntax highlighting, so that controls stack horizontally if space permits.

Additionally, set expiry and syntax dropdown to be a smaller width

This will make the page neater and look better on mobile devices.

Copy to new paste

Is your feature request related to a problem? Please describe.
no

Describe the solution you'd like
The option to "copy" into a new a paste, which takes the contents of the currently viewed paste and puts it into a new paste, which can be updated.

Describe alternatives you've considered
Copy/paste, but that's primitive :)

Additional context
none

New Paste

Is there an existing issue for this?

  • I have searched the existing issues

Is This A Security Issue?

  • This is not a security issue

Describe The Problem

Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

Expected Behavior

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/.venv/lib/python3.10/site-packages/quart/app.py", line 1650, in handle_request
    return await self.full_dispatch_request(request_context)
  File "/app/.venv/lib/python3.10/site-packages/quart/app.py", line 1675, in full_dispatch_request
    result = await self.handle_user_exception(error)
  File "/app/.venv/lib/python3.10/site-packages/quart/app.py", line 1107, in handle_user_exception
    raise error
  File "/app/.venv/lib/python3.10/site-packages/quart/app.py", line 1673, in full_dispatch_request
    result = await self.dispatch_request(request_context)
  File "/app/.venv/lib/python3.10/site-packages/quart/app.py", line 1718, in dispatch_request
    return await self.ensure_async(handler)(**request_.view_args)
  File "/app/paste_bin/views/frontend.py", line 99, in post_new_paste
    paste_id = await paste_handler.create_paste(
  File "/app/paste_bin/core/paste_handler.py", line 57, in create_paste
    raise PasteHandlerStorageException() from err
paste_bin.core.helpers.PasteHandlerStorageException

Steps To Reproduce

No response

Environment

No response

Extra Context

No response

Public Pastes

  • Viewable list pastes
  • Option to make all pastes public (from env variable)

Copy Share link doesn't work on Firefox

Describe the bug
The "Copy Share Link" button doesn't work on Firefox.
(It does work on Edge)

To Reproduce
Steps to reproduce the behavior:

  1. In Firefox, open hastypaste website (behind reverse proxy - NginxProxyManager)
  2. Click on "Copy Share Link"
  3. Try to paste the link somewhere
  4. See error in firefox console (see screenshot below)

Expected behavior
The link should copy as expected (it does on Edge)

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Firefox
  • Version v1.3

Branding Customisation

Customisation of certain parts of Hasty Paste have been discussed in #38.

Here are some of the things that should be customisable:

  • Title
  • Icon
  • Theme-Colours, most likely through changing CSS variables

The customisation features will not allow changing the "Powered By" message in the footer.

Add text box for syntax dropdown

Thank you for adding syntax highlighting. I was wondering if you could change it from a straight dropdown to include a text box. That way I can type 'yaml' to select the language, rather than having to scroll all the way down.

See pastebin.com for example of this.

Make the rootless container feature, optional

It is a pain to be forced down the rootless path, when it was all working fine as is. I would much prefer to keep backwards compatibility, and only have rootless as an extra option, or not at all.

Maybe have an option to supply an environmental var for the puid/pgid for it to run as, rather than hard code to nobody?

(feat) Redis database

Does it fit the projects scope?

  • This is relevant

Why?

The ability to change which key store hastypaste can use in redis is useful

Solution?

Be able to specify the database:

E.g. CACHE__REDIS_URI=redis://redis:6379:2

Alternatives?

No response

Extra Context

No response

"Copy Share Link" button does not work under http

Describe the bug
Copy Share Link bouton not run

To Reproduce
Steps to reproduce the behavior:

  1. Create New Paste
  2. Click on "Copy Share Link"
  3. Paste or Ctrl+V
  4. Not Share Link

Expected behavior
The "Copy Share Link" as work

Screenshots
https://user-images.githubusercontent.com/45015615/192137844-fd77f5df-9740-4833-8250-e3c5799cff8a.mp4

2022-09-25 12-48-14

Uncaught (in promise) TypeError: navigator.clipboard is undefined
    copy_to_clipboard http://192.168.2.20:4010/static/script.js:6
    promise callback*copy_to_clipboard http://192.168.2.20:4010/static/script.js:6
    onclick http://192.168.2.20:4010/vBf05lnLf2NniEKpP7FTG7U7GbadXBM3oB8kqcRp:1
[script.js:6:19](http://192.168.2.20:4010/static/script.js)
    copy_to_clipboard http://192.168.2.20:4010/static/script.js:6
    (Asynchrone : promise callback)
    copy_to_clipboard http://192.168.2.20:4010/static/script.js:6
    onclick http://192.168.2.20:4010/vBf05lnLf2NniEKpP7FTG7U7GbadXBM3oB8kqcRp:1

https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Errors/Unexpected_type

Install (please complete the following information):*

  • Docker install
  • Hasty Paste V1.5

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser : Chrome 105.0.5195.127 / Firefox 105 / Edge 105

Thx

Rootless Docker Image

Make the Docker image use the "nobody" user. This means it will not run the app as root.

Expiry set in UI always interpreted as UTC

When setting the expiry in the web UI, the datetime is interpreted as utc not local time. This may cause pastes to expire before & after set time.

The solution is to set the local timezone in the settings, this will be implemented in V1.7.

Do not show version number

Is your feature request related to a problem? Please describe.
For security obscurity reasons, I think the version number of Hasty Paste should not be publicly visible.

Describe the solution you'd like
Be able to choose to hide the version number of Hasty paste, for example with a docker environment variable
Ex :
BRANDING__VERSION=True
image

BRANDING__VERSION=False
image

Describe alternatives you've considered

Additional context

Potential Dockerfile Improvements

Heya,

Great work so far! I'll be (re-)deploying this weekend!

I've been doing some work w/ Dockerfiles recently, and came across COPY --link whilst working with BUILDKIT_INLINE_CACHE=1 which may be useful.

Further information:

Docker workflow modifications for the above:

It's already damn clean though! Hope it helps reduce build times and sizes!

Purpose of long ID?

What's the long ID option for? I understand the difference in the paste url, but wondered what the use case was?

Disable auto capitalise and auto spell check

On android devices (and maybe other devices), text entered is auto-capitalised and spell check tested. Please turn this off.

Example

<input type="text" autocorrect="off" autocapitalize="off"/>

[For V1.7] Remove Deprecated Features

Features in previous updates have been deprecated. To reduce the amount of redundant code and feature blocking, these features will have to be completely removed/changed. This issue will indicate when and what features are going

Whats Changing?

  • Paste id's not in a-zA-Z0-9 will no longer be accepted
  • API route /api/pastes/{paste id} will no longer return the flat file, but instead the paste content
  • API route /api/pastes/{paste id}/content will be removed (will be /api/pastes/{paste id})

Why?

  • Clearer Paste ID's, with the ability of adding padding into the paste ID's for easier reading by humans
  • A better API, ready for use with a official CLI app

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.