-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8466764
commit eaae776
Showing
10 changed files
with
193 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,3 +66,6 @@ target/ | |
|
||
# db | ||
tests/db.sqlite3 | ||
|
||
# node | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
__version__ = '0.1.2' | ||
__version__ = '0.2.0' | ||
|
||
default_app_config = 'mjml.apps.MJMLConfig' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use strict'; | ||
|
||
|
||
var host = '127.0.0.1', | ||
port = '42201', | ||
argv = process.argv.slice(2); | ||
|
||
|
||
switch (argv.length) { | ||
case 0: | ||
break; | ||
case 1: | ||
port = argv[0]; | ||
break; | ||
case 2: | ||
port = argv[0]; | ||
host = argv[1]; | ||
break; | ||
default: | ||
console.log('Run command: NODE_PATH=node_modules node tcpserver.js 42201 127.0.0.1'); | ||
} | ||
|
||
|
||
var mjml = require('mjml'), | ||
net = require('net'), | ||
server = net.createServer(); | ||
|
||
|
||
function handleConnection(conn) { | ||
conn.setEncoding('utf8'); | ||
conn.on('data', function(d) { | ||
var result; | ||
try { | ||
result = mjml.mjml2html(d.toString()); | ||
conn.write('0'); | ||
} catch (err) { | ||
result = err.message; | ||
conn.write('1'); | ||
} | ||
conn.write(('000000000' + Buffer.byteLength(result).toString()).slice(-9)); | ||
conn.write(result); | ||
}); | ||
conn.once('close', function() {}); | ||
conn.on('error', function(err) {}); | ||
} | ||
|
||
|
||
server.on('connection', handleConnection); | ||
server.listen(port, host, function () { | ||
console.log('RUN SERVER %s:%s', host, port); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
from django.conf import settings | ||
|
||
MJML_BACKEND_MODE = getattr(settings, 'MJML_BACKEND_MODE', 'cmd') | ||
assert MJML_BACKEND_MODE in ('cmd', 'tcpserver') | ||
|
||
# cmd backend mode configs | ||
MJML_EXEC_CMD = getattr(settings, 'MJML_EXEC_CMD', 'mjml') | ||
|
||
# tcpserver backend mode configs | ||
MJML_TCPSERVERS = getattr(settings, 'MJML_TCPSERVERS', [('127.0.0.1', 42201)]) | ||
assert isinstance(MJML_TCPSERVERS, (list, tuple)) | ||
for t in MJML_TCPSERVERS: | ||
assert isinstance(t, (list, tuple)) and len(t) == 2 and isinstance(t[0], str) and isinstance(t[1], int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters