Skip to content

Commit

Permalink
Initial version. Somehow works :)
Browse files Browse the repository at this point in the history
  • Loading branch information
syrel committed Sep 3, 2016
1 parent 8b3f163 commit fbb2fb2
Show file tree
Hide file tree
Showing 55 changed files with 297 additions and 16 deletions.
4 changes: 3 additions & 1 deletion app/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"motion-ui": "~1.1.0",
"foundation-sites": "~6.2.0",
"motion-ui": "~1.2.2",
"requirejs": "latest"
"requirejs": "latest",
"underscore": "latest",
"autosize": "latest"
},
"ignore": [
"**/.*",
Expand Down
7 changes: 3 additions & 4 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Foundation for Sites</title>
<link rel="stylesheet" href="css/app.css">
<link rel="stylesheet" href="css/github-markdown.css">
</head>
<body>
<div class="row">
<div class="large-6 columns" id="pillar">
<textarea placeholder="small-12.columns"></textarea>
</div>
<div class="row align-middle">
<textarea class="large-6 columns align-self-middle" rows="1" cols="50" id="pillar" placeholder="Pillar markup"></textarea>
<div class="large-6 columns" id="preview">

</div>
Expand Down
15 changes: 7 additions & 8 deletions app/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@ requirejs.config({
"jquery": '../assets/jquery/dist/jquery.min',
"foundation": '../assets/foundation-sites/dist/foundation.min',
"what-input": '../assets/what-input/what-input.min',
"motion-ui": '../assets/motion-ui/dist/motion-ui.min'
"motion-ui": '../assets/motion-ui/dist/motion-ui.min',
"underscore": '../assets/underscore/underscore-min',
"autosize": '../assets/autosize/dist/autosize.min'
},
shim: {
"foundation": ['jquery']
}
});


