Skip to content
This repository was archived by the owner on Oct 21, 2018. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: anru/rsted
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: destrangis/rsted
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 10 commits
  • 10 files changed
  • 2 contributors

Commits on Feb 1, 2021

  1. Copy the full SHA
    0938962 View commit details

Commits on Feb 9, 2021

  1. Copy the full SHA
    45a9769 View commit details
  2. Copy the full SHA
    59ef27b View commit details
  3. Remove requirements for old versions of packages.

    Those were only required for compatibility with python2
    destrangis committed Feb 9, 2021
    Copy the full SHA
    5c8df75 View commit details
  4. Copy the full SHA
    03397d9 View commit details
  5. Copy the full SHA
    b3e4e7e View commit details
  6. Further Python3 compatibility changes.

    Mainly on the fcgi daemon part
    destrangis committed Feb 9, 2021
    Copy the full SHA
    3f9cb7f View commit details
  7. Copy the full SHA
    b0e209a View commit details

Commits on Feb 28, 2021

  1. Fix site address

    destrangis committed Feb 28, 2021
    Copy the full SHA
    9e91da8 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    fb487af View commit details
Showing with 52 additions and 38 deletions.
  1. +10 −1 README.rst
  2. +3 −3 application.py
  3. +11 −11 pwl/fastcgi.py
  4. +3 −3 pwl/utils/daemon.py
  5. +5 −5 pwl/utils/daemonize.py
  6. +1 −1 rsted.fcgi
  7. +10 −5 rsted/pdf.py
  8. +1 −1 settings.py
  9. +2 −2 templates/about.html
  10. +6 −6 templates/base.html
11 changes: 10 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
RSTED
=====

Simple online editor for reStructuredText on Flask.

Try it where: http://rst.ninjs.org/
This repository contains the necessary modifications to run on Python3
with up-to-date versions of the packages it depends upon. The original
repository at https://github.com/anru/rsted is no longer maintained,
and works only on Python2.

You can try it at http://destrangis.eu.pythonanywhere.com as the former link (http://rst.ninjs.org/) is, alas, no longer
working.

Getting setup
-------------
6 changes: 3 additions & 3 deletions application.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# all the imports

import os, sys
reload(sys)
sys.setdefaultencoding('utf-8')
#reload(sys)
#sys.setdefaultencoding('utf-8')

from flask import Flask, request, render_template, make_response, url_for

22 changes: 11 additions & 11 deletions pwl/fastcgi.py
Original file line number Diff line number Diff line change
@@ -86,9 +86,9 @@


def fastcgi_help(message=None):
print FASTCGI_HELP
print(FASTCGI_HELP)
if message:
print message
print(message)
return False


@@ -114,16 +114,16 @@ def runfastcgi(app, argset=[], **kwargs):
if pw:
os.setresgid(pw.pw_gid, pw.pw_gid, pw.pw_gid)
os.setresuid(pw.pw_uid, pw.pw_uid, pw.pw_uid)


try:
import flup
except ImportError, e:
print >> sys.stderr, 'ERROR: %s' % e
print >> sys.stderr, ' Unable to load the flup package. In order to run rsted'
print >> sys.stderr, ' as a FastCGI application, you will need to get flup from'
print >> sys.stderr, " http://www.saddi.com/software/flup/ If you've already"
print >> sys.stderr, ' installed flup, then make sure you have it in your PYTHONPATH.'
except ImportError as e:
print('ERROR: %s' % e, file=sys.stderr)
print(' Unable to load the flup package. In order to run rsted', file=sys.stderr)
print(' as a FastCGI application, you will need to get flup from', file=sys.stderr)
print(" http://www.saddi.com/software/flup/ If you've already", file=sys.stderr)
print(' installed flup, then make sure you have it in your PYTHONPATH.', file=sys.stderr)
return False

flup_module = 'server.' + options['protocol']
@@ -141,7 +141,7 @@ def runfastcgi(app, argset=[], **kwargs):
wsgi_opts['debug'] = options['debug'] is not None

try:
module = importlib.import_module('.%s' % flup_module, 'flup')
module = importlib.import_module('flup.%s' % flup_module, 'flup')
#WSGIServer = module.WSGIServer
class WSGIServer(module.WSGIServer):

@@ -154,7 +154,7 @@ def _spawnChild(self, sock):
return super(WSGIServer, self)._spawnChild(sock)

except:
print "Can't import flup." + flup_module
print("Can't import flup." + flup_module)
return False

if options['host'] and options['port'] and not options['socket']:
6 changes: 3 additions & 3 deletions pwl/utils/daemon.py
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ def delpid(self):
os.unlink(self.pidfile)
except:
pass

def readpid(self):
try:
with open(self.pidfile, 'r') as pf:
@@ -84,7 +84,7 @@ def stop(self):

# Get the pid from the pidfile
pid = self.readpid()

if not pid:
message = 'pidfile %s does not exist. Daemon not running?\n' % self.pidfile
sys.stderr.write(message)
@@ -95,7 +95,7 @@ def stop(self):
while 1:
os.kill(pid, signal.SIGTERM) # @UndefinedVariable
time.sleep(0.1)
except OSError, err:
except OSError as err:
error_code = getattr(err, 'code', err.errno)
if error_code == errno.ESRCH: # No such process
self.delpid()
10 changes: 5 additions & 5 deletions pwl/utils/daemonize.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
import sys
import signal

def become_daemon(our_home_dir='.', out_log='/dev/null', err_log='/dev/null', umask=022):
def become_daemon(our_home_dir='.', out_log='/dev/null', err_log='/dev/null', umask=0o22):
'''Robustly turn into a UNIX daemon, running in our_home_dir.'''

# On some systems, the fork() system call resets some of the
@@ -15,7 +15,7 @@ def become_daemon(our_home_dir='.', out_log='/dev/null', err_log='/dev/null', um
try:
if os.fork() > 0:
sys.exit(0) # kill off parent
except OSError, e:
except OSError as e:
sys.stderr.write('fork #1 failed: (%d) %s\n' % (e.errno, e.strerror))
sys.exit(1)
os.setsid()
@@ -26,14 +26,14 @@ def become_daemon(our_home_dir='.', out_log='/dev/null', err_log='/dev/null', um
try:
if os.fork() > 0:
os._exit(0)
except OSError, e:
except OSError as e:
sys.stderr.write('fork #2 failed: (%d) %s\n' % (e.errno, e.strerror))
os._exit(1)

signal.signal(signal.SIGUSR1, usr1)
si = open('/dev/null', 'r')
so = open(out_log, 'a+', 0)
se = open(err_log, 'a+', 0)
so = open(out_log, 'a+b', 0)
se = open(err_log, 'a+b', 0)
os.dup2(si.fileno(), sys.stdin.fileno())
os.dup2(so.fileno(), sys.stdout.fileno())
os.dup2(se.fileno(), sys.stderr.fileno())
2 changes: 1 addition & 1 deletion rsted.fcgi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3

import os
from os.path import join as J
15 changes: 10 additions & 5 deletions rsted/pdf.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import sys
from rst2pdf.createpdf import RstToPdf
import codecs
utf8codec = codecs.lookup('utf-8')

from flask import current_app

try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
if sys.version_info > (3,):
#from io import StringIO
from io import BytesIO
else:
try:
from cStringIO import StringIO as BytesIO
except ImportError:
from StringIO import StringIO as BytesIO

def rst2pdf(content, theme=None):
topdf = RstToPdf(basedir=current_app.config.root_path, breaklevel=0)
buf = StringIO()
buf = BytesIO()

if not content:
content = '\0'
2 changes: 1 addition & 1 deletion settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

# configuration
DEBUG = not os.environ.has_key('RSTED_PROD')
DEBUG = 'RSTED_PROD' not in os.environ

RUN_PATH = 'var/run'
PID_FILE = 'fastcgi.pid'
4 changes: 2 additions & 2 deletions templates/about.html
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@
{% block content %}

<p>
Site uses standard rst2html.py script</br>
Site source: <a href="http://github.com/anru/rsted">http://github.com/anru/rsted</a>
This site uses standard rst2html.py script</br>
Source code to this site: <a href="https://github.com/destrangis/rsted">https://github.com/destrangis/rsted</a>
</p>


12 changes: 6 additions & 6 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -5,18 +5,18 @@
<meta charset="UTF-8">
<title>{% block title %}Online reStructuredText editor{% endblock %}</title>

<link rel="stylesheet" href="{{ request.script_root }}{{ MEDIA_URL }}style/base.css"/>
<link rel="stylesheet" href="{{ request.script_root }}{{ MEDIA_URL }}style/site.css"/>
<link rel="stylesheet" href="{{ request.script_root }}{{ MEDIA_URL }}style/menu.css"/>
<link rel="stylesheet" href="{{ request.script_root }}{{ MEDIA_URL }}style/base.css"/>
<link rel="stylesheet" href="{{ request.script_root }}{{ MEDIA_URL }}style/site.css"/>
<link rel="stylesheet" href="{{ request.script_root }}{{ MEDIA_URL }}style/menu.css"/>


<script src="{{ request.script_root }}{{ MEDIA_URL }}scripts/jquery-1.6.4.min.js"></script>
<script src="{{ request.script_root }}{{ MEDIA_URL }}scripts/jquery.layout.min-1.2.0.js"></script>
<script src="{{ request.script_root }}{{ MEDIA_URL }}scripts/jquery-1.6.4.min.js"></script>
<script src="{{ request.script_root }}{{ MEDIA_URL }}scripts/jquery.layout.min-1.2.0.js"></script>

{% endblock %}
</head>
<body>
<a id="github-ribbon" href="http://github.com/anru/rsted">Fork me on GitHub</a>
<a id="github-ribbon" href="http://github.com/destrangis/rsted">Fork me on GitHub</a>
{% block body_head %}
{% endblock %}
<header id="header">