Skip to content

Commit

Permalink
updated for Xmachine
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Burks committed Oct 3, 2010
1 parent 36e6569 commit 9e0ac1a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
13 changes: 13 additions & 0 deletions Nukefile
@@ -0,0 +1,13 @@
;; Nukefile for Nunja-based Xmachine app

(task "zip" is
(SH "rm -rf build/TinyIO.app")
(SH "mkdir -p build/TinyIO.app")
(SH "cp -r tinyd build/TinyIO.app/TinyIO")
(SH "cp -r site build/TinyIO.app")
(SH "cp -r site.nu build/TinyIO.app")
(SH "cp -r public build/TinyIO.app")
(SH "cp -r common build/TinyIO.app")
(SH "cd build; zip -r TinyIO.zip TinyIO.app"))

(task "default" => "zip")
2 changes: 1 addition & 1 deletion public/index.html
Expand Up @@ -76,7 +76,7 @@
</td>
<td align="right">
<h1>tiny.io</h1>
<p>a little URL shortener ("Nu"-kular powered)</p>
<p>a little URL shortener</p>
</td>
<td>
<div id="pane" style="margin-left:10px; width:400px; min-height:120px; background-color:#E0E0F0">
Expand Down
1 change: 1 addition & 0 deletions site/redirect.nu
@@ -1,6 +1,7 @@
(set tiny ((REQUEST bindings) id:))

(set tinyurl (mongo findOne:(dict tiny:tiny) inCollection:"tinyio.tinyurls"))
(puts ((REQUEST requestHeaders) description))

(if (and tinyurl (set url (tinyurl url:)))
(then (set hit (dict tiny:tiny
Expand Down
4 changes: 3 additions & 1 deletion site/shorten.nu
@@ -1,6 +1,8 @@
(set key ((REQUEST post) key:))

(set TINY_KEY (((NSProcessInfo processInfo) environment) TINY_KEY:))
(if (set secret (mongo findOne:(dict key:key) inCollection:"tinyio.secrets"))
(then (set TINY_KEY (secret key:)))
(else (set TINY_KEY (((NSProcessInfo processInfo) environment) TINY_KEY:))))

(if (eq key TINY_KEY)
(then (if (and (set url ((REQUEST post) url:)) (> (url length) 0))
Expand Down
18 changes: 9 additions & 9 deletions tinyd
@@ -1,9 +1,9 @@
#!/usr/local/bin/nush
#
# @file tinyd
# The tiny.io daemon.
# @file nunjad
# The Nunja daemon.
#
# @copyright Copyright (c) 2010 Neon Design Technology, Inc.
# @copyright Copyright (c) 2008 Neon Design Technology, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -29,8 +29,6 @@
(set argv ((NSProcessInfo processInfo) arguments))
(set argi 0)

((((NSProcessInfo processInfo) processIdentifier) stringValue) writeToFile:"tinyd.pid" atomically:NO)

;; if we're running as a nush script, skip the nush path
(if (/(.*)nush$/ findInString:(argv 0))
(set argi (+ argi 1)))
Expand All @@ -40,7 +38,7 @@

;; the option(s) we need to set
(set site ".")
(set port 9000)
(set port 3000)
(set localOnly NO)

;; process the remaining arguments
Expand All @@ -59,14 +57,16 @@
(set argi (+ argi 1)))

(set n (Nunja nunja))

(if localOnly
(then (n bindToAddress:"127.0.0.1" port:port))
(else (n bindToAddress:"0.0.0.0" port:port)))

(if site
(n setDelegate:((NunjaDelegate alloc) initWithSite:site)))
(puts (+ "tinyd is running on port " port))
((n delegate) configureSite:site))

(puts (+ "Nunja is running on port " port))
(set $site site) ;; make the path to the site directory available to handlers
((n delegate) dump)
(if (Nunja verbose) ((n delegate) dump))
(n run)

0 comments on commit 9e0ac1a

Please sign in to comment.