removed lxml post processing
updated dockerfile
This commit is contained in:
		
							parent
							
								
									1b1e34b035
								
							
						
					
					
						commit
						325c735f4e
					
				
					 7 changed files with 57 additions and 68 deletions
				
			
		| 
						 | 
					@ -1,21 +1,15 @@
 | 
				
			||||||
FROM realms/base
 | 
					FROM realms/base
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Packages
 | 
					# Packages
 | 
				
			||||||
RUN add-apt-repository -y ppa:chris-lea/node.js && apt-get update
 | 
					RUN apt-get update && apt-get install -y build-essential python-pip python-virtualenv python-dev zlib1g-dev libffi-dev libyaml-dev
 | 
				
			||||||
RUN apt-get install -y python build-essential git libpcre3-dev python-software-properties \
 | 
					 | 
				
			||||||
    python-pip python-virtualenv python-dev pkg-config curl libxml2-dev libxslt1-dev zlib1g-dev \
 | 
					 | 
				
			||||||
    libffi-dev nodejs libyaml-dev
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Realms Code
 | 
					# lxml deps
 | 
				
			||||||
RUN cd /home/deploy && git clone https://github.com/scragg0x/realms-wiki
 | 
					# libxml2-dev libxslt1-dev
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Bower stuff for frontend assets
 | 
					# Virtualenv
 | 
				
			||||||
RUN npm install -g bower
 | 
					 | 
				
			||||||
RUN bower --allow-root --config.cwd=/home/deploy/realms-wiki --config.directory=realms/static/vendor --config.interactive=false install
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Virtualenv building
 | 
					 | 
				
			||||||
RUN virtualenv /home/deploy/realms-wiki/.venv
 | 
					RUN virtualenv /home/deploy/realms-wiki/.venv
 | 
				
			||||||
RUN /home/deploy/realms-wiki/.venv/bin/pip install /home/deploy/realms-wiki
 | 
					
 | 
				
			||||||
 | 
					RUN cd /home/deploy/realms-wiki && .venv/bin/pip install realms-wiki
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Logging
 | 
					# Logging
 | 
				
			||||||
RUN mkdir /var/log/realms-wiki && chown deploy.deploy /var/log/realms-wiki
 | 
					RUN mkdir /var/log/realms-wiki && chown deploy.deploy /var/log/realms-wiki
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,9 +1,51 @@
 | 
				
			||||||
#!/bin/sh
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					limit nofile 65335 65335
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					respawn
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					description "Realms Wiki"
 | 
				
			||||||
 | 
					author "scragg@gmail.com"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
chdir /home/deploy/realms-wiki
 | 
					chdir /home/deploy/realms-wiki
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					env PATH=/home/deploy/realms-wiki/.venv/bin:/usr/local/bin:/usr/bin:/bin:$PATH
 | 
				
			||||||
 | 
					export PATH
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					env LC_ALL=en_US.UTF-8
 | 
				
			||||||
 | 
					env GEVENT_RESOLVER=ares
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export LC_ALL
 | 
				
			||||||
 | 
					export GEVENT_RESOLVER
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ "${REALMS_WIKI_CONFIG}" != "" ]; then
 | 
					if [ "${REALMS_WIKI_CONFIG}" != "" ]; then
 | 
				
			||||||
    realms-wiki configure ${REALMS_WIKI_CONFIG}
 | 
					    realms-wiki configure ${REALMS_WIKI_CONFIG}
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exec /sbin/setuser deploy /home/deploy/realms-wiki/.venv/bin/python manage.py run >>/var/log/realms-wiki/realms-wiki.log 2>&1
 | 
					if [ "${REALMS_WIKI_WORKERS}" == "" ]; then
 | 
				
			||||||
 | 
					    REALMS_WIKI_WORKERS=3
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [ "${REALMS_WIKI_PORT}" == "" ]; then
 | 
				
			||||||
 | 
					    REALMS_WIKI_PORT=5000
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					setuid deploy
 | 
				
			||||||
 | 
					setgid deploy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					start on runlevel [2345]
 | 
				
			||||||
 | 
					stop on runlevel [!2345]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					respawn
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					exec gunicorn \
 | 
				
			||||||
 | 
					  --name realms-wiki \
 | 
				
			||||||
 | 
					  --access-logfile - \
 | 
				
			||||||
 | 
					  --error-logfile - \
 | 
				
			||||||
 | 
					  --worker-class gevent \
 | 
				
			||||||
 | 
					  --workers ${REALMS_WIKI_WORKERS} \
 | 
				
			||||||
 | 
					  --bind 0.0.0.0:${REALMS_WIKI_PORT} \
 | 
				
			||||||
 | 
					  --user deploy \
 | 
				
			||||||
 | 
					  --group deploy \
 | 
				
			||||||
 | 
					  --chdir /home/deploy/realms-wiki \
 | 
				
			||||||
 | 
					  'realms:create_app()' >>/var/log/realms-wiki/realms-wiki.log 2>&1
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,9 +15,12 @@ sudo apt-get install -y software-properties-common python-software-properties
 | 
				
			||||||
