Skip to content

cutelyst/pastelyst

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pastelyst

Pastelyst is an easy to use and expandable web paste tool built with Cutelyst and KDE Frameworks 5 Syntax Highlighting. It uses less than 3 MB of RAM and renders quickly using a SQLite DB for the storage.

Pastelyst is almost feature complete and on production at paste.cutelyst.org. You can grab the code and deploy your own paste tool now. And please don't forget to contribute to adding these extra features if you have time:

  • Extra database support
  • URL shortener
  • User authentication
  • And some more

The list is short and the code is clean, go test, break, hack, and have fun!

Dependencies

  • Grantlee
  • KDE Frameworks 5 Syntax Highlighting
  • Cutelyst 2.0.0 or newer with enabled Grantlee plugin

Configuration

Create an INI file like pastelyst.conf with:

[Cutelyst]
DatabasePath = /var/tmp/my_site_data/pastelyst.sqlite
production = true

social = true
download = true
clipboard = true

Where:

  • DatabasePath is the place where sqlite database will be placed
  • production when true will preload the theme templates, which is a lot faster but if you are customizing the theme you will need to reload the process
  • social adds social media share buttons for pastes if enabled
  • download adds download button for pastes if enabled
  • clipboard adds copy to clipboard button for pastes if enabled

Running

You can run it with cutelyst-wsgi or uWSGI, both have similar command line options, and you should look at their documentation to know their options, the simplest one:

cutelyst-wsgi2 --application path/to/libPastelyst.so --http-socket :3000 --ini pastelyst.conf --chdir parent_of_root_dir --static-map /static=root/static

The chdir needs to point to the parent of the root directory that came from this project. The option --static-map is used to serve the static files.

Now point your browser to http://localhost:3000

API Usage Guidelines

Pastelyst also provides an API. Using the API, you can create your own applications based on Pastelyst or use Pastelyst from terminal. For details see Creating RESTful applications with Qt and Cutelyst, Understanding And Using REST APIs, and POST Form Data with cURL.

List pastes

curl -H "Content-Type: application/json" -X POST  https://paste.cutelyst.org/api/json/list/1
{"result":{"count":15,"pages":0,"pastes":["hW7BwGCNS","7B6G5HJNT","l_Zo9VaRT","f_9z4b-_T","YnsDOFIRR","pu0h5ftsT"
curl -H "Content-Type: application/json" -X POST  https://paste.cutelyst.org/api/json/list/2
{"result":{"count":15,"pages":0,"pastes":[]}}

Show pastes

curl -H "Content-Type: application/json" -X POST  https://paste.cutelyst.org/api/json/show/pu0h5ftsT
{"result":{"data":"#include <iostream>\r\n\r\nint main() {\r\n  std::cout << \"hello\\n\";\r\n  return 0;\r\n}","id":"pu0h5ftsT","language":"C++","timestamp":1503821618,"title":"Test"}}
curl -H "Content-Type: application/json" -X POST  https://paste.cutelyst.org/api/json/show/STIdv05VREeht/1234567890
{"result":{"data":"my hidden text is here.","id":"STIdv05VREeht","language":"text","timestamp":1547050001,"title":"API test 1"}}

Create pastes

curl -X POST http://localhost:3000/api/json/create -F 'data=echo "Hello World!"' -F 'language=Bash' -F 'title=API Test'
{"result":{"id":"m2TvYu2sQ"}}
curl -X POST http://localhost:3000/api/json/create -F 'data=echo "Hello World!"' -F 'language=Bash' -F 'title=API Test' -F 'password=1234567890'
{"result":{"id":"tMQD52pdRCe3K"}}

History

Pastelyst was initially developed by Daniel Nicoletti and announced on August 25, 2017 on cutelyst.org. Sticklyst, which was chosen as the project name, was later replaced by Pastelyst.