Skip to content

Commit

Permalink
Merge pull request #18 from Deric-W/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Deric-W authored Aug 13, 2019
2 parents 566a4e5 + 6326fb3 commit f2292cc
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 6 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ The script is called either by the configuration of the web server or a shebang
- automatic sending of headers with fallback: `Content-Type: text/html`

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

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

Done! you can now use `.pyhp` files by adding a Shebang
5 changes: 5 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ session_gc
session_encode
session_decode
$_SESSION

add handler for memcached (if not already submitted)
add handler for redis (if not already submitted)

wait for suggestions
2 changes: 1 addition & 1 deletion cache_handlers/files_mtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class handler:
def __init__(self, cache_path, file_path):
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
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
self.file_path = file_path

def is_outdated(self): # return True if cache is not created or needs refresh
Expand Down
28 changes: 28 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
pyhp (1.2-1) stable; urgency=low

* third release
* add support for ~ as home directory in cache_path
* add debian package

-- Eric Wolf <[email protected]> Tue, 13 Aug 2019 18:07:00 +0100

pyhp (1.1-1) stable; urgency=low

* second release
* add register_shutdown_function
* add header_register_callback
* add config
* reworked caching to use handlers (old code as files_mtime handler)
* reworked caching to use handlers (old code as files_mtime handler)
* reworked prepare file
* now using argparse
* changed directory structure (see pyhp.conf)

-- Eric Wolf <[email protected]> Sat, 03 Aug 2019 15:30:00 +0100

pyhp (1.0-1) stable; urgency=low

* first release
* add basic functionality

-- Eric Wolf <[email protected]> Sat, 29 Jun 2019 19:00:00 +0100
1 change: 1 addition & 0 deletions debian/conffiles
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/pyhp.conf
13 changes: 13 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Package: pyhp
Version: 1.2-1
Architecture: all
Maintainer: Eric Wolf <[email protected]>
Installed-Size: 21
Depends: python3:any (>= 3.5)
Suggests: apache2
Section: web
Priority: optional
Homepage: https://github.com/Deric-W/PyHP-Interpreter
Description: Interprets and executes pyhp files.
PyHP is a script for interpreting and executing pyhp files, with several PHP functions available.
pyhp files are (mostly) HTML files that have embedded Python source code and can be used for creating dynamic web pages.
10 changes: 10 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: pyhp
Upstream-Contact: Eric Wolf <[email protected]>
Source: https://github.com/Deric-W/PyHP-Interpreter
Copyright: 2019 Eric Wolf
License: Expat

Files: *
Copyright: 2019 Eric Wolf
License: Expat
55 changes: 55 additions & 0 deletions debian/deb_builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
echo "Name of package?"
read package
mkdir $package

mkdir $package/etc
wget -nv -O $package/etc/pyhp.conf --tries=3 https://raw.githubusercontent.com/Deric-W/PyHP-Interpreter/master/pyhp.conf
chown root $package/etc/pyhp.conf
chgrp root $package/etc/pyhp.conf

mkdir $package/lib
mkdir $package/lib/pyhp
mkdir $package/lib/pyhp/cache_handlers
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
chown root $package/lib/pyhp/cache_handlers/files_mtime.py
chgrp root $package/lib/pyhp/cache_handlers/files_mtime.py

mkdir $package/usr
mkdir $package/usr/bin
wget -nv -O $package/usr/bin/pyhp --tries=3 https://raw.githubusercontent.com/Deric-W/PyHP-Interpreter/master/pyhp.py
chown root $package/usr/bin/pyhp
chgrp root $package/usr/bin/pyhp
chmod +x $package/usr/bin/pyhp

mkdir $package/DEBIAN
wget -nv -O $package/DEBIAN/control --tries=3 https://raw.githubusercontent.com/Deric-W/PyHP-Interpreter/master/debian/control
chown root $package/DEBIAN/control
chgrp root $package/DEBIAN/control

wget -nv -O $package/DEBIAN/conffiles --tries=3 https://raw.githubusercontent.com/Deric-W/PyHP-Interpreter/master/debian/conffiles
chown root $package/DEBIAN/conffiles
chgrp root $package/DEBIAN/conffiles

mkdir $package/usr/share
mkdir $package/usr/share/doc
mkdir $package/usr/share/doc/pyhp
wget -nv -O $package/usr/share/doc/pyhp/copyright --tries=3 https://raw.githubusercontent.com/Deric-W/PyHP-Interpreter/master/debian/copyright
chown root $package/usr/share/doc/pyhp/copyright
chgrp root $package/usr/share/doc/pyhp/copyright

wget -nv -O $package/usr/share/doc/pyhp/changelog.Debian --tries=3 https://raw.githubusercontent.com/Deric-W/PyHP-Interpreter/master/debian/changelog
gzip -n --best $package/usr/share/doc/pyhp/changelog.Debian
chown root $package/usr/share/doc/pyhp/changelog.Debian.gz
chgrp root $package/usr/share/doc/pyhp/changelog.Debian.gz

chdir $package
md5sum etc/pyhp.conf >> DEBIAN/md5sums
md5sum lib/pyhp/cache_handlers/files_mtime.py >> DEBIAN/md5sums
md5sum usr/bin/pyhp >> DEBIAN/md5sums
md5sum usr/share/doc/pyhp/copyright >> DEBIAN/md5sums
md5sum usr/share/doc/pyhp/changelog.Debian.gz >> DEBIAN/md5sums
chdir ../

dpkg-deb --build $package

rm -rf $package
2 changes: 1 addition & 1 deletion pyhp.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ closing_tag = [\n \t]\?\> # regex
[caching]
allow_caching = True
auto_caching = False # ignore -c arg
cache_path = /var/cache/pyhp # path to use
cache_path = ~/.pyhpcache # path to use
handler = files_mtime
handler_path = /lib/pyhp/cache_handlers # directory containing the handler

0 comments on commit f2292cc

Please sign in to comment.