sudo add-apt-repository -y ppa:chris-lea/node.js
 | 
					sudo add-apt-repository -y ppa:chris-lea/node.js
 | 
				
			||||||
sudo apt-get update
 | 
					sudo apt-get update
 | 
				
			||||||
sudo apt-get install -y python build-essential pkg-config git  \
 | 
					sudo apt-get install -y python build-essential pkg-config git  \
 | 
				
			||||||
python-pip python-virtualenv python-dev libxml2-dev libxslt1-dev zlib1g-dev \
 | 
					python-pip python-virtualenv python-dev zlib1g-dev \
 | 
				
			||||||
libffi-dev libyaml-dev libssl-dev nodejs
 | 
					libffi-dev libyaml-dev libssl-dev nodejs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# lxml deps
 | 
				
			||||||
 | 
					# libxml2-dev libxslt1-dev
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Default cache is memoization
 | 
					# Default cache is memoization
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Redis
 | 
					# Redis
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -326,8 +326,8 @@ def restart():
 | 
				
			||||||
def status():
 | 
					def status():
 | 
				
			||||||
    """ Get server status
 | 
					    """ Get server status
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    pid = is_running(get_pid())
 | 
					    pid = get_pid()
 | 
				
			||||||
    if not pid:
 | 
					    if not is_running(pid):
 | 
				
			||||||
        yellow("Server is not running")
 | 
					        yellow("Server is not running")
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        green("Server is running PID: %s" % pid)
 | 
					        green("Server is running PID: %s" % pid)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,13 +1,10 @@
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
import re
 | 
					import re
 | 
				
			||||||
import lxml.html
 | 
					 | 
				
			||||||
from lxml.html.clean import Cleaner
 | 
					 | 
				
			||||||
import ghdiff
 | 
					import ghdiff
 | 
				
			||||||
import gittle.utils
 | 
					import gittle.utils
 | 
				
			||||||
import yaml
 | 
					import yaml
 | 
				
			||||||
from gittle import Gittle
 | 
					from gittle import Gittle
 | 
				
			||||||
from dulwich.repo import NotGitRepository
 | 
					from dulwich.repo import NotGitRepository
 | 
				
			||||||
from werkzeug.utils import escape, unescape
 | 
					 | 
				
			||||||
from realms.lib.util import to_canonical
 | 
					from realms.lib.util import to_canonical
 | 
				
			||||||
from realms import cache
 | 
					from realms import cache
 | 
				
			||||||
from realms.lib.hook import HookMixin
 | 
					from realms.lib.hook import HookMixin
 | 
				
			||||||
