Permalink
Browse files

better directions

  • Loading branch information...
1 parent 3194d18 commit f0c5e8c8775054901010b79a64ff7c2456af03f9 @joelcarranza committed Jun 25, 2012
Showing with 25 additions and 19 deletions.
  1. +1 −1 README.md
  2. +0 −6 templates/answer.html
  3. +20 −8 templates/question.html
  4. +4 −4 textdirections.py
View
2 README.md
@@ -22,7 +22,7 @@ A user can ask for directions via text message by texting XXX-XXXX (TODO). An ex
Audubon Park to Superdome
directions from Audobon Park to Superdome by bike
bus directions from Audubon Park to Superdome
- Audubon Park to Superdome by bike bus @ 3:40
+ Audubon Park to Superdome by bike bus at 3:40
Texting HELP to the service provides some brief instructions
View
6 templates/answer.html
@@ -1,6 +0,0 @@
-$def with (response)
-$var title: Answer
-
-<pre>
-$response
-</pre>
View
28 templates/question.html
@@ -1,18 +1,30 @@
$def with (question,response)
-$var title: SMS Test
+$var title: BikeBus SMS Test
<div class="row">
<div class="span6">
- <h1>SMS Test</h2>
- <form class="well" method="POST">
- <label>Command</label>
- <textarea class="span5" name="q" placeholder="Type something…">$question</textarea>
- <span class="help-block">Entry a text message like thing here</span>
+ <h1>BikeBus SMS Test</h2>
+ <form method="POST">
+ <textarea class="span5" name="q" rows="5" placeholder="Type something…">$question</textarea>
+ <span class="help-block">
+ <b>Examples</b><br>
+ Audubon Park to Superdome<br>
+ directions from Audobon Park to Superdome by bike<br>
+ bus directions from Audubon Park to Superdome<br>
+ Audubon Park to Superdome by bus at 3:40<br>
+ </span>
<button type="submit" class="btn">Submit</button>
</form>
- $for text in response:
- <pre>$text</pre>
+ $if response:
+ <h2>Response</h2>
+ $for text in response:
+ <div class="sms">
+ <span class="badge" style="float:right">
+ $len(text)
+ </span>
+ <pre>$text</pre>
+ </div>
</div>
</div>
View
8 textdirections.py
@@ -23,19 +23,19 @@
AT_PATTERN = r'(\s+(?:at|in)\s+.+)?'
MODE_PATTERN = r'bike|bus|walk|walking|streetcar'
-FROM_TO_PATTERN = r'(?:from)?(.+?)\s+to\s+(.+?)'
+FROM_TO_PATTERN = r'(?:from\s+)?(.+?)\s+to\s+(.+?)'
ACTIONS = (
(r'^help$','help'),
# MODE directions from FROM to TO at AT
- ('^('+MODE_PATTERN+r')(?:\s+directions\s+)'+
+ ('^('+MODE_PATTERN+r')(?:\s+directions\s+)?'+
FROM_TO_PATTERN+
AT_PATTERN+
'$'
,'directions1'),
# from FROM to TO via MODE at AT
- (r'^'+FROM_TO_PATTERN+
- '(\s+by|via\s+'+MODE_PATTERN+')?'+
+ (r'^(?:directions\s+)?'+FROM_TO_PATTERN+
+ '(?:\s+(?:by|via)\s+('+MODE_PATTERN+'))?'+
AT_PATTERN+
'$'
,'directions2')

0 comments on commit f0c5e8c

Please sign in to comment.