Added link shortener feature.

Now app can either handle pastes or shorten links, but not both.
This commit is contained in:
eleksir
2017-03-18 16:14:52 +03:00
parent cd72ee3124
commit fbc8445b73
3 changed files with 176 additions and 30 deletions

View File

@@ -1,9 +1,11 @@
## Paste. ##
This is pastebin replacement. It does not use ads, it is opensource it is relatively small.
This is pastebin replacement. It does not use ads, it is opensource, it is relatively small.
And it has minimal pastebin API stub, at least pastebinit can paste to it with minimal config changes.
Besides pastebinit there are 2 cli clients available on main page of this app.
And as a bonus this app can short links too! But it either shorts links **or** stores paste, not both at same time.
### How do I get set up? ###
This paste utilizes PDO SQLite driver, well, at least for now :) and mbstrings.
@@ -11,7 +13,11 @@ Tested php versions are 5.6.30 and 7.0.12. Paste uses **paste/paste.sqlite** fil
Tested on apache/fcgid (windows) for dev and nginx/php-fpm for prod.
Default installation assumes that paste runs as / app on site, but you can change it (BASEURL) in index.php.
Default installation assumes that paste runs as / app on site, but you can change it (BASEURL) in app.ini.
#### Settings for paste mode ####
edit app.ini and set correct address, base url, db path, application type (type = paste)
Nginx config snippet:
```
@@ -43,7 +49,39 @@ location / {
}
```
Database initialises automatically :)
Database initializes automatically :)
#### Settings for link shortener mode ####
edit app.ini and set correct address, base url, db path, application type (type = short)
Nginx config snippet:
```
# limit links size to ~ 50k
client_max_body_size 64k;
rewrite "^/([a-z|A-Z]*)$" /index.php?$1;
location / {
root /var/www/htdocs/empty;
index index.php;
location ~ \.php$ {
if ($request_method !~ ^(GET|HEAD|POST)$ ) {
return 499;
}
root /var/www/htdocs;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_pass php;
}
}
```
Database initializes automatically :)
### Contribution guidelines ###
@@ -52,7 +90,7 @@ Clean code, preferably with comments for some quirky places.
### PasteBinIt configuration ###
default pastebin site, __~/.pastebinit.xml__:
```
```xml
<pastebinit>
<pastebin>http://your.site</pastebin>
<author>Stephane Graber</author>
@@ -61,7 +99,7 @@ default pastebin site, __~/.pastebinit.xml__:
</pastebinit>
```
and how to work with it __~/.pastebinit.d/your.site.conf__:
```
```ini
[pastebin]
basename = your.site
regexp = http://((([a-zA-Z0-9\-_\.]*)(your\.site)))
@@ -115,4 +153,11 @@ diff -ruN pastebin.com.conf your.site.conf
-page = /api/api_post.php
+page = /
regexp = (.*)
```
```
### TODO ###
* Make one app that shorten links, stores paste, stores pictures (yes! image hosting).
* Configurable features (not everyone wants all features enabled).
* Before implementing picture storage, there should be made authorization.
* Sane and clear API.