Skip to content

Commit f2292cc

Browse files
authored
Merge pull request #18 from Deric-W/dev
Dev
2 parents 566a4e5 + 6326fb3 commit f2292cc

File tree

9 files changed

+121
-6
lines changed

9 files changed

+121
-6
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The script is called either by the configuration of the web server or a shebang
3737
- automatic sending of headers with fallback: `Content-Type: text/html`
3838

3939
## Cache Handlers
40-
- are responsible for saveing/loading/renewing caches
40+
- are responsible for saving/loading/renewing caches
4141
- are python scripts with the following contents:
4242
- the `handler` class, wich takes the cache path and absolute file path as initialization parameters
4343
- the method `is_outdated`, wich returns True or False
@@ -46,9 +46,12 @@ The script is called either by the configuration of the web server or a shebang
4646
- the method `close`, wich does cleanup tasks
4747

4848
## Installation
49+
### Debian
50+
Use the Debian package
51+
### Other
4952
1. enable CGI for your web server
50-
2. drop pyhp.py somewhere and mark it as executable (make sure Python 3.4+ is installed)
51-
3. create /etc/pyhp.conf
52-
4. create the directories listed in pyhp.conf and drop the choosen cache handler (and maybe others) in the cache handler directory
53+
2. drop pyhp.py somewhere and mark it as executable (make sure Python 3.5+ is installed)
54+
3. download pyhp.conf and move it to `/etc`
55+
4. create `/lib/pyhp/cache_handlers` and drop the choosen cache handler (and maybe others) in the cache handler directory
5356

5457
Done! you can now use `.pyhp` files by adding a Shebang

TODO

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ session_gc
1616
session_encode
1717
session_decode
1818
$_SESSION
19+
20+
add handler for memcached (if not already submitted)
21+
add handler for redis (if not already submitted)
22+
23+
wait for suggestions

cache_handlers/files_mtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class handler:
1010
def __init__(self, cache_path, file_path):
11-
self.cache_path = os.path.join(cache_path, file_path.strip(os.path.sep) + ".cache") # use full path to allow indentical named files in different directories with cache_path as root
11+
self.cache_path = os.path.join(os.path.expanduser(cache_path), file_path.strip(os.path.sep) + ".cache") # use full path to allow indentical named files in different directories with cache_path as root
1212
self.file_path = file_path
1313

1414
def is_outdated(self): # return True if cache is not created or needs refresh

debian/changelog

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
pyhp (1.2-1) stable; urgency=low
2+
3+
* third release
4+
* add support for ~ as home directory in cache_path
5+
* add debian package
6+
7+
-- Eric Wolf <[email protected]> Tue, 13 Aug 2019 18:07:00 +0100
8+
9+
pyhp (1.1-1) stable; urgency=low
10+
11+
* second release
12+
* add register_shutdown_function
13+
* add header_register_callback
14+
* add config
15+
* reworked caching to use handlers (old code as files_mtime handler)
16+
* reworked caching to use handlers (old code as files_mtime handler)
17+
* reworked prepare file
18+
* now using argparse
19+
* changed directory structure (see pyhp.conf)
20+
21+
-- Eric Wolf <[email protected]> Sat, 03 Aug 2019 15:30:00 +0100
22+
23+
pyhp (1.0-1) stable; urgency=low
24+
25+
* first release
26+
* add basic functionality
27+
28+
-- Eric Wolf <[email protected]> Sat, 29 Jun 2019 19:00:00 +0100

debian/conffiles

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/etc/pyhp.conf

debian/control

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Package: pyhp
2+
Version: 1.2-1
3+
Architecture: all
4+
Maintainer: Eric Wolf <[email protected]>
5+
Installed-Size: 21
6+
Depends: python3:any (>= 3.5)
7+
Suggests: apache2
8+
Section: web
9+
Priority: optional
10+
Homepage: https://github.com/Deric-W/PyHP-Interpreter
11+
Description: Interprets and executes pyhp files.
12+
PyHP is a script for interpreting and executing pyhp files, with several PHP functions available.
13+
pyhp files are (mostly) HTML files that have embedded Python source code and can be used for creating dynamic web pages.

debian/copyright

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2+
Upstream-Name: pyhp
3+
Upstream-Contact: Eric Wolf <[email protected]>
4+
Source: https://github.com/Deric-W/PyHP-Interpreter
5+
Copyright: 2019 Eric Wolf
6+
License: Expat
7+
8+
Files: *
9+
Copyright: 2019 Eric Wolf
10+
License: Expat

debian/deb_builder.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
echo "Name of package?"
2+
read package
3+
mkdir $package
4+
5+
mkdir $package/etc
6+
wget -nv -O $package/etc/pyhp.conf --tries=3 https://raw.githubusercontent.com/Deric-W/PyHP-Interpreter/master/pyhp.conf
7+
chown root $package/etc/pyhp.conf
8+
chgrp root $package/etc/pyhp.conf
9+
10+
mkdir $package/lib
11+
mkdir $package/lib/pyhp
12+
mkdir $package/lib/pyhp/cache_handlers
13+
wget -nv -O $package/lib/pyhp/cache_handlers/files_mtime.py --tries=3 https://raw.githubusercontent.com/Deric-W/PyHP-Interpreter/master/cache_handlers/files_mtime.py
14+
chown root $package/lib/pyhp/cache_handlers/files_mtime.py
15+
chgrp root $package/lib/pyhp/cache_handlers/files_mtime.py
16+
17+
mkdir $package/usr
18+
mkdir $package/usr/bin
19+
wget -nv -O $package/usr/bin/pyhp --tries=3 https://raw.githubusercontent.com/Deric-W/PyHP-Interpreter/master/pyhp.py
20+
chown root $package/usr/bin/pyhp
21+
chgrp root $package/usr/bin/pyhp
22+
chmod +x $package/usr/bin/pyhp
23+
24+
mkdir $package/DEBIAN
25+
wget -nv -O $package/DEBIAN/control --tries=3 https://raw.githubusercontent.com/Deric-W/PyHP-Interpreter/master/debian/control
26+
chown root $package/DEBIAN/control
27+
chgrp root $package/DEBIAN/control
28+
29+
wget -nv -O $package/DEBIAN/conffiles --tries=3 https://raw.githubusercontent.com/Deric-W/PyHP-Interpreter/master/debian/conffiles
30+
chown root $package/DEBIAN/conffiles
31+
chgrp root $package/DEBIAN/conffiles
32+
33+
mkdir $package/usr/share
34+
mkdir $package/usr/share/doc
35+
mkdir $package/usr/share/doc/pyhp
36+
wget -nv -O $package/usr/share/doc/pyhp/copyright --tries=3 https://raw.githubusercontent.com/Deric-W/PyHP-Interpreter/master/debian/copyright
37+
chown root $package/usr/share/doc/pyhp/copyright
38+
chgrp root $package/usr/share/doc/pyhp/copyright
39+
40+
wget -nv -O $package/usr/share/doc/pyhp/changelog.Debian --tries=3 https://raw.githubusercontent.com/Deric-W/PyHP-Interpreter/master/debian/changelog
41+
gzip -n --best $package/usr/share/doc/pyhp/changelog.Debian
42+
chown root $package/usr/share/doc/pyhp/changelog.Debian.gz
43+
chgrp root $package/usr/share/doc/pyhp/changelog.Debian.gz
44+
45+
chdir $package
46+
md5sum etc/pyhp.conf >> DEBIAN/md5sums
47+
md5sum lib/pyhp/cache_handlers/files_mtime.py >> DEBIAN/md5sums
48+
md5sum usr/bin/pyhp >> DEBIAN/md5sums
49+
md5sum usr/share/doc/pyhp/copyright >> DEBIAN/md5sums
50+
md5sum usr/share/doc/pyhp/changelog.Debian.gz >> DEBIAN/md5sums
51+
chdir ../
52+
53+
dpkg-deb --build $package
54+
55+
rm -rf $package

pyhp.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ closing_tag = [\n \t]\?\> # regex
88
[caching]
99
allow_caching = True
1010
auto_caching = False # ignore -c arg
11-
cache_path = /var/cache/pyhp # path to use
11+
cache_path = ~/.pyhpcache # path to use
1212
handler = files_mtime
1313
handler_path = /lib/pyhp/cache_handlers # directory containing the handler

0 commit comments

Comments
 (0)