// Add any foundation modules you require to the end of this line.
require(['jquery', 'foundation', 'what-input'], function($) {
// Foundation JavaScript
// Documentation can be found at: http://foundation.zurb.com/docs
$(document).load(function() {
$(this).foundation();
alert('haba');
});
require(['paas', 'jquery', 'foundation', 'what-input'], function(PaaS, $) {
$(this).foundation();
PaaS.init();
});
62 changes: 62 additions & 0 deletions app/js/paas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Created by Aliaksei Syrel on 02/09/16.
*/
define(['jquery', 'underscore', 'autosize'], function($, _, autosize){

function PaaS() {
var _this = this;
var pillar = $('#pillar');
var preview = $('#preview');

_this.initalize = function () {
_this.attachPillarListener();
_this.load();
autosize(pillar);
};

_this.onPillarChanged = function() {
var text = pillar.val();
$.post(/*'http://127.0.0.1:6561/'*/'http://paas.syrel.ch/render/html', { pillar: text },
function( data ) {
preview.html( data );
});
};

_this.attachPillarListener = function () {
var oldValue = pillar.val();
var preview = _.debounce(function(){
var newValue = pillar.val();
if (newValue != oldValue) {
oldValue = newValue;
_this.onPillarChanged();
_this.save();
}
},300);
pillar.on('input change keyup keydown paste', preview);
};

_this.save = function () {
var file = pillar.val();
// sets the file string to hold the data
localStorage.setItem('pillar', JSON.stringify(file));
};

_this.load = function () {
var autosave = localStorage.getItem('pillar');
if (_.isUndefined(autosave)) return;
// parses the string (btw. its UTF-8)
var text = JSON.parse(autosave);
//modifies the textarea with the id="inputTextArea"
pillar.val(text);
_this.onPillarChanged();
};

_this.initalize();
}

PaaS.init = function() {
new PaaS();
};

return PaaS;
});
2 changes: 1 addition & 1 deletion app/scss/_settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
// ---------

$global-font-size: 100%;
$global-width: rem-calc(1200);
$global-width: rem-calc(1600);
$global-lineheight: 1.5;
$foundation-palette: (
primary: #2199e8,
Expand Down
16 changes: 14 additions & 2 deletions app/scss/paas.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
.haba {
background: red;
.full-height {
height: 100%;
}

textarea {
overflow: none;
display: block;
resize: vertical;
font-family: monospace;
font-size: 95%;
}

#preview {
padding-left: rem-calc(40);
}
26 changes: 26 additions & 0 deletions server/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

dir="pharo"

RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

rm -rf "$dir"
mkdir "$dir"
cd "$dir"

echo -e "${BLUE}Downloading Pharo 4.0...${NC}"
wget http://files.pharo.org/platform/Pharo4.0-linux-oldLibC.zip

echo -e "${BLUE}Extracting...${NC}"
unzip Pharo4.0-linux-oldLibC.zip

mv pharo4.0/* ./
rm -rf pharo4.0

echo -e "${BLUE}Installing Pillar...${NC}"
./pharo -vm-display-null shared/Pharo4.0.image eval --save "Gofer it url: 'http://smalltalkhub.com/mc/Pier/Pillar/main/'; configurationOf: 'Pillar'; loadDevelopment"

echo -e "${BLUE}Installing PaaS (Pillar as a service)...${NC}"
./pharo -vm-display-null shared/Pharo4.0.image eval --save "Metacello new baseline: 'PaaS'; repository: 'github://syrel/paas/src'; load: #core"
11 changes: 11 additions & 0 deletions server/render_html.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
/**
* Created by PhpStorm.
* User: aliaksei
* Date: 03/09/16
* Time: 09:53
*/

include_once('setup.php');

echo render("html", $_POST['pillar']);
9 changes: 9 additions & 0 deletions server/rpm/32rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

url=$1
file=`basename "$url"`
echo $file

wget "$url"
rpm2cpio "$url" | ( cd ~/linux32/; cpio -div )
ldd ../pharo/bin/libSqueakSSL.so
8 changes: 8 additions & 0 deletions server/rpm/64rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

url=$1
file=`basename "$url"`
echo $file

wget "$url"
rpm2cpio "$url" | ( cd ~/linux/; cpio -div )
Binary file added server/rpm/alsa-lib-1.1.0-4.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/audit-libs-2.4.5-3.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/dbus-libs-1.2.24-8.el6_6.i686.rpm
Binary file not shown.
Binary file added server/rpm/expat-2.0.1-11.el6_2.i686.rpm
Binary file not shown.
Binary file added server/rpm/freetype-2.3.11-17.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/glibc-2.12-1.192.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/hal-libs-0.5.14-14.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/keyutils-libs-1.4-5.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/krb5-libs-1.10.3-57.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/libICE-1.0.6-1.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/libSM-1.2.1-2.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/libX11-1.6.3-2.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/libX11-common-1.6.3-2.el6.noarch.rpm
Binary file not shown.
Binary file added server/rpm/libXau-1.0.6-4.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/libXdamage-1.1.3-4.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/libXdmcp-1.1.1-3.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/libXext-1.3.3-1.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/libXfixes-5.0.1-2.1.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/libXfont-1.5.1-2.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/libXxf86vm-1.1.3-2.1.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/libcom_err-1.41.12-22.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/libdrm-2.4.65-2.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/libfontenc-1.1.2-3.el6.i686.rpm
Binary file not shown.
Binary file not shown.
Binary file added server/rpm/libpciaccess-0.13.4-1.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/libselinux-2.0.94-7.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/libuuid-2.17.2-12.24.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/libxcb-1.11-2.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/libxshmfence-1.2-1.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/lynx-2.8.6-27.el6.x86_64.rpm
Binary file not shown.
Binary file added server/rpm/mesa-dri-drivers-11.0.7-4.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/mesa-libGL-11.0.7-4.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/openssl-1.0.1e-48.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/pam-1.1.1-22.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/pixman-0.32.8-1.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/rpm-4.8.0-55.el6.x86_64.rpm
Binary file not shown.
85 changes: 85 additions & 0 deletions server/rpm/rpm2cpio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Lightweight RPM to CPIO converter.
# Copyright © 2008-2013 Rudá Moura
#

'''Extract cpio archive from RPM package.
rpm2cpio converts the RPM on standard input or first parameter to a CPIO archive on standard output.
Usage:
rpm2cpio < adjtimex-1.20-2.1.i386.rpm | cpio -it
./sbin/adjtimex
./usr/share/doc/adjtimex-1.20
./usr/share/doc/adjtimex-1.20/COPYING
./usr/share/doc/adjtimex-1.20/COPYRIGHT
./usr/share/doc/adjtimex-1.20/README
./usr/share/man/man8/adjtimex.8.gz
133 blocks
'''

import sys
import StringIO
import gzip
import subprocess

try:
import lzma
except ImportError:
HAS_LZMA_MODULE = False
else:
HAS_LZMA_MODULE = True

RPM_MAGIC = '\xed\xab\xee\xdb'
GZIP_MAGIC = '\x1f\x8b'
XZ_MAGIC = '\xfd7zXZ\x00'

def gzip_decompress(data):
gzstream = StringIO.StringIO(data)
gzipper = gzip.GzipFile(fileobj=gzstream)
data = gzipper.read()
return data

def xz_decompress(data):
if HAS_LZMA_MODULE:
return lzma.decompress(data)
unxz = subprocess.Popen(['unxz'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
data = unxz.communicate(input=data)[0]
return data

def rpm2cpio(stream_in=sys.stdin, stream_out=sys.stdout):
lead = stream_in.read(96)
if lead[0:4] != RPM_MAGIC:
raise IOError, 'the input is not a RPM package'
data = stream_in.read()
decompress = None
idx = data.find(XZ_MAGIC)
if idx != -1:
decompress = xz_decompress
pos = idx
idx = data.find(GZIP_MAGIC)
if idx != -1 and decompress is None:
decompress = gzip_decompress
pos = idx
if decompress is None:
raise IOError, 'could not find compressed cpio archive'
data = decompress(data[pos:])
stream_out.write(data)

if __name__ == '__main__':
if sys.argv[1:]:
try:
fin = open(sys.argv[1])
rpm2cpio(fin)
fin.close()
except IOError, e:
print 'Error:', sys.argv[1], e
else:
try:
rpm2cpio()
except IOError, e:
print 'Error:', e
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added server/rpm/xorg-x11-xauth-1.0.9-1.el6.i686.rpm
Binary file not shown.
Binary file added server/rpm/zlib-1.2.3-29.el6.i686.rpm
Binary file not shown.
46 changes: 46 additions & 0 deletions server/setup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* Created by PhpStorm.
* User: aliaksei
* Date: 03/09/16
* Time: 06:45
*/
header('Access-Control-Allow-Origin: *');

static $PORT = 6561;

class exec {

static function run($command){
$PID = exec("$command 2>/dev/null >/dev/null &");
return($PID);
}

static function isRunning($name){
exec("pgrep $name", $pids);
return !empty($pids);
}
};

if(!exec::isRunning('pharo')) {
echo exec::run('bash --login -c "./start.sh '.$PORT.'"');
}

function render ($mode, $pillar) {
global $PORT;
if (strlen($pillar) == 0)
return '';
$url = 'http://'.$_SERVER['SERVER_NAME'].':'.$PORT.'/'.$mode;
$options = array(
'http' => array(
'header' => "Content-type: text/html",
'method' => 'POST',
'content' => $pillar
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ }

return $result;
}
22 changes: 22 additions & 0 deletions server/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

dir="pharo"
port="6561"

if [ "$#" -gt 0 ]; then
port=$1
fi

RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

cd $dir

if pgrep "pharo" > /dev/null
then
echo "Already running"
else
echo -e "${BLUE}Starting server on port ${port}...${NC}"
./pharo -vm-display-null shared/Pharo4.0.image eval --no-quit "PaaSBackend startOn: $port" &>/dev/null &disown
fi

0 comments on commit fbb2fb2

Please sign in to comment.