Mercurial > paster
changeset 67:1a6abb3ed16a
make: cleanup
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sat, 18 Jun 2022 17:32:09 +0200 |
parents | a14b5b7aa80e |
children | 87041e7df099 |
files | Makefile paster.1 paster.1.in pasterd-clean.8 pasterd-clean.8.in pasterd-themes.5 pasterd-themes.5.in pasterd.8 pasterd.8.in |
diffstat | 9 files changed, 642 insertions(+), 669 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Sat Jun 18 09:42:05 2022 +0200 +++ b/Makefile Sat Jun 18 17:32:09 2022 +0200 @@ -49,13 +49,12 @@ page.c \ paste.c \ util.c -CORE_HDRS= ${CORE_SRCS:.c=.h} CORE_OBJS= ${CORE_SRCS:.c=.o} -CORE_DEPS= ${CORE_SRCS:.c=.d} CORE_LIB= libpaster.a TESTS_SRCS= tests/test-database.c -TESTS_OBJS= ${TESTS_SRCS:.c=} +TESTS_OBJS= ${TESTS_SRCS:.c=.o} +TESTS= ${TESTS_SRCS:.c=} SQLITE_FLAGS= -DSQLITE_THREADSAFE=0 \ -DSQLITE_OMIT_LOAD_EXTENSION \ @@ -63,36 +62,28 @@ -DSQLITE_DEFAULT_FOREIGN_KEYS=1 SQLITE_LIB= libsqlite3.a -MY_CFLAGS= -std=c11 \ - -I . \ - -I extern \ - -D_XOPEN_SOURCE=700 \ - -DSHAREDIR=\"${SHAREDIR}\" \ - -DVARDIR=\"${VARDIR}\" \ - `pkg-config --cflags kcgi-html` +KCGI_INCS= `pkg-config --cflags kcgi kcgi-html` +KCGI_LIBS= `pkg-config --libs kcgi kcgi-html` -MY_LDFLAGS= `pkg-config --libs kcgi-html` +INCS= -I. -Iextern ${KCGI_INCS} +DEFS= -D_POSIX_C_SOURCE=200809L -DVARDIR=\"${VARDIR}\" -DSHAREDIR=\"${SHAREDIR}\" +LIBS= ${KCGI_LIBS} +SED= sed -e "s|@SHAREDIR@|${SHAREDIR}|" \ + -e "s|@VARDIR@|${VARDIR}|" .SUFFIXES: -.SUFFIXES: .o .c .in +.SUFFIXES: .o .c .sh all: pasterd pasterd-clean paster --include ${CORE_DEPS} paster.d pasterd-clean.d - .c.o: - ${CC} ${MY_CFLAGS} ${CFLAGS} -MMD -c $< - -.c: - ${CC} ${MY_CFLAGS} ${CFLAGS} -MMD $< -o $@ ${CORE_LIB} ${SQLITE_LIB} ${MY_LDFLAGS} ${LDFLAGS} + ${CC} ${INCS} ${DEFS} ${CFLAGS} -c $< -o $@ .o: - ${CC} ${MY_CFLAGS} ${CFLAGS} -MMD $< -o $@ ${CORE_LIB} ${SQLITE_LIB} ${MY_LDFLAGS} ${LDFLAGS} + ${CC} ${INCS} ${DEFS} ${CFLAGS} $< -o $@ ${CORE_LIB} ${SQLITE_LIB} ${LIBS} ${LDFLAGS} -.in: - sed -e "s|@SHAREDIR@|${SHAREDIR}|" \ - -e "s|@VARDIR@|${VARDIR}|" \ - < $< > $@ +.sh: + ${SED} < $< > $@ ${SQLITE_LIB}: extern/sqlite3.c extern/sqlite3.h ${CC} ${CFLAGS} ${SQLITE_FLAGS} -c extern/sqlite3.c -o extern/sqlite3.o @@ -101,20 +92,16 @@ ${CORE_LIB}: ${CORE_OBJS} ${AR} -rc $@ ${CORE_OBJS} -pasterd.o: ${CORE_LIB} ${SQLITE_LIB} pasterd.8 pasterd-themes.5 - -pasterd-clean.o: ${CORE_LIB} ${SQLITE_LIB} pasterd-clean.8 - -paster: paster.sh paster.1 +paster: paster.sh cp paster.sh paster chmod +x paster +pasterd.o pasterd-clean.o: ${CORE_LIB} ${SQLITE_LIB} + clean: rm -f ${SQLITE_LIB} extern/sqlite3.o - rm -f ${CORE_LIB} ${CORE_OBJS} ${CORE_DEPS} - rm -f pasterd pasterd.d pasterd.o pasterd.8 - rm -f pasterd-clean pasterd-clean.d pasterd-clean.o pasterd-clean.8 - rm -f paster paster.1 + rm -f ${CORE_LIB} ${CORE_OBJS} + rm -f paster pasterd-clean pasterd rm -f test.db ${TESTS_OBJS} install-paster: @@ -122,7 +109,7 @@ mkdir -p ${DESTDIR}${MANDIR}/man1 cp paster ${DESTDIR}${BINDIR} chmod 755 ${DESTDIR}${BINDIR}/paster - cp paster.1 ${DESTDIR}${MANDIR}/man1 + ${SED} < paster.1 > ${DESTDIR}${MANDIR}/man1/paster.1 install-pasterd: mkdir -p ${DESTDIR}${BINDIR} @@ -132,29 +119,15 @@ cp pasterd-clean ${DESTDIR}${BINDIR} mkdir -p ${DESTDIR}${SHAREDIR}/paster cp -R themes ${DESTDIR}${SHAREDIR}/paster - cp pasterd.8 ${DESTDIR}${MANDIR}/man8 - cp pasterd-clean.8 ${DESTDIR}${MANDIR}/man8 - cp pasterd-themes.5 ${DESTDIR}${MANDIR}/man5 + ${SED} < pasterd.8 > ${DESTDIR}${MANDIR}/man8/pasterd.8 + ${SED} < pasterd-clean.8 > ${DESTDIR}${MANDIR}/man8/pasterd-clean.8 + ${SED} < pasterd-themes.5 > ${DESTDIR}${MANDIR}/man5/pasterd-themes.5 install: install-pasterd install-paster -dist: - mkdir -p paster-${VERSION} - cp -R extern paster-${VERSION} - cp -R themes paster-${VERSION} - cp -R tests paster-${VERSION} - cp ${CORE_SRCS} ${CORE_HDRS} paster-${VERSION} - cp pasterd.8.in pasterd.c paster-${VERSION} - cp pasterd-clean.8.in pasterd-clean.c paster-${VERSION} - cp paster.1.in paster.sh paster-${VERSION} - cp Makefile CHANGES.md CONTRIBUTE.md CREDITS.md INSTALL.md LICENSE.md \ - README.md STYLE.md TODO.md paster-${VERSION} - tar -cJf paster-${VERSION}.tar.xz paster-${VERSION} - rm -rf paster-${VERSION} - ${TESTS_OBJS}: ${CORE_LIB} ${SQLITE_LIB} -tests: ${TESTS_OBJS} - for t in ${TESTS_OBJS}; do $$t; done +tests: ${TESTS} + for t in ${TESTS}; do $$t; done -.PHONY: all clean dist run tests +.PHONY: all clean tests
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/paster.1 Sat Jun 18 17:32:09 2022 +0200 @@ -0,0 +1,95 @@ +.\" +.\" Copyright (c) 2020-2022 David Demelier <markand@malikania.fr> +.\" +.\" Permission to use, copy, modify, and/or distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd 06 February, 2020 +.Dt PASTER 1 +.Os +.\" NAME +.Sh NAME +.Nm paster +.Nd simple paste service client +.\" SYNOPSIS +.Sh SYNOPSIS +.Nm +.Op Fl LDpv +.Op Fl a Ar author +.Op Fl l Ar language +.Op Fl d Ar duration +.Op Fl t Ar title +.Ar filename +.Ar host +.\" DESCRIPTION +.Sh DESCRIPTION +The +.Nm +tool is the convenient brother to +.Nm pasterd , +it will paste some content into an instance. +.Pp +The +.Ar filename +argument can points to a file whose content will be pasted, if it is set to +.Dq - +then standard input is read instead. +.Pp +The +.Ar host +argument is a URL where a +.Nm pasterd +instance is running. +.Pp +Available options: +.Bl -tag -width Ds +.It Fl L +List all supported languages. +.It Fl D +List all supported durations. +.It Fl p +Store the paste as public (default is private). +.It Fl v +Be more verbose. +.It Fl a Ar author +Sets the author, defaults to +.Dq Anonymous . +.It Fl l Ar language +Sets the code snippet language, defaults to +.Dq "nohighlight" . +.It Fl d Ar duration +Sets the paste lifetime, defaults to +.Dq "day" . +.It Fl t Ar title +Sets a title to the paste, defaults to +.Dq "Untitled" . +.\" EXAMPLES +.Sh EXAMPLES +.Ss Paste the main.sh script shell with a title and an author. +.Bd -literal -offset +paster -t "Some shell script" -a Francis -l shell main.sh http://example.org +.Ed +.Ss Read standard input and paste it. +.Bd -literal -offset +grep error logs.txt | paster - http://example.org +.Ed +.Ss Paste a public file file with a short duration. +.Bd -literal -offset +paster -p -d hour some-data.txt http://example.org +.Ed +.\" AUTHORS +.Sh AUTHORS +.Nm +was written by David Demelier <markand@malikania.fr> +.\" SEE ALSO +.Sh SEE ALSO +.Xr pasterd 8
--- a/paster.1.in Sat Jun 18 09:42:05 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,95 +0,0 @@ -.\" -.\" Copyright (c) 2020-2022 David Demelier <markand@malikania.fr> -.\" -.\" Permission to use, copy, modify, and/or distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.\" -.Dd 06 February, 2020 -.Dt PASTER 1 -.Os -.\" NAME -.Sh NAME -.Nm paster -.Nd simple paste service client -.\" SYNOPSIS -.Sh SYNOPSIS -.Nm -.Op Fl LDpv -.Op Fl a Ar author -.Op Fl l Ar language -.Op Fl d Ar duration -.Op Fl t Ar title -.Ar filename -.Ar host -.\" DESCRIPTION -.Sh DESCRIPTION -The -.Nm -tool is the convenient brother to -.Nm pasterd , -it will paste some content into an instance. -.Pp -The -.Ar filename -argument can points to a file whose content will be pasted, if it is set to -.Dq - -then standard input is read instead. -.Pp -The -.Ar host -argument is a URL where a -.Nm pasterd -instance is running. -.Pp -Available options: -.Bl -tag -width Ds -.It Fl L -List all supported languages. -.It Fl D -List all supported durations. -.It Fl p -Store the paste as public (default is private). -.It Fl v -Be more verbose. -.It Fl a Ar author -Sets the author, defaults to -.Dq Anonymous . -.It Fl l Ar language -Sets the code snippet language, defaults to -.Dq "nohighlight" . -.It Fl d Ar duration -Sets the paste lifetime, defaults to -.Dq "day" . -.It Fl t Ar title -Sets a title to the paste, defaults to -.Dq "Untitled" . -.\" EXAMPLES -.Sh EXAMPLES -.Ss Paste the main.sh script shell with a title and an author. -.Bd -literal -offset -paster -t "Some shell script" -a Francis -l shell main.sh http://example.org -.Ed -.Ss Read standard input and paste it. -.Bd -literal -offset -grep error logs.txt | paster - http://example.org -.Ed -.Ss Paste a public file file with a short duration. -.Bd -literal -offset -paster -p -d hour some-data.txt http://example.org -.Ed -.\" AUTHORS -.Sh AUTHORS -.Nm -was written by David Demelier <markand@malikania.fr> -.\" SEE ALSO -.Sh SEE ALSO -.Xr pasterd 8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pasterd-clean.8 Sat Jun 18 17:32:09 2022 +0200 @@ -0,0 +1,67 @@ +.\" +.\" Copyright (c) 2020-2022 David Demelier <markand@malikania.fr> +.\" +.\" Permission to use, copy, modify, and/or distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd 06 February, 2020 +.Dt PASTERD-CLEAN 8 +.Os +.\" NAME +.Sh NAME +.Nm pasterd-clean +.Nd simple paste service cleaner +.\" SYNOPSIS +.Sh SYNOPSIS +.Nm +.Op Fl d Ar database-path +.\" DESCRIPTION +.Sh DESCRIPTION +This utility should be used at periodic intervals to clean up the SQLite +database. It will remove deprecated pastes. +.Pp +Like +.Xr pasterd 8 +it can use environment variables or option to specify the database. +.Pp +Available options: +.Bl -tag -width Ds +.It Fl d Ar database-path +Specify an alternate path for the database. +.El +.\" USAGE +.Sh USAGE +This command should be placed in a cron job (or equivalent) at periodic +intervals. Since the minimal lifetime for a paste is one hour a periodic job +every hour seems appropriate. +.Pp +Note: make sure to run the cron job in the same user as the pasterd service, +otherwise you may change file permissions. +.Pp +Example of cron job: +.Bd -literal -offset Ds +0 * * * * www pasterd-clean -d /var/paster/paster.db +.Ed +.\" ENVIRONMENT +.Sh ENVIRONMENT +The following environment variables are detected: +.Bl -tag -width Ds +.It Va PASTERD_DATABASE_PATH No (string) +Path to the SQLite database. +.El +.\" AUTHORS +.Sh AUTHORS +.Nm +was written by David Demelier <markand@malikania.fr> +.\" SEE ALSO +.Sh SEE ALSO +.Xr pasterd 8
--- a/pasterd-clean.8.in Sat Jun 18 09:42:05 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -.\" -.\" Copyright (c) 2020-2022 David Demelier <markand@malikania.fr> -.\" -.\" Permission to use, copy, modify, and/or distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.\" -.Dd 06 February, 2020 -.Dt PASTERD-CLEAN 8 -.Os -.\" NAME -.Sh NAME -.Nm pasterd-clean -.Nd simple paste service cleaner -.\" SYNOPSIS -.Sh SYNOPSIS -.Nm -.Op Fl d Ar database-path -.\" DESCRIPTION -.Sh DESCRIPTION -This utility should be used at periodic intervals to clean up the SQLite -database. It will remove deprecated pastes. -.Pp -Like -.Xr pasterd 8 -it can use environment variables or option to specify the database. -.Pp -Available options: -.Bl -tag -width Ds -.It Fl d Ar database-path -Specify an alternate path for the database. -.El -.\" USAGE -.Sh USAGE -This command should be placed in a cron job (or equivalent) at periodic -intervals. Since the minimal lifetime for a paste is one hour a periodic job -every hour seems appropriate. -.Pp -Note: make sure to run the cron job in the same user as the pasterd service, -otherwise you may change file permissions. -.Pp -Example of cron job: -.Bd -literal -offset Ds -0 * * * * www pasterd-clean -d /var/paster/paster.db -.Ed -.\" ENVIRONMENT -.Sh ENVIRONMENT -The following environment variables are detected: -.Bl -tag -width Ds -.It Va PASTERD_DATABASE_PATH No (string) -Path to the SQLite database. -.El -.\" AUTHORS -.Sh AUTHORS -.Nm -was written by David Demelier <markand@malikania.fr> -.\" SEE ALSO -.Sh SEE ALSO -.Xr pasterd 8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pasterd-themes.5 Sat Jun 18 17:32:09 2022 +0200 @@ -0,0 +1,245 @@ +.\" +.\" Copyright (c) 2020-2022 David Demelier <markand@malikania.fr> +.\" +.\" Permission to use, copy, modify, and/or distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd 25 November, 2020 +.Dt PASTERD-THEMES 5 +.Os +.\" NAME +.Sh NAME +.Nm pasterd-themes +.Nd themes for pasterd +.\" DESCRIPTION +.Sh DESCRIPTION +This manual page describes the file hierarchy and syntax required to create a +new theme for +.Nm pasterd . +.Pp +A theme consists of fragments and pages. A fragment is a piece of HTML code that +may be repeated while a page is usually the HTML code that is inside the +.Dq <body></body> +HTML tag. +.\" THEME STRUCTURE +.Sh THEME STRUCTURE +The easiest way to create a new theme is to copy the predefined +.Pa minimal +theme and adapt the files to the desired style. See it in +@SHAREDIR@/paster/themes/minimal. +.Pp +The following files must be provided into a directory: +.Bd -literal -offset indent +theme/fragments/duration.html +theme/fragments/language.html +theme/fragments/footer.html +theme/fragments/header.html +theme/fragments/paste.html +theme/pages/400.html +theme/pages/404.html +theme/pages/500.html +theme/pages/paste.html +theme/pages/index.html +theme/pages/new.html +theme/pages/search.html +.Ed +.Pp +A special +.Pa static +directory into the theme can be used to provide non templates data such as +images, Javascript and CSS files. They are not processed and provided as-is. +.Pp +See below for a description per file. +.\" KEYWORDS +.Sh KEYWORDS +Templates files may contain keywords that are replaced during processing using +the syntax +.Dq @@variable@@ . +.Pp +The following keywords are supported: +.Bl -tag -width 10n +.It Va author +The paste author. +.It Va date +Date as a string. +.It Va duration +Duration expressed as a string. May be +.Dq hour , +.Dq day , +.Dq week , +.Dq month . +.It Va durations +Fragment repeated for every duration supported using +.Pa fragments/duration.html +template. +.It Va language +The paste language type. +.It Va languages +Fragment repeated for every language supported using +.Pa fragments/language.html +template. +.It Va expiration +The time left for the paste expressed as minutes, hours or days depending on the +time left. +.It Va id +Unique paste indentifier. +.It Va pastes +Fragment repeated for every paste using +.Pa fragments/paste.html +template. +.It Va public +String set to +.Dq Yes +if public or +.Dq \&No +otherwise. +.It Va title +When used within header fragment, page's title otherwise paste's title. +.El +.\" PAGES AND FRAGMENTS +.Sh PAGES AND FRAGMENTS +.\" fragments/duration.html +.Ss fragments/duration.html +A fragment that should generate a +.Dq <select> +option for the given duration. +.Pp +Supported keywords: +.Bl -bullet -compact +.It +.Va duration +.El +.\" fragments/footer.html +.Ss fragments/footer.html +Fragment applied at the end of a page. +.\" fragments/header.html +.Ss fragments/header.html +Fragment applied at the beginning of a page. +.Pp +Supported keywords: +.Bl -bullet -compact +.It +.Va title +.El +.\" fragments/language.html +.Ss fragments/language.html +A fragment that should generate a +.Dq <select> +option for the given language. +.Pp +Supported keywords: +.Bl -bullet -compact +.It +.Va language +.El +.\" fragments/paste.html +.Ss fragments/paste.html +Repeated fragment in the +.Pa pages/index.html +page. +.Pp +Supported keywords: +.Bl -bullet -compact +.It +.Va id +.It +.Va title +.It +.Va author +.It +.Va date +.It +.Va expiration +.It +.Va language +.El +.Ss pages/400.html +.Ss pages/404.html +.Ss pages/500.html +Those pages are used to indicate an error that are generated from +.Nm pasterd . +.\" pages/index.html +.Ss pages/index.html +This page is the landing of the +.Nm pasterd +program. It should provide a list of last recents paste. +.Pp +Supported keywords: +.Bl -bullet -compact +.It +.Va pastes +.El +.\" pages/paste.html +.Ss pages/paste.html +Details of a paste. +.Pp +Supported keywords: +.Bl -bullet -compact +.It +.Va author +.It +.Va code +.It +.Va date +.It +.Va expiration +.It +.Va id +.It +.Va public +.It +.Va title +.El +.\" pages/new.html +.Ss pages/new.html +Create a form for sending a new paste. The form should submit a POST request to +the same page with the following field data: +.Pp +.Bl -tag -width 10n +.It Va author +Paste author. +.It Va code +The code content. +.It Va duration +Paste duration (should use +.Dq durations +keyword). +.It Va language +The code language (should use +.Dq languages +keyword). +.It Va title +Paste title. +.El +.Pp +Supported keywords: +.Bl -bullet -compact +.It +.Va durations +.It +.Va languages +.El +.\" pages/search.html +.Ss pages/search.html +Create a form for searching pastes. The form should submit a POST request to +the same page with the following field data: +.Bl -tag +.It Va author +Author of paste. +.It Va language +Paste language. +.It Va title +Title to search +.El +.\" SEE ALSO +.Sh SEE ALSO +.Xr pasterd 8
--- a/pasterd-themes.5.in Sat Jun 18 09:42:05 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,245 +0,0 @@ -.\" -.\" Copyright (c) 2020-2022 David Demelier <markand@malikania.fr> -.\" -.\" Permission to use, copy, modify, and/or distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.\" -.Dd 25 November, 2020 -.Dt PASTERD-THEMES 5 -.Os -.\" NAME -.Sh NAME -.Nm pasterd-themes -.Nd themes for pasterd -.\" DESCRIPTION -.Sh DESCRIPTION -This manual page describes the file hierarchy and syntax required to create a -new theme for -.Nm pasterd . -.Pp -A theme consists of fragments and pages. A fragment is a piece of HTML code that -may be repeated while a page is usually the HTML code that is inside the -.Dq <body></body> -HTML tag. -.\" THEME STRUCTURE -.Sh THEME STRUCTURE -The easiest way to create a new theme is to copy the predefined -.Pa minimal -theme and adapt the files to the desired style. See it in -@SHAREDIR@/paster/themes/minimal. -.Pp -The following files must be provided into a directory: -.Bd -literal -offset indent -theme/fragments/duration.html -theme/fragments/language.html -theme/fragments/footer.html -theme/fragments/header.html -theme/fragments/paste.html -theme/pages/400.html -theme/pages/404.html -theme/pages/500.html -theme/pages/paste.html -theme/pages/index.html -theme/pages/new.html -theme/pages/search.html -.Ed -.Pp -A special -.Pa static -directory into the theme can be used to provide non templates data such as -images, Javascript and CSS files. They are not processed and provided as-is. -.Pp -See below for a description per file. -.\" KEYWORDS -.Sh KEYWORDS -Templates files may contain keywords that are replaced during processing using -the syntax -.Dq @@variable@@ . -.Pp -The following keywords are supported: -.Bl -tag -width 10n -.It Va author -The paste author. -.It Va date -Date as a string. -.It Va duration -Duration expressed as a string. May be -.Dq hour , -.Dq day , -.Dq week , -.Dq month . -.It Va durations -Fragment repeated for every duration supported using -.Pa fragments/duration.html -template. -.It Va language -The paste language type. -.It Va languages -Fragment repeated for every language supported using -.Pa fragments/language.html -template. -.It Va expiration -The time left for the paste expressed as minutes, hours or days depending on the -time left. -.It Va id -Unique paste indentifier. -.It Va pastes -Fragment repeated for every paste using -.Pa fragments/paste.html -template. -.It Va public -String set to -.Dq Yes -if public or -.Dq \&No -otherwise. -.It Va title -When used within header fragment, page's title otherwise paste's title. -.El -.\" PAGES AND FRAGMENTS -.Sh PAGES AND FRAGMENTS -.\" fragments/duration.html -.Ss fragments/duration.html -A fragment that should generate a -.Dq <select> -option for the given duration. -.Pp -Supported keywords: -.Bl -bullet -compact -.It -.Va duration -.El -.\" fragments/footer.html -.Ss fragments/footer.html -Fragment applied at the end of a page. -.\" fragments/header.html -.Ss fragments/header.html -Fragment applied at the beginning of a page. -.Pp -Supported keywords: -.Bl -bullet -compact -.It -.Va title -.El -.\" fragments/language.html -.Ss fragments/language.html -A fragment that should generate a -.Dq <select> -option for the given language. -.Pp -Supported keywords: -.Bl -bullet -compact -.It -.Va language -.El -.\" fragments/paste.html -.Ss fragments/paste.html -Repeated fragment in the -.Pa pages/index.html -page. -.Pp -Supported keywords: -.Bl -bullet -compact -.It -.Va id -.It -.Va title -.It -.Va author -.It -.Va date -.It -.Va expiration -.It -.Va language -.El -.Ss pages/400.html -.Ss pages/404.html -.Ss pages/500.html -Those pages are used to indicate an error that are generated from -.Nm pasterd . -.\" pages/index.html -.Ss pages/index.html -This page is the landing of the -.Nm pasterd -program. It should provide a list of last recents paste. -.Pp -Supported keywords: -.Bl -bullet -compact -.It -.Va pastes -.El -.\" pages/paste.html -.Ss pages/paste.html -Details of a paste. -.Pp -Supported keywords: -.Bl -bullet -compact -.It -.Va author -.It -.Va code -.It -.Va date -.It -.Va expiration -.It -.Va id -.It -.Va public -.It -.Va title -.El -.\" pages/new.html -.Ss pages/new.html -Create a form for sending a new paste. The form should submit a POST request to -the same page with the following field data: -.Pp -.Bl -tag -width 10n -.It Va author -Paste author. -.It Va code -The code content. -.It Va duration -Paste duration (should use -.Dq durations -keyword). -.It Va language -The code language (should use -.Dq languages -keyword). -.It Va title -Paste title. -.El -.Pp -Supported keywords: -.Bl -bullet -compact -.It -.Va durations -.It -.Va languages -.El -.\" pages/search.html -.Ss pages/search.html -Create a form for searching pastes. The form should submit a POST request to -the same page with the following field data: -.Bl -tag -.It Va author -Author of paste. -.It Va language -Paste language. -.It Va title -Title to search -.El -.\" SEE ALSO -.Sh SEE ALSO -.Xr pasterd 8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pasterd.8 Sat Jun 18 17:32:09 2022 +0200 @@ -0,0 +1,209 @@ +.\" +.\" Copyright (c) 2020-2022 David Demelier <markand@malikania.fr> +.\" +.\" Permission to use, copy, modify, and/or distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd 06 February, 2020 +.Dt PASTERD 8 +.Os +.\" NAME +.Sh NAME +.Nm pasterd +.Nd simple paste service +.\" SYNOPSIS +.Sh SYNOPSIS +.Nm +.Op Fl fqv +.Op Fl d Ar database-path +.Op Fl t Ar theme-directory +.\" DESCRIPTION +.Sh DESCRIPTION +The +.Nm +utility is a simple CGI or FastCGI program to host code snippets over a web +interface. It will show most recent public pastes and let users to create new +one from a web form. +.Pp +It supports: +.Bl -bullet -compat +.It +Listing of recent pastes, +.It +Submission of new pastes, +.It +Searching existing pastes, +.It +Language highlighting (depending on the theme), +.It +Private pastes (not listed). +.El +.Pp +To store pastes, +.Nm +uses a SQLite database that must be writable by the CGI/FastCGI owner. See usage +below. +.Pp +Available options: +.Bl -tag -width Ds +.It Fl f +Starts as FastCGI mode, +.Nm +will wait forever for new requests. +.It Fl d Ar database-path +Specify an alternate path for the database. +.It Fl t Ar theme-directory +Specify an alternate directory for the theme. +.It Fl q +Do not log through syslog at all. +.It Fl v +Increase verbosity level. +.El +.\" USAGE +.Sh USAGE +The +.Nm +utility does not use configuration file as it does not need many adjustments, +instead every parameter could be passed by environment variables or options. +.Pp +By default, +.Nm +will try to use +.Pa @VARDIR@/paster/paster.db +database. +.\" LOGS +.Sh LOGS +The +.Nm +utility will log information through syslog unless verbosity is disabled. +Except at startup where the tool can write to stderr some information if it +can't continue processing, the tool will never write anything to stdout and +use syslog only. +.Pp +The available verbosity level is defined in the following order: +.Bd -literal -offset Ds +none < warnings (default) < info < debug +.Ed +.Pp +Use +.Fl q +or +.Va PASTERD_VERBOSITY=0 +if you want to disable syslog completely. +.\" USING WITH FASTCGI +.Sh USING WITH FASTCGI +The recommended way to use +.Nm +is to deploy using FastCGI. You can use the +.Xr kfcgi 8 +helper to spawn the process for you. +.Pp +Example: +.Bd -literal -offset Ds +kfcgi -p /var/www/paster -- pasterd -f -d paster.db -t siimple +.Ed +.Pp +Note: kfcgi chroot to the directory given, you must either statically link +pasterd at build time or deploy all required libraries. Also, themes directory +will need to be available in the chroot directory. In the above example, this +will effectively create a database +.Pa /var/www/paster/paster.db +and use the theme +.Pa /var/www/paster/siimple . +.Pp +Then, simply copy the desired theme into the directory. +.Bd -literal -offset Ds +cp -R @SHAREDIR@/paster/themes/siimple /var/www/paster +.Ed +.Pp +As an +.Em insecure +alternative, you can chroot to +.Pa / +to avoid static-linking and copying themes, using: +.Bd -literal -offset Ds +kfcgi -p / -- pasterd -f \e + -d /var/www/paster/paster.db \e + -t @SHAREDIR@/paster/themes/siimple +.Ed +.Pp +Both kfcgi invocations will create +.Pa /var/www/run/http.sock +with current user and group. Configure the web server to talk to that socket +and make sure it has appropriate file permissions otherwise see +.Fl u +option in +.Nm kfcgi . +See also the +.Xr kfcgi 8 +manual for more information. +.Pp +Next, configure the web server. +.Pp +Warning: at this moment, +.Nm +requires its own virtual host and can +.Em not +use a url. +.\" Server: nginx +.Ss Server: nginx +The nginx web server requires several parameters to run +.Nm . +.Bd -literal +server { + server_name mypaste.fr; + listen 80; + + location / { + fastcgi_param QUERY_STRING query_string; + fastcgi_param REQUEST_METHOD $request_method; + fastcgi_param CONTENT_TYPE $content_type; + fastcgi_param CONTENT_LENGTH $content_length; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param SCRIPT_NAME $fastcgi_script_name; + fastcgi_param PATH_INFO $document_uri; + fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; + fastcgi_param REQUEST_URI $request_uri; + fastcgi_param DOCUMENT_URI $document_uri; + fastcgi_param DOCUMENT_ROOT $document_root; + fastcgi_param SERVER_PROTOCOL $server_protocol; + fastcgi_param GATEWAY_INTERFACE CGI/1.1; + fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; + fastcgi_param REMOTE_ADDR $remote_addr; + fastcgi_param REMOTE_PORT $remote_port; + fastcgi_param SERVER_ADDR $server_addr; + fastcgi_param SERVER_PORT $server_port; + fastcgi_param SERVER_NAME $server_name; + fastcgi_param HTTPS $https; + fastcgi_pass unix:/var/www/run/httpd.sock; + } +} +.Ed +.\" ENVIRONMENT +.Sh ENVIRONMENT +The following environment variables are detected: +.Bl -tag -width Ds +.It Va PASTERD_DATABASE_PATH No (string) +Path to the SQLite database. +.It Va PASTERD_THEME_DIR No (string) +Directory containing the theme. +.It Va PASTERD_VERBOSITY No (number) +Verbosity level, 0 to disable completely. +.El +.\" AUTHORS +.Sh AUTHORS +.Nm +was written by David Demelier <markand@malikania.fr> +.\" SEE ALSO +.Sh SEE ALSO +.Xr paster 8 , +.Xr kfcgi 8
--- a/pasterd.8.in Sat Jun 18 09:42:05 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,209 +0,0 @@ -.\" -.\" Copyright (c) 2020-2022 David Demelier <markand@malikania.fr> -.\" -.\" Permission to use, copy, modify, and/or distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.\" -.Dd 06 February, 2020 -.Dt PASTERD 8 -.Os -.\" NAME -.Sh NAME -.Nm pasterd -.Nd simple paste service -.\" SYNOPSIS -.Sh SYNOPSIS -.Nm -.Op Fl fqv -.Op Fl d Ar database-path -.Op Fl t Ar theme-directory -.\" DESCRIPTION -.Sh DESCRIPTION -The -.Nm -utility is a simple CGI or FastCGI program to host code snippets over a web -interface. It will show most recent public pastes and let users to create new -one from a web form. -.Pp -It supports: -.Bl -bullet -compat -.It -Listing of recent pastes, -.It -Submission of new pastes, -.It -Searching existing pastes, -.It -Language highlighting (depending on the theme), -.It -Private pastes (not listed). -.El -.Pp -To store pastes, -.Nm -uses a SQLite database that must be writable by the CGI/FastCGI owner. See usage -below. -.Pp -Available options: -.Bl -tag -width Ds -.It Fl f -Starts as FastCGI mode, -.Nm -will wait forever for new requests. -.It Fl d Ar database-path -Specify an alternate path for the database. -.It Fl t Ar theme-directory -Specify an alternate directory for the theme. -.It Fl q -Do not log through syslog at all. -.It Fl v -Increase verbosity level. -.El -.\" USAGE -.Sh USAGE -The -.Nm -utility does not use configuration file as it does not need many adjustments, -instead every parameter could be passed by environment variables or options. -.Pp -By default, -.Nm -will try to use -.Pa @VARDIR@/paster/paster.db -database. -.\" LOGS -.Sh LOGS -The -.Nm -utility will log information through syslog unless verbosity is disabled. -Except at startup where the tool can write to stderr some information if it -can't continue processing, the tool will never write anything to stdout and -use syslog only. -.Pp -The available verbosity level is defined in the following order: -.Bd -literal -offset Ds -none < warnings (default) < info < debug -.Ed -.Pp -Use -.Fl q -or -.Va PASTERD_VERBOSITY=0 -if you want to disable syslog completely. -.\" USING WITH FASTCGI -.Sh USING WITH FASTCGI -The recommended way to use -.Nm -is to deploy using FastCGI. You can use the -.Xr kfcgi 8 -helper to spawn the process for you. -.Pp -Example: -.Bd -literal -offset Ds -kfcgi -p /var/www/paster -- pasterd -f -d paster.db -t siimple -.Ed -.Pp -Note: kfcgi chroot to the directory given, you must either statically link -pasterd at build time or deploy all required libraries. Also, themes directory -will need to be available in the chroot directory. In the above example, this -will effectively create a database -.Pa /var/www/paster/paster.db -and use the theme -.Pa /var/www/paster/siimple . -.Pp -Then, simply copy the desired theme into the directory. -.Bd -literal -offset Ds -cp -R @SHAREDIR@/paster/themes/siimple /var/www/paster -.Ed -.Pp -As an -.Em insecure -alternative, you can chroot to -.Pa / -to avoid static-linking and copying themes, using: -.Bd -literal -offset Ds -kfcgi -p / -- pasterd -f \e - -d /var/www/paster/paster.db \e - -t @SHAREDIR@/paster/themes/siimple -.Ed -.Pp -Both kfcgi invocations will create -.Pa /var/www/run/http.sock -with current user and group. Configure the web server to talk to that socket -and make sure it has appropriate file permissions otherwise see -.Fl u -option in -.Nm kfcgi . -See also the -.Xr kfcgi 8 -manual for more information. -.Pp -Next, configure the web server. -.Pp -Warning: at this moment, -.Nm -requires its own virtual host and can -.Em not -use a url. -.\" Server: nginx -.Ss Server: nginx -The nginx web server requires several parameters to run -.Nm . -.Bd -literal -server { - server_name mypaste.fr; - listen 80; - - location / { - fastcgi_param QUERY_STRING query_string; - fastcgi_param REQUEST_METHOD $request_method; - fastcgi_param CONTENT_TYPE $content_type; - fastcgi_param CONTENT_LENGTH $content_length; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param SCRIPT_NAME $fastcgi_script_name; - fastcgi_param PATH_INFO $document_uri; - fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; - fastcgi_param REQUEST_URI $request_uri; - fastcgi_param DOCUMENT_URI $document_uri; - fastcgi_param DOCUMENT_ROOT $document_root; - fastcgi_param SERVER_PROTOCOL $server_protocol; - fastcgi_param GATEWAY_INTERFACE CGI/1.1; - fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; - fastcgi_param REMOTE_ADDR $remote_addr; - fastcgi_param REMOTE_PORT $remote_port; - fastcgi_param SERVER_ADDR $server_addr; - fastcgi_param SERVER_PORT $server_port; - fastcgi_param SERVER_NAME $server_name; - fastcgi_param HTTPS $https; - fastcgi_pass unix:/var/www/run/httpd.sock; - } -} -.Ed -.\" ENVIRONMENT -.Sh ENVIRONMENT -The following environment variables are detected: -.Bl -tag -width Ds -.It Va PASTERD_DATABASE_PATH No (string) -Path to the SQLite database. -.It Va PASTERD_THEME_DIR No (string) -Directory containing the theme. -.It Va PASTERD_VERBOSITY No (number) -Verbosity level, 0 to disable completely. -.El -.\" AUTHORS -.Sh AUTHORS -.Nm -was written by David Demelier <markand@malikania.fr> -.\" SEE ALSO -.Sh SEE ALSO -.Xr paster 8 , -.Xr kfcgi 8