Commits

Rhys !  committed 9f134f9

using search.php

  • Participants
  • Parent commits 657a194

Comments (0)

Files changed (18)

 compiled/*.js.map
 compiled/*.html
 compiled/*.css
+compiled/*.php
     def __init__(self, *args, **kwargs):
         super(Converter, self).__init__(*args, **kwargs)
         if 'convert_tempita' not in kwargs or kwargs['convert_tempita']:
-            self.to_con.append(('.tmpl', '.html', self.convert_tempita))
+            self.to_con.append(('.tmpl', '.php', self.convert_tempita))
 
     def convert_tempita(self, fpth, tpth):
         if os.path.basename(fpth) != 'wrapper.tmpl':

File site/booklist_hit2316.shpaml

 {{inherit "wrapper.tmpl"}}
 {{def bins}}
 li
-    a.inscope href=booklists.html | Booklists
+    a.inscope href=booklists.php | Booklists
     ul
         li
             a href=# | HIT2316 Usability
 ul.breadcrumb
     li
         >
-        a href=index.html | Bookshop
+        a href=index.php | Bookshop
     li
         >
-        a href=booklists.html | Booklists
+        a href=booklists.php | Booklists
     li
         >
         a href=# | HIT2316 Usability
 h1 | HIT2316 Usability
 h2 | Semester Two, 2011, Hawthorn Campus
-form.table.cartadd method=get action=cart.html
+form.table.cartadd method=get action=cart.php
     table
         tr
             th | Add
             th | Price A$
         tr
             td
-                > input type=checkbox name=item value=9780120884360 checked=checked
-            td
-                a href=construction.html | User Interface Design & Evaluation
+                > input type=checkbox name=item value=4 checked=checked
+            td | User Interface Design & Evaluation
             td | Prescribed Text
             td | Stone & Woodroffe
             td.number | 9780120884360

File site/booklists.shpaml

 ul.breadcrumb
     li
         >
-        a href=index.html | Bookshop
+        a href=index.php | Bookshop
     li
         >
-        a href=booklists.html | Booklists
-form.block method=get action=booklist_hit2316.html
+        a href=booklists.php | Booklists
+form.block method=get action=booklist_hit2316.php
     fieldset
         legend | Year
         > input type=radio name=year value=2010 id=year-2010

File site/cart.coffee

     else
         return []
 
-window.add_to_cart = (code) ->
+window.update_cart = (code, quantity) ->
     cart = cart_items()
     if code not in cart
         cart.push code
         $.cookie 'cart', cart.join ';'
+    $.cookie code, quantity
 
 window.store_item = (code, props) ->
     localStorage.setItem code, props.join ';'
 
 window.retr_item = (code) ->
-    return localStorage.getItem(code).split ';'
+    props = localStorage.getItem(code)
+    if props
+        return props.split ';'
+    else
+        return null
 
 window.remove_from_cart = (code) ->
     cart = cart_items()
     if loc >= 0
         cart = cart.slice(0, loc).concat cart.slice loc + 1
         $.cookie 'cart', cart.join ';'
+    $.cookie code, null
 
-item_row = (code) ->
+item_row = (code, editable) ->
     data = retr_item code
+    quantity = $.cookie(code) or 1
     if data
-        row = $ '<tr><td><input type="text" name="item" /></td></tr>'
-        row.find('input').attr('id', code).attr 'value', data[0]
-        row.append $('<td />').text val for val in data.slice 1
+        if editable
+            row = $ '<tr><td><input type="text" name="item" /></td></tr>'
+            row.find('input').attr('id', code).attr 'value', quantity
+        else
+            row = $ '<tr><td /></tr>'
+            row.find('td').text quantity
+        row.append $('<td />').text val for val in data
         return row
     else
         alert "cannot find #{code}"
 
 store_item_from_row = (checkbox) ->
     props = ($(td).text().trim() for td in $(checkbox).closest('td').siblings())
-    props.unshift 1
     store_item checkbox.value, props
 
 $ ->
     $('form.cartadd').submit ->
         map_to_items this, store_item_from_row
-        map_to_items this, (item) -> add_to_cart item.value
+        map_to_items this, (item) -> update_cart item.value, 1
     $('table.cart').each ->
         table = $(this)
+        editable = not table.hasClass 'static'
         if cart_items().length
-            table.append row for row in (item_row code for code in cart_items())
+            table.append row for row in (item_row code, editable for code in cart_items())
             table.find('td:last-child').attr 'class', 'number'
             table.find('td:nth-child(6)').attr 'class', 'number'
         else
         if /^[0-9]+$/.exec this.value
             if this.value is '0'
                 remove_from_cart this.id
-                $(this).closest('tr').attr('class', 'grey')
+                $(this).closest('tr').attr 'class', 'grey'
             else
                 props = retr_item this.id
-                props[0] = this.value
                 store_item this.id, props
-                add_to_cart this.id
-                $(this).closest('tr').attr('class', '')
+                update_cart this.id, this.value
+                $(this).closest('tr').attr 'class', ''
         else
             alert 'Please enter a valid quantity.'
             this.value = this.defaultValue

File site/cart.shpaml

 ul.breadcrumb
     li
         &gt;
-        a href=index.html | Bookshop
+        a href=index.php | Bookshop
     li
         &gt;
-        a href=cart.html | Shopping cart
+        a href=cart.php | Shopping cart
 
 h1 | Shopping cart
-form.table.cartremove method=get action=purchase.html
+form.table.cartremove method=get action=purchase.php
     p | Set the quantity of an item to 0 to remove it.
     table.cart
         tr

File site/compiled/print_icon.gif

Added
New image

File site/global.coffee

         link_bn = url_basename $(this).attr 'href'
         if link_bn is cur_bn or link_bn is '#'
             $(this).attr 'class', 'selected'
+    $('a.print').click ->
+        window.print()

File site/global.sass

     .grey
         color: #bbb
 
+table.cart
+    clear: both
+    input[type="text"]
+        width: 2em
+
+a.print
+    text-decoration: none
+    span
+        position: relative
+        top: -2px
+    &.right
+        float: right
+    &:hover
+        span
+            text-decoration: underline
+
 #right
     margin-top: 1px
     background-color: $nav-bg

File site/index.shpaml

 ul.breadcrumb
     li
         &gt;
-        a href=index.html | Bookshop
-form.block method=get action=search_results.html
+        a href=index.php | Bookshop
+form.block method=get action=search_results.php
     > input type=text name=query placeholder="Enter search terms"
     > input type=submit value=Search
-    a href=search_help.html | Help
+    a href=search_help.php | Help
     .options
-        > input type=radio name=by value=keywords id=by-keywords checked=checked
-        label for=by-keywords | Keywords
-        > input type=radio name=by value=author id=by-author
+        > input type=radio name=by value=bookTitle id=by-title checked=checked
+        label for=by-title | Title/Name
+        > input type=radio name=by value=bookAuthor id=by-author
         label for=by-author | Author/Supplier
-        > input type=radio name=by value=number id=by-number
+        > input type=radio name=by value=bookISBN id=by-number
         label for=by-number | ISBN/EAN/Item No.
-        > input type=radio name=by value=title id=by-title
-        label for=by-title | Title/Name
 .panel.left
     ul
         li
             > img src=http://www.swinburne.edu.au/lib/images/libraryhome/icon-papers.jpg
-            a href=booklists.html | Booklists
+            a href=booklists.php | Booklists
             p | Purchase from subject booklists
 .panel.right
     ul
         li
             > img src=black_hoodie.jpg height=52 width=52
-            a href=product_hoodies.html | Varsity Hoodies
+            a href=product_hoodies.php | Varsity Hoodies
             p | New product

File site/product_hoodies.shpaml

 {{inherit "wrapper.tmpl"}}
 {{def bins}}
 li
-    a.inscope href=product_list.html | Product list
+    a.inscope href=product_list.php | Product list
     ul
         li
-            a href=product_hoodies.html | Varsity Hoodies
+            a href=product_hoodies.php | Varsity Hoodies
 {{enddef}}
 {{py: global left_insert; left_insert = {'Product list': bins()} }}
 {{def title}}Varsity Hoodies{{enddef}}
 ul.breadcrumb
     li
         &gt;
-        a href=index.html | Bookshop
+        a href=index.php | Bookshop
     li
         &gt;
-        a href=product_list.html | Product list
+        a href=product_list.php | Product list
     li
         &gt;
         a href=# | Varsity Hoodies

File site/product_list.shpaml

 {{inherit "wrapper.tmpl"}}
 {{def bins}}
 li
-    a href=product_list.html | Product list
+    a href=product_list.php | Product list
     ul
         li
-            a href=product_hoodies.html | Varsity Hoodies
+            a href=product_hoodies.php | Varsity Hoodies
 {{enddef}}
 {{py: global left_insert; left_insert = {'Product list': bins()} }}
 {{def title}}Product list{{enddef}}
 ul.breadcrumb
     li
         &gt;
-        a href=index.html | Bookshop
+        a href=index.php | Bookshop
     li
         &gt;
         a href=# | Product list
     ul
         li
             > img src=https://bookshop.swin.edu.au/html/images/product/black_hoodie.jpg
-            a href=product_hoodies.html | Varsity Hoodies
+            a href=product_hoodies.php | Varsity Hoodies
             p | Be proud and show off your University to everyone you meet

File site/purchase.shpaml

 ul.breadcrumb
     li
         &gt;
-        a href=index.html | Bookshop
+        a href=index.php | Bookshop
     li
         &gt;
-        a href=cart.html | Shopping cart
+        a href=cart.php | Shopping cart
     li
         &gt;
         a href=# | Complete purchase
 
 h1 | Complete purchase
-table.cart
+table.cart.static
     tr
         th | Item
         th | Type
         th | In Stock
         th | Price A$
 
-form.table#shipping method=get action=receipt.html
+form.table#shipping method=get action=receipt.php
     table
         caption | Shipping
         tr

File site/receipt.shpaml

 {{py: global left_insert; left_insert = {} }}
 {{def title}}Receipt{{enddef}}
 {{def stylesheet}}purchase{{enddef}}
+{{def script}}cart{{enddef}}
 ul.breadcrumb
     li
         &gt;
-        a href=index.html | Bookshop
+        a href=index.php | Bookshop
     li
         &gt;
-        a href=cart.html | Shopping cart
+        a href=cart.php | Shopping cart
     li
         &gt;
         a href=# | Receipt
 
 h1 | Receipt
 h2 | #12345678
-p | Please print this receipt for your records.
-table
+p
+    Please print this receipt for your records.
+    a.print.right href=#
+        > img src=print_icon.gif width=16 height=16
+        span | Print
+table.cart.static
     tr
         th | Item
         th | Type
         th | ISBN/Item No.
         th | In Stock
         th | Price A$
-    tr
-        td
-            a href=construction.html | User Interface Design & Evaluation
-        td | Prescribed Text
-        td | Stone & Woodroffe
-        td.number | 9780120884360
-        td.number | 6
-        td.number | $112.95

File site/search.php

+<?php
+	$searchParam = $_GET["by"];
+	$searchValue = $_GET["query"];
+	$DB = mysql_connect("mysql.ict.swin.edu.au",
+		"s9510621",
+		"160892"
+	);
+	mysql_select_db("s9510621_db",$DB);
+	$query = "select * from bookShop where ".$searchParam." like '%".$searchValue."%';";
+	$result = mysql_query($query);
+	if(!$result)
+	{
+		echo "<p>No items found.</p>";
+	}
+	else
+	{
+#		echo '<form method="POST" action="Shoppingcart_add.php">';
+		echo '<table>';
+		echo '<tr>';
+		echo '<th>Add</th>';
+		echo '<th>Item</th>';
+		echo '<th>Type</th>';
+		echo '<th>Author/Supplier</th>';
+		echo '<th>ISBN/Item No.</th>';
+		echo '<th>In Stock</th>';
+		echo '<th>Price A$</th>';
+		echo '</tr>';
+		while($row = mysql_fetch_array($result))
+		{
+			echo '<tr>';
+			echo '<td><input type="checkbox" value="'.$row["bookCode"].'" name="item"/></td>';
+			echo '<td>'.$row["bookTitle"].'</td>';
+			echo '<td>'.$row["bookType"].'</td>';
+			echo '<td>'.$row["bookAuthor"].'</td>';
+			echo '<td>'.$row["bookISBN"].'</td>';
+			echo '<td class="number">'.$row["bookStock"].'</td>';
+			echo '<td class="number">$'.$row["bookPrice"].'</td>';
+			echo '</tr>';
+		}
+		mysql_close($DB);
+		echo '</table>';
+		echo '<input type="Submit" value="Add to cart"/>';
+#		echo '</form>';
+	}
+?>

File site/search_help.shpaml

 ul.breadcrumb
     li
         &gt;
-        a href=index.html | Bookshop
+        a href=index.php | Bookshop
     li
         &gt;
-        a href=search_help.html | Search help
+        a href=search_help.php | Search help
 
 h1 | Search help
 ul

File site/search_results.shpaml

 {{inherit "wrapper.tmpl"}}
 {{py: global left_insert; left_insert = {} }}
+{{py: with open('site/search.php') as f: search_php = f.read() }}
 {{def title}}Search results{{enddef}}
+{{def script}}cart{{enddef}}
 ul.breadcrumb
     li
         &gt;
-        a href=index.html | Bookshop
+        a href=index.php | Bookshop
     li
         &gt;
         a href=# | Search results
-form.block method=get action=search_results.html
+form.block method=get action=search_results.php
     > input type=text name=query placeholder="Enter search terms" value=""
     > input type=submit value=Search
-    a href=search_help.html | Help
+    a href=search_help.php | Help
     .options
-        > input type=radio name=by value=keywords id=by-keywords checked=checked
-        label for=by-keywords | Keywords
-        > input type=radio name=by value=author id=by-author
+        > input type=radio name=by value=bookTitle id=by-title checked=checked
+        label for=by-title | Title/Name
+        > input type=radio name=by value=bookAuthor id=by-author
         label for=by-author | Author/Supplier
-        > input type=radio name=by value=number id=by-number
+        > input type=radio name=by value=bookISBN id=by-number
         label for=by-number | ISBN/EAN/Item No.
-        > input type=radio name=by value=title id=by-title
-        label for=by-title | Title/Name
-form.table method=get action=construction.html
-    table
-        tr
-            th | Add
-            th | Item
-            th | Type
-            th | Author/Supplier
-            th | ISBN/Item No.
-            th | In Stock
-            th | Price A$
-        tr
-            td
-                > input type=checkbox name=item value=9780120884360
-            td
-                a href=construction.html | User Interface Design & Evaluation
-            td | Prescribed Text
-            td | Stone & Woodroffe
-            td.number | 9780120884360
-            td.number | 6
-            td.number | $112.95
-    > input type=submit value="Add to cart"
+form.table.cartadd method=get action=cart.php
+    {{search_php | html}}

File site/wrapper.shpaml

-{{py: left_links = (('Home', 'index.html'), ('Academic staff', 'construction.html'), ('Booklists', 'booklists.html'), ('Second-hand textbooks', 'construction.html'), ('Product list', 'product_list.html'), ('Request an item', 'construction.html'), ('Contact us', 'construction.html'), ('Locations', 'construction.html'), ('Information', 'construction.html')) }}
-<?xml version="1.0" encoding="utf-8"?>
+{{py: left_links = (('Home', 'index.php'), ('Academic staff', 'construction.php'), ('Booklists', 'booklists.php'), ('Second-hand textbooks', 'construction.php'), ('Product list', 'product_list.php'), ('Request an item', 'construction.php'), ('Contact us', 'construction.php'), ('Locations', 'construction.php'), ('Information', 'construction.php')) }}
+<?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?>
 <!DOCTYPE html>
 html xmlns=http://www.w3.org/1999/xhtml xml:lang=en
     head
                            {{endif}}
                           {{endfor}}
                     #right
-                        a href=construction.html
+                        a href=construction.php
                             > img src=login-key.png
                             p
                                 strong | Login
                                 for an 8% discount
-                        a href=cart.html
+                        a href=cart.php
                             > img src=shopping-cart-icon.png
                             p | Shopping cart
         #footer-wrapper