| 
						 | 
					@ -107,8 +104,6 @@ class Wiki(HookMixin):
 | 
				
			||||||
        cname = to_canonical(name)
 | 
					        cname = to_canonical(name)
 | 
				
			||||||
        filename = cname_to_filename(cname)
 | 
					        filename = cname_to_filename(cname)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        content = self.clean(content)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        with open(self.path + "/" + filename, 'w') as f:
 | 
					        with open(self.path + "/" + filename, 'w') as f:
 | 
				
			||||||
            f.write(content)
 | 
					            f.write(content)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -129,50 +124,6 @@ class Wiki(HookMixin):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return ret
 | 
					        return ret
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def clean(self, content):
 | 
					 | 
				
			||||||
        """Clean any HTML, this might not be necessary.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        :param content: Content of page.
 | 
					 | 
				
			||||||
        :return: str
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        """
 | 
					 | 
				
			||||||
        def escape_repl(m):
 | 
					 | 
				
			||||||
            if m.group(1):
 | 
					 | 
				
			||||||
                return "```" + escape(m.group(1)) + "```"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        def unescape_repl(m):
 | 
					 | 
				
			||||||
            if m.group(1):
 | 
					 | 
				
			||||||
                return "```" + unescape(m.group(1)) + "```"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        # prevents p tag from being added, we remove this later
 | 
					 | 
				
			||||||
        content = '<div>' + content + '</div>'
 | 
					 | 
				
			||||||
        content = re.sub(r"```(.*?)```", escape_repl, content, flags=re.DOTALL)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        tree = lxml.html.fromstring(content)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        cleaner = Cleaner(remove_unknown_tags=False,
 | 
					 | 
				
			||||||
                          kill_tags={'style'},
 | 
					 | 
				
			||||||
                          safe_attrs_only=False)
 | 
					 | 
				
			||||||
        tree = cleaner.clean_html(tree)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        content = lxml.html.tostring(tree, encoding='utf-8', method='html')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        # remove added div tags
 | 
					 | 
				
			||||||
        content = content[5:-6]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        # FIXME this is for block quotes, doesn't work for double ">"
 | 
					 | 
				
			||||||
        content = re.sub(r"(\n>)", "\n>", content)
 | 
					 | 
				
			||||||
        content = re.sub(r"(^>)", ">", content)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        # Handlebars partial ">"
 | 
					 | 
				
			||||||
        content = re.sub(r"\{\{>(.*?)\}\}", r'{{>\1}}', content)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        # Handlebars, allow {{}} inside HTML links
 | 
					 | 
				
			||||||
        content = content.replace("%7B", "{")
 | 
					 | 
				
			||||||
        content = content.replace("%7D", "}")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        content = re.sub(r"```(.*?)```", unescape_repl, content, flags=re.DOTALL)
 | 
					 | 
				
			||||||
        return content
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def rename_page(self, old_name, new_name, username=None, email=None, message=None):
 | 
					    def rename_page(self, old_name, new_name, username=None, email=None, message=None):
 | 
				
			||||||
        """Rename page.
 | 
					        """Rename page.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1 +1 @@
 | 
				
			||||||
__version__ = '0.4.3'
 | 
					__version__ = '0.4.4'
 | 
				
			||||||
							
								
								
									
										1
									
								
								setup.py
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								setup.py
									
										
									
									
									
								
							| 
						 | 
					@ -38,7 +38,6 @@ setup(name='realms-wiki',
 | 
				
			||||||
          'gittle==0.4.0',
 | 
					          'gittle==0.4.0',
 | 
				
			||||||
          'gunicorn==19.1.1',
 | 
					          'gunicorn==19.1.1',
 | 
				
			||||||
          'itsdangerous==0.24',
 | 
					          'itsdangerous==0.24',
 | 
				
			||||||
          'lxml==3.4.0',
 | 
					 | 
				
			||||||
          'markdown2==2.3.0',
 | 
					          'markdown2==2.3.0',
 | 
				
			||||||
          'simplejson==3.6.3'
 | 
					          'simplejson==3.6.3'
 | 
				
			||||||
      ],
 | 
					      ],
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue