From ab7076adcc45da24e996a37012bf30194c8b5d33 Mon Sep 17 00:00:00 2001 From: Jack Lucas Date: Thu, 9 Mar 2017 17:34:33 -0500 Subject: [PATCH 1/9] Work on pictures being resized for speed --- main.lisp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/main.lisp b/main.lisp index de85756..ccf4b26 100644 --- a/main.lisp +++ b/main.lisp @@ -5,7 +5,8 @@ :cl-pass :hunchentoot :parenscript - :trivial-shell)) + :trivial-shell + :opticl)) (defvar *current-message-list* '()) (defvar *global-invoice-list* '()) @@ -274,6 +275,24 @@ :name image-name) (make-pathname :directory invoice-location :name image-name) :overwrite t) + (ensure-directories-exist (concatenate 'string invoice-location "webimg/")) + (let* ((new-img-name (concatenate 'string (invoice-set-name current-invoice) + "-" + (show-name current-invoice) + "-" + (write-to-string (invoice-id-num current-invoice)) + ".jpg"))) + + + (cl-fad:copy-file (make-pathname :directory temp-image-directory + :name image-name) + (make-pathname :directory (concatenate 'string invoice-location "webimg/") + :name new-img-name) :overwrite t) + (let* ((new-img-path (make-pathname :directory (concatenate 'string invoice-location "webimg/") + :name new-img-name)) + (img (read-jpeg-file new-img-path))) + (write-jpeg-file new-img-path (resize-image img 1200 1600)))) + (setf (invoice-id-num current-invoice) (+ (invoice-id-num current-invoice) 1)) (delete-file (make-pathname :directory temp-image-directory :name image-name)))) @@ -800,10 +819,6 @@ collect post-parameter))) (standard-page (:title "Picture Batch") (mapc #'(lambda (x) - (format t "~A ~A ~A ~A
" (first x) - (second x) - (third x) - (fourth x)) (rename-file (second x) (concatenate 'string "/tmp/" (third x)) :if-exists :supersede) @@ -898,7 +913,7 @@ (setname (invoice-set-name invoice)) (contact (invoice-contact-name invoice)) (change-pic-cookie (cookie-in "current-picture")) - (images (prepare-for-table (cl-fad:list-directory (invoice-root-dir invoice)))) + (images (prepare-for-table (cl-fad:list-directory (concatenate 'string (invoice-root-dir invoice) "webimg/")))) (images-filtered (sort-item-list (filter-already-in-itemlist images invoice) change-pic-cookie))) (set-cookie "current-picture" :value "") (standard-page (:title "Order Writeup") From 138a15f5fd5b9031829dad67be4143aaa87076b4 Mon Sep 17 00:00:00 2001 From: Jack Lucas Date: Thu, 9 Mar 2017 20:23:30 -0500 Subject: [PATCH 2/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f824a7c..50d1448 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # RILEY RILEY is licensed under rileyMIT. By using this software you pledge undying loyalty and ultimate power to Riley as your new Queen. -![Queen Riley](https://i.sli.mg/BROLOa.jpg) +![Queen Riley](https://i.imgur.com/HVWtgvZ.jpg) From b633e4905fb7750e578377210fa4dd7e7490f2e5 Mon Sep 17 00:00:00 2001 From: Jack Lucas Date: Thu, 9 Mar 2017 23:06:58 -0500 Subject: [PATCH 3/9] More themeing work --- main.lisp | 208 +++++++++++++++++------------------- www/plugins/input-upload.js | 3 + www/plugins/jq-input.js | 93 ++++++++++++++++ 3 files changed, 197 insertions(+), 107 deletions(-) create mode 100644 www/plugins/input-upload.js create mode 100644 www/plugins/jq-input.js diff --git a/main.lisp b/main.lisp index ccf4b26..f9eadf1 100644 --- a/main.lisp +++ b/main.lisp @@ -320,21 +320,18 @@ ;(:script :src "js/ajax-item.js") (:script :src "js/materialize.min.js") (:link :href "https://fonts.googleapis.com/icon?family=Material+Icons" :rel "stylesheet") - (:link :type "text/css" - :rel "stylesheet" - :href "plugins/dataTables/datatables.min.css") - (:script :src "plugins/dataTables/datatables.min.js") - (:script :src "plugins/dataTables/Responsive-2.1.1/js/dataTables.responsive.min.js") - (:link :type "text/css" - :rel "stylesheet" - :href "plugins/dataTables/Responsive-2.1.1/css/responsive.dataTables.min.css")) - + (:script :src "plugins/jq-input.js")) (:body ,@navbar (:div :class "container" (:div :class "section" - ,@body)))))) + ,@body))) + (:footer :class "page-footer red darken-4" + (:div :class "container" + (:div :class "row" + (:h5 :class "center white-text" "Made with Powerful Parenthesis"))))))) + (defmacro standard-three-nine-hook ((&key bodythree) &body bodynine) `(with-html-output (*standard-output* nil :indent t) @@ -420,7 +417,7 @@ (:nav :class "red darken-4" (:div :class "nav-wrapper" - (:a :class "brand-logo" "CAPS") + (:a :class "center brand-logo" "CAPS") (:a :href "#" :data-activates "mobile-demo" :class "button-collapse" (:i :class "material-icons" "menu")) @@ -481,41 +478,48 @@ (defmacro standard-item-writeup (&key image full-images invoice-data) - `(with-html-output (*standard-output* nil :indent t) - (:div :class "card" :id "box-picture" - (:div :class "card-content" - (:span :class "card-title" - (:center (:img :id "input-picture" :src ,image :class "img-responsive materialboxed" - :width "40%" :height "40%" :name ,image))) - + `(with-html-output (*standard-output* nil :indent t) + (:div :class "section" + (:div :class "row blue-grey" + (:div :class "col s12 m6 l6" + (:div :class "card" + (:div :class "card-image" + (:img :id "input-picture" :src ,image :class "materialboxed responsive-img" :name ,image)))) + (:div :class "col s12 m6 l6" + + (:div :class "card" :id "box-picture" + + + (:div :class "card-content" (:form :action "/additem" :method "POST" :id "new-item" - (:div :class "input-field s12" - (:label :for "inputDesc" "Description") + (:div :class "input-field col s12 l12 m12" + (:label :for "inputDesc" :class "black-text" "Description") - (:input :type "text" :class "form-control" + (:input :type "text" :id "input-item-description" :name "input-item-description")) - (:div :class "input-field s6" + (:div :class "input-field col s12 l6 m6" - (:label :for "inputPrice" "Price") - (:input :type "text" :class "form-control" + (:label :for "inputPrice" :class "black-text" "Price") + (:input :type "text" :id "input-item-price" :name "input-item-price")) - (:div :class "input-field s6" + (:div :class "input-field col s12 m6 l6" - (:label :for "inputQty" "Quantity") - (:input :type "text" :class "form-control" + (:label :for "inputQty" :class "black-text" "Quantity") + (:input :type "text" :id "input-item-qty" :name "input-item-qty")) (:input :type "hidden" :id "image-data" :name "image-data" :value ,image) - (:button :type "submit" :class "btn waves-effect waves-light" "Add item") - (:button :type "button" :class "btn waves-effect waves-light" - :data-toggle "modal" :data-target "#myModal" "Switch Item or Add Multiple Pictures"))) - (:div :id "form-messages") + (:button :type "submit" :class "red darken-4 btn waves-effect waves-light" "Add") + (:button :type "button" :class "red darken-4 btn waves-effect waves-light" + :data-toggle "modal" :data-target "#myModal" "Switch"))))))) + + ;(:script :src "plugins/custom/ajax-item.js") (:div :id "myModal" :class "modal fade" :role "dialog" @@ -533,7 +537,7 @@ :name "image-name" :value img) (:input :type "image" :id "saveform" :class "img-responsive" :width "40%" :height "40%" :src img - :alt "Submit Form")))))))))))) + :alt "Submit Form"))))))))))) (defmacro standard-order-intro () `(with-html-output (*standard-output* nil :indent t) @@ -557,21 +561,7 @@ (:input :type "text" :class "form-control" :id "inputContact" :name "inputContact")) (:div :class "center" - (:button :type "submit" :class "btn waves-effect waves-light" "Write Show Order" (:i :class "material-icons right" "send")))))))) - -(defmacro standard-picture-table (&key image-list) - `(with-html-output (*standard-output* nil :indent t) - (:div :class "" - (:div :class "" - "List of pictures to be written up" - (:div :class "box-tools pull-right" - (:button :class "btn btn-box-tool" :data-widget "collapse" - (:i :class "fa fa-plus")))) - (:div :class "box-body" - (dolist (image ,image-list) - (htm (:div :class "" - (:img :src image :class "img-responsive" - :width "40%" :height "40%")))))))) + (:button :type "submit" :class "red darken-4 btn waves-effect waves-light" "Write Show Order" (:i :class "material-icons right" "send")))))))) (defmacro standard-check-in-showlist () `(with-html-output (*standard-output* nil :indent t) @@ -598,26 +588,28 @@ :name "setname" :id "setname") (:input :type "hidden" :value (show-name invoice) :name "showname" :id "showname") - (:button :type "submit" :class "btn btn-small" + (:button :type "submit" :class "red darken-4 btn btn-small" "Check In"))))))))))) (defmacro standard-item-list-table (&key invoice) `(with-html-output (*standard-output* nil :indent t) - (:div :class "row" - (:input :type "text" :id "myInput" :onkeyup "myFunction()" :placeholder "Search for items") + (:div :class "row" + (:div :class "input-field col s12 l6 m6" + (:label :for "myInput" :class "black-text" "Search") + (:input :type "text" :id "myInput" :onkeyup "myFunction()" :class "black-text")) (:script :src "plugins/search.js") (:ul :id "myUL" (dolist (item (invoice-item-list ,invoice)) (htm (:li (:div :class "col s12 m6 l6" - (:div :class "card" + (:div :class "card blue-grey" (:div :class "card-image" - (:img :src (item-picture item) :width "25%" :height "25%" :class "materialboxed") + (:img :src (item-picture item) :width "25%" :height "25%" :class "materialboxed responsive-img") (:span :class "black card-title" (fmt "~A" (escape-string (item-description item))))) (:div :class "card-content" - (:div :class "chip" (fmt "Price: ~A" (escape-string (item-price item)))) - (:div :class "chip" (fmt "Quantity: ~A" (escape-string (item-quantity item))))) + (:div :class "chip black-text" (fmt "Price: ~A" (escape-string (item-price item)))) + (:div :class "chip black-text" (fmt "Quantity: ~A" (escape-string (item-quantity item))))) (:div :class "card-action" (:form :class "form-inline" :action "/removeitem" @@ -632,7 +624,7 @@ (:input :type "hidden" :value ,invoice :name "invoice" :id "invoice") (if (string= (item-returned-on item) "") - (htm (:button :type "submit" :class "btn btn-default btn-sm btn-danger" "Remove")) + (htm (:button :type "submit" :class "red darken-4 btn btn-default btn-sm btn-danger" "Remove")) (htm (:button :type "submit" :class "btn btn-sm btn-danger disabled" :disabled "true" (fmt "RTN'D ~A" (escape-string (item-returned-on item))))))))))))))))) ;;;Force remove option may be necessary due to this @@ -642,30 +634,26 @@ (defmacro standard-check-in (&key invoice) `(with-html-output (*standard-output* nil :indent t) - (:div :class "card" - (:div :class "card-content" - (:table :id "checkinlist" :class "table table-bordered table-striped" - (:thead - (:tr - (:th "Picture") - (:th "Description") - (:th "QTY") - (:th "Price") - (:th "Check?"))) - (:tbody + (:div :class "row" + (:div :class "input-field col s12 l6 m6" + (:label :for "myInput" :class "black-text" "Search") + (:input :type "text" :id "myInput" :class "black-text" :onkeyup "myFunction()")) + (:ul :id "myUL" (dolist (item (remove-returned (invoice-item-list ,invoice))) (htm - - (:tr - (:td - (:img :src (item-picture item) :class "img-responsive materialboxed" - :width "40%" :height "40%"))) + (:li + (:div :class "col s12 m6 l6" + (:div :class "card blue-grey" + (:div :class "card-image" + (:img :src (item-picture item) :class "materialboxed responsive-img") + (:span :class "card-title black" (fmt "~A" (escape-string (item-description item))))) + (:div :class "card-content" - (:td (fmt "~A" (escape-string (item-description item)))) - (:td (fmt "~A" (escape-string (item-quantity item)))) - (:td (fmt "~A" (escape-string (item-price item)))) - (:td - (:form :class "form-inline" + + (:div :class "chip black-text" (fmt "Price: ~A" (escape-string (item-price item)))) + (:div :class "chip black-text" (fmt "Quantity: ~A" (escape-string (item-quantity item)))) + (:div :class "card-action" + (:form :action "/check-in-item" :method "POST" :id "check-in-table" @@ -676,29 +664,29 @@ :value (item-description item)) (:input :type "hidden" :name "item-qty" :id "item-qty" :value (item-quantity item)) - (:button :type "submit" :class "btn" "Check in")))))))) - (:script "$(\"#checkinlist\").DataTable();")))) + (:button :type "submit" :class "red darken-4 btn waves-effect waves-light" "Check in")))))))))) + (:script :src "plugins/search.js")))) + (defmacro standard-picture-upload () `(with-html-output (*standard-output* nil :indent t) - (:div :class "card" - (:div :class "card-content" - (:span :class "card-title" (:h5 "Upload")) - - (:form :action "/displayimagegot" - :class "form-inline" + (:div :class "row" + (:div :class "col s12 m12 l12" + (:form :action "/displayimagegot" :method "POST" :enctype "multipart/form-data" :id "new-picture-upload" - (:div :class "form-group" - (:input - :multiple "multiple" - :id "picture-batch" - :name "picture-batch" - :type "file" - :name "img") - (:input :type "submit"))))))) + (:div + (:input + :class "btn" + :multiple "multiple" + :id "picture-batch" + :name "picture-batch" + :type "file" + :name "img") + (:button :type "submit" :height "10%" :width "10%" :class "blue-grey btn waves-effect waves-light" "Upload"))))) + (:script :src "plugins/input-upload.js"))) (defmacro standard-pdf-iframe (&key pdf) `(with-html-output (*standard-output* nil :indent t) @@ -709,22 +697,24 @@ (defmacro standard-invoice-writing (&key show set contact pic-num) `(with-html-output (*standard-output* nil :indent t) - (:div :class "card blue-grey" :id "invoice-writing-box" - (:div :class "card-content" + (:br) + (:div :class "row" + (:div :class "col s12 m6 l6" (:div :class " black-text chip s3 m3 l3" ,show) (:div :class "black-text chip s3 m3 l3" ,set) - (:br) (:div :class "black-text chip s3 m3 l3" ,contact) (:div :class "black-text chip s3 m3 l3" - ,pic-num) - (:br) - (:a :href "/createpdf" (:button :type "submit" :class "btn waves-effect waves-light" - "Create PDF")) - (:a :href "/check-in-set" (:button :type "submit" :class "btn waves-effect waves-light" "Check-in Items")) - (:a :href "/setthemcookies" (:button :type "submit" :class "btn waves-effect waves-light" "Invoice Home")))))) + ,pic-num)) + (:div :class "col s12 m6 l6" + + + (:a :href "/createpdf" (:button :type "submit" :class "red darken-4 btn waves-effect waves-light" + "PDF")) + (:a :href "/check-in-set" (:button :type "submit" :class "red darken-4 btn waves-effect waves-light" "Check")) + (:a :href "/setthemcookies" (:button :type "submit" :class "red darken-4 btn waves-effect waves-light" "Invoice")))))) ;;;Define page handler functions @@ -886,7 +876,11 @@ (setname (invoice-set-name invoice))) (standard-page (:title (concatenate 'string "Check in: " showname "-" setname)) (:navbar (test-navbar)) - (standard-invoice-writing) + (standard-invoice-writing :show (fmt "~A" (escape-string showname)) + :set (fmt "~A" (escape-string setname)) + :contact (fmt "~A" (escape-string (invoice-contact-name invoice))) + :pic-num (fmt "~A" (escape-string (count-pics-from-invoice (concatenate 'string showname + "-" setname))))) (standard-check-in :invoice invoice)))) @@ -920,9 +914,9 @@ (:navbar (test-navbar)) (standard-three-nine-hook (:bodythree - ((standard-invoice-writing :show (fmt "Showname: ~A" (escape-string showname)) - :set (fmt "Setname: ~A" (escape-string setname)) - :contact (fmt "Contact: ~A" (escape-string contact)) + ((standard-invoice-writing :show (fmt "~A" (escape-string showname)) + :set (fmt "~A" (escape-string setname)) + :contact (fmt "~A" (escape-string contact)) :pic-num (fmt "~A" (escape-string (count-pics-from-invoice (concatenate 'string showname "-" setname))))) (standard-picture-upload))) @@ -959,8 +953,8 @@ "0" (let* ((invoice (find-invoice-from-cookie inv)) (invoice-pathname (invoice-root-dir invoice))) - (concatenate 'string "There are " (write-to-string (filtered-length (cl-fad:list-directory invoice-pathname))) - " pictures on this order")))) + (concatenate 'string (write-to-string (filtered-length (cl-fad:list-directory invoice-pathname))) + " pictures on order")))) (defun filtered-length (directory-list) (length (remove-if #'(lambda (x) diff --git a/www/plugins/input-upload.js b/www/plugins/input-upload.js new file mode 100644 index 0000000..fb928cd --- /dev/null +++ b/www/plugins/input-upload.js @@ -0,0 +1,3 @@ +$(document).ready(function() { + $('#picture-batch').inputFileText( { text: 'Choose Pictures', buttonClass: 'red darken-4 btn waves-effect waves-light' } ); +}); diff --git a/www/plugins/jq-input.js b/www/plugins/jq-input.js new file mode 100644 index 0000000..8f85433 --- /dev/null +++ b/www/plugins/jq-input.js @@ -0,0 +1,93 @@ +(function($) { + + $.fn.inputFileText = function(userOptions) { + // Shortcut for plugin reference + var P = $.fn.inputFileText; + + var options = P.getOptions(userOptions); + + if(P.shouldRemoveInputFileText(this, options.remove)) { + return P.removeInputFileText(this); + } + else if(P.hasInputFileText(this)) { + return this; + } + + // Keep track of input file element's display setting + this.attr(P.DISPLAY_ATTRIBUTE, this.css('display')); + + // Hide input file element + this.css({ + display: 'none' + //width: 0 + }); + + // Insert button after input file element + var button = $( + '' + ).insertAfter(this); + + // Insert text after button element + var text = $( + '' + ).insertAfter(button); + + // Open input file dialog when button clicked + var self = this; + button.click(function() { + self.click(); + }); + + // Update text when input file chosen + this.change(function() { + // Chrome puts C:\fakepath\... for file path + text.text(self.val().replace('C:\\fakepath\\', '')); + }); + + // Mark that this plugin has been applied to the input file element + return this.attr(P.MARKER_ATTRIBUTE, 'true'); + }; + + $.fn.inputFileText.MARKER_ATTRIBUTE = 'data-inputFileText'; + $.fn.inputFileText.DISPLAY_ATTRIBUTE = 'data-inputFileText-display'; + + $.fn.inputFileText.getOptions = function(userOptions) { + return $.extend({ + // Defaults + text: 'Choose File', + remove: false, + buttonClass: '', + textClass: '' + }, userOptions); + }; + + /** + Check if plugin has already been applied to input file element. + */ + $.fn.inputFileText.hasInputFileText = function(inputFileElement) { + return inputFileElement.attr($.fn.inputFileText.MARKER_ATTRIBUTE) === 'true'; + }; + + /** + Check if plugin should be removed from input file element. + */ + $.fn.inputFileText.shouldRemoveInputFileText = function(inputFileElement, remove) { + return remove && $.fn.inputFileText.hasInputFileText(inputFileElement); + }; + + /** + Remove plugin from input file element. + */ + $.fn.inputFileText.removeInputFileText = function(inputFileElement) { + var P = $.fn.inputFileText; + + inputFileElement.next('input[type=button]').remove(); + inputFileElement.next('span').remove(); + return inputFileElement.attr(P.MARKER_ATTRIBUTE, null) + .css({ + display: inputFileElement.attr(P.DISPLAY_ATTRIBUTE) + }) + .attr(P.DISPLAY_ATTRIBUTE, null); + }; + +}(jQuery)); \ No newline at end of file From 6aea61dd1a258bf8d17a1ed62291cdcf4ef0a68f Mon Sep 17 00:00:00 2001 From: Jack Lucas Date: Fri, 10 Mar 2017 13:28:47 -0500 Subject: [PATCH 4/9] Need to work on github issues --- main.lisp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.lisp b/main.lisp index f9eadf1..61bba30 100644 --- a/main.lisp +++ b/main.lisp @@ -459,9 +459,10 @@ (defmacro standard-global-messages () `(with-html-output (*standard-output* nil :indent t) (:div :class "row" - (:div :class "col s12 m6" + (dolist (messages (find-global-messages)) (htm + (:div :class "col s12 m6 l6" (:div :class "card" (:div :class "card-content" (:span :class "card-title" (:h4 @@ -997,7 +998,7 @@ (redirect "/login")) (redirect "/badpassword")))) -;;;For the love of McCarthy please turn this into a macro already + (define-easy-handler (login :uri "/login") () (standard-page (:title "Login") (standard-login))) From f0fa9ab4eec18188fc889d699ecec3e12284476e Mon Sep 17 00:00:00 2001 From: Jack Lucas Date: Sun, 12 Mar 2017 14:02:53 -0400 Subject: [PATCH 5/9] Need to mess with parameters --- main.lisp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/main.lisp b/main.lisp index 61bba30..9d0e29f 100644 --- a/main.lisp +++ b/main.lisp @@ -581,16 +581,8 @@ (:td (fmt "~A" (escape-string (show-name invoice)))) (:td (fmt "~A" (escape-string (invoice-set-name invoice)))) (:td (fmt "~A" (escape-string (invoice-contact-name invoice)))) - (:td (:form :class "form-inline" - :action "/check-in-set-pre" - :method "POST" - :id "item-table" - (:input :type "hidden" :value (invoice-set-name invoice) - :name "setname" :id "setname") - (:input :type "hidden" :value (show-name invoice) - :name "showname" :id "showname") - (:button :type "submit" :class "red darken-4 btn btn-small" - "Check In"))))))))))) + (:td (:a :href (format nil "check-in-set-pre?showname=~a&setname=~a" (show-name invoice) (invoice-set-name invoice)) + :class "btn" "Check In")))))))))) (defmacro standard-item-list-table (&key invoice) `(with-html-output (*standard-output* nil :indent t) @@ -864,11 +856,9 @@ (standard-check-in-showlist))) ;;;Required to get around the refresh problem. Will need to expand solution -(define-easy-handler (check-in-set-pre :uri "/check-in-set-pre") () - (let* ((showname (hunchentoot:post-parameter "showname")) - (setname (hunchentoot:post-parameter "setname"))) +(define-easy-handler (check-in-set-pre :uri "/check-in-set-pre") (showname setname) (set-cookie "current-invoice" :value (concatenate 'string showname "-" setname)) - (redirect "/check-in-set"))) + (redirect "/check-in-set")) ;;;Presents a table of items that have not been checked in yet (define-easy-handler (checkinset :uri "/check-in-set") () From a79392fe6689ebbff0b98ac36a6957ec09ca5082 Mon Sep 17 00:00:00 2001 From: Jack Lucas Date: Sun, 12 Mar 2017 14:37:09 -0400 Subject: [PATCH 6/9] Starting work on show-list --- main.lisp | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/main.lisp b/main.lisp index 9d0e29f..300dfea 100644 --- a/main.lisp +++ b/main.lisp @@ -201,6 +201,17 @@ ;;;Find an invoice-object connected to a message ;;;Used for generating buttons on the dashboard + +(defun string-web-safe (stg) + (let* ((poz (position #\' stg)) + (sanitized-first (subseq stg 0 poz)) + (sanitized-last (subseq stg (+ poz 1)))) + (concatenate 'string sanitized-first "'" sanitized-last))) + +(defun web-safep (stg) + (if (position #\' stg) + (string-web-safe stg) + stg)) ;;;If an item already has a return date remove it from the check-in list ;;;before passing the data to the check-in page (defun remove-returned (inv-itemlist) @@ -566,23 +577,21 @@ (defmacro standard-check-in-showlist () `(with-html-output (*standard-output* nil :indent t) - (:div :class "container" - (:table :class "table table-bordered table-striped" - (:thead - (:tr - (:th "Show Name") - (:th "Set Name") - (:th "Contact") - (:th "Check In"))) - (:tbody + (:div :class "row" (dolist (invoice *global-invoice-list*) (htm - (:tr - (:td (fmt "~A" (escape-string (show-name invoice)))) - (:td (fmt "~A" (escape-string (invoice-set-name invoice)))) - (:td (fmt "~A" (escape-string (invoice-contact-name invoice)))) - (:td (:a :href (format nil "check-in-set-pre?showname=~a&setname=~a" (show-name invoice) (invoice-set-name invoice)) - :class "btn" "Check In")))))))))) + (:div :class "col s12 m4 l4" + (:div :class "card" + (:div :class "card-content" + (:span :class "card-title" (:h5 + (fmt "~A" (escape-string (show-name invoice))))) + + + (:div :class "chip black-text" (fmt "Set: ~A" (escape-string (invoice-set-name invoice)))) + (:div :class "chip black-text" (fmt "Contact: ~A" (escape-string (invoice-contact-name invoice)))) + (:div :class "card-action" + (:a :href (format nil "check-in-set-pre?showname=~a&setname=~a" (web-safep (show-name invoice)) (web-safep (invoice-set-name invoice))) + :class "btn waves-effect waves-light" "Show Page")))))))))) (defmacro standard-item-list-table (&key invoice) `(with-html-output (*standard-output* nil :indent t) From ee2418724b60552be1c9618ead350c50d52037ff Mon Sep 17 00:00:00 2001 From: Jack Lucas Date: Sun, 12 Mar 2017 18:08:07 -0400 Subject: [PATCH 7/9] Working on item table for pdf's --- invoice.cls | 2 +- main.lisp | 119 ++++++++++++++++++++++++++++---------------- www/js/ajax-item.js | 37 ++++++++++---- 3 files changed, 104 insertions(+), 54 deletions(-) diff --git a/invoice.cls b/invoice.cls index 3270cbd..7be12e9 100644 --- a/invoice.cls +++ b/invoice.cls @@ -52,7 +52,7 @@ } \begin{longtable}{|c|c|c|} - {\bf Item Images} & {\bf Item Images} & {\bf Item Images} \\ + {\bf Item} & {\bf Item} & {\bf Item} \\ \hline \hline \endhead }{ \hline diff --git a/main.lisp b/main.lisp index 300dfea..20b2c01 100644 --- a/main.lisp +++ b/main.lisp @@ -206,12 +206,19 @@ (let* ((poz (position #\' stg)) (sanitized-first (subseq stg 0 poz)) (sanitized-last (subseq stg (+ poz 1)))) - (concatenate 'string sanitized-first "'" sanitized-last))) + (web-safep (concatenate 'string sanitized-first "'" sanitized-last)))) + (defun web-safep (stg) (if (position #\' stg) (string-web-safe stg) stg)) + +(defun directory-safe (stg) + (remove-if #'(lambda (x) + (or (char= x #\ ) + (char= x #\'))) + stg)) ;;;If an item already has a return date remove it from the check-in list ;;;before passing the data to the check-in page (defun remove-returned (inv-itemlist) @@ -298,9 +305,9 @@ (cl-fad:copy-file (make-pathname :directory temp-image-directory :name image-name) (make-pathname :directory (concatenate 'string invoice-location "webimg/") - :name new-img-name) :overwrite t) + :name (directory-safe new-img-name)) :overwrite t) (let* ((new-img-path (make-pathname :directory (concatenate 'string invoice-location "webimg/") - :name new-img-name)) + :name (directory-safe new-img-name))) (img (read-jpeg-file new-img-path))) (write-jpeg-file new-img-path (resize-image img 1200 1600)))) (setf (invoice-id-num current-invoice) (+ (invoice-id-num current-invoice) 1)) @@ -529,28 +536,29 @@ (:button :type "submit" :class "red darken-4 btn waves-effect waves-light" "Add") (:button :type "button" :class "red darken-4 btn waves-effect waves-light" - :data-toggle "modal" :data-target "#myModal" "Switch"))))))) + :data-target "myModal" "Switch"))))))) ;(:script :src "plugins/custom/ajax-item.js") - (:div :id "myModal" :class "modal fade" :role "dialog" - (:div :class "modal-dialog" - (:div :class "modal-content" - (:div :class "modal-header" - (:button :type "button" :class "close" :data-dismiss "modal" "Close") - (:h4 :class "modal-title" "Switch or Add multiple pictures") - (:div :class "modal-body" :id "modalImg" - (dolist (img ,full-images) - (htm - (:form :action "/swapitemposition" - :method "POST" - (:input :type "hidden" :id "image-name" - :name "image-name" :value img) - (:input :type "image" :id "saveform" :class "img-responsive" - :width "40%" :height "40%" :src img - :alt "Submit Form"))))))))))) - + (:div :id "myModal" :class "modal bottom-sheet" + + (:div :class "modal-content" + + (:h4 "Switch Pictures") + + (dolist (img ,full-images) + (htm + (:div :class "col s12 m6 l6" + (:form :action "/swapitemposition" + :method "POST" + (:input :type "hidden" :id "image-name" + :name "image-name" :value img) + (:input :type "image" :id "saveform" :class "img-responsive" + :width "100%" :height "50%" :src img + :alt "Submit Form")))))) + (:script "$(document).ready(function(){ $('.modal').modal(); });")))) + (defmacro standard-order-intro () `(with-html-output (*standard-output* nil :indent t) @@ -591,7 +599,9 @@ (:div :class "chip black-text" (fmt "Contact: ~A" (escape-string (invoice-contact-name invoice)))) (:div :class "card-action" (:a :href (format nil "check-in-set-pre?showname=~a&setname=~a" (web-safep (show-name invoice)) (web-safep (invoice-set-name invoice))) - :class "btn waves-effect waves-light" "Show Page")))))))))) + :class "chip blue-grey" "Check-in") + (:a :href (format nil "pre-set-cookies?showname=~a&setname=~a" (web-safep (show-name invoice)) (web-safep (invoice-set-name invoice))) + :class "chip blue-grey" "Invoice")))))))))) (defmacro standard-item-list-table (&key invoice) `(with-html-output (*standard-output* nil :indent t) @@ -599,7 +609,8 @@ (:div :class "input-field col s12 l6 m6" (:label :for "myInput" :class "black-text" "Search") (:input :type "text" :id "myInput" :onkeyup "myFunction()" :class "black-text")) - (:script :src "plugins/search.js") + (:script :src "plugins/search.js") + (:div :id "itemlist" (:ul :id "myUL" (dolist (item (invoice-item-list ,invoice)) (htm @@ -628,7 +639,7 @@ (if (string= (item-returned-on item) "") (htm (:button :type "submit" :class "red darken-4 btn btn-default btn-sm btn-danger" "Remove")) (htm (:button :type "submit" :class "btn btn-sm btn-danger disabled" :disabled "true" - (fmt "RTN'D ~A" (escape-string (item-returned-on item))))))))))))))))) + (fmt "RTN'D ~A" (escape-string (item-returned-on item)))))))))))))))))) ;;;Force remove option may be necessary due to this @@ -695,7 +706,7 @@ (:iframe :id "iframepdf" :height "600" :width "100%" - :src ,pdf))) + :src (concatenate 'string (web-safep ,pdf) "?name=")))) (defmacro standard-invoice-writing (&key show set contact pic-num) `(with-html-output (*standard-output* nil :indent t) @@ -730,8 +741,8 @@ (root-dir (concatenate 'string (directory-namestring (acceptor-document-root *acceptor*)) "show-bank" "/" - showname - "/" setname "/"))) + (directory-safe showname) + "/" (directory-safe setname) "/"))) (ensure-directories-exist root-dir) (register-invoice :id-num (+ *global-invoice-id* 1) :set-name setname @@ -821,10 +832,9 @@ ;;;Current solution to being able to refresh pages without putting data in the URI ;;;May need to start putting data in the URI but the function works pretty decently already. -(define-easy-handler (pre-set-cookies :uri "/pre-set-cookies") () - (set-cookie "current-invoice" :value (concatenate 'string (hunchentoot:post-parameter "showname") - "-" - (hunchentoot:post-parameter "setname"))) +(define-easy-handler (pre-set-cookies :uri "/pre-set-cookies") (showname setname) + (set-cookie "current-invoice" :value (concatenate 'string showname "-" setname)) + (redirect "/setthemcookies")) ;;;Adds an item from the additem panel on the write order page @@ -1008,12 +1018,17 @@ (defparameter header-name "\\dotfill \\textsc{Ordered by:} ") (defparameter header-set "\\dotfill \\textsc{Set:} ") (defparameter header-show "\\dotfill \\textsc{Show:} ") -(defparameter date-header "\\tab {\\bf Pickup Date:} \\today \\dotfill") +(defparameter date-header "\\\\ {\\bf Pickup Date:} \\today \\dotfill") (defparameter rental-period "{\\bf {Rental Period:}") (defparameter begin-table "\\begin{invoiceTable}") (defparameter end-table "\\end{invoiceTable}") (defparameter unitrow "\\unitrow{") +(defparameter begin-img-table "\\begin{pictureTable}") +(defparameter end-img-table "\\end{pictureTable}") +(defparameter end-document "\\end{document}") +(defparameter begin-document "\\begin{document}") +(defparameter picrow "\\picrow{") ;;;Takes an invoice and root-dir (defparameter tail-conf " @@ -1022,8 +1037,7 @@ {\\color{red} \\textsc{Signature}}\\hspace{0.5cm} \\makebox[3in]{\\hrulefill} \\hspace{0.5cm} \\textsc{Date}\\hspace{0.5cm} \\makebox[1in]{\\hrulefill} \\\\ \\textsc{Print}\\hspace{1.25cm} \\makebox[3in]{\\hrulefill} -\\newpage -\\end{document}") +\\newpage") (defparameter document-conf "\\documentclass{invoice} % Use the custom invoice class (invoice.cls) @@ -1038,10 +1052,9 @@ \\usepackage{pgffor} \\usepackage{caption} \\usepackage{expl3} +") -\\begin{document}") - (defparameter heading-conf " \\hfil{\\huge\\color{red}{\\textsc{Checkout Sheet}}}\\hfil % \\bigskip\\break % Whitespace @@ -1053,20 +1066,20 @@ Ste. 000 \\hfill{ \\emph{Office:} (000) 000-0000} \\\\ % Your address and contact information Norfolk, Georgia 00000 \\hfill anon@anon.com \\\\ \\\\ -{\\bf Invoice To:} \\\\ % From here --->") +{\\bf Invoice To:} \\\\ ") ;;;Latex Functions---------------------------------------------- (defun generate-invoice-single-header (invoice func) - (concatenate 'string func invoice)) + (concatenate 'string func invoice " ")) (defun generate-latex (invoice root-dir) (ensure-directories-exist (concatenate 'string root-dir "pdf/")) - (let* ((pdfname (concatenate 'string "pdf/" (show-name invoice) - "-" (invoice-set-name invoice) + (let* ((pdfname (concatenate 'string "pdf/" (directory-safe (show-name invoice)) + "-" (directory-safe (invoice-set-name invoice)) ".tex")) - (ironic-tex-name (concatenate 'string "pdf/" (show-name invoice) - "-" (invoice-set-name invoice) + (ironic-tex-name (concatenate 'string "pdf/" (directory-safe (show-name invoice)) + "-" (directory-safe (invoice-set-name invoice)) ".pdf")) (complete-stream (concatenate 'string root-dir pdfname)) @@ -1074,7 +1087,13 @@ Norfolk, Georgia 00000 \\hfill anon@anon.com ironic-tex-name))) (with-open-file (s complete-stream :direction :output :if-exists :supersede) + (princ document-conf s) + (princ (concatenate 'string + "\\graphicspath{ {" + (invoice-root-dir invoice) + "webimg/}}") s) + (princ begin-document s) (fresh-line s) (princ heading-conf s) (princ (generate-invoice-single-header @@ -1083,8 +1102,10 @@ Norfolk, Georgia 00000 \\hfill anon@anon.com (invoice-set-name invoice) header-set) s) (princ (generate-invoice-single-header (invoice-contact-name invoice) header-name) s) + (fresh-line s) (fresh-line s) + (princ date-header s) (princ rental-period s) (fresh-line s) @@ -1094,7 +1115,12 @@ Norfolk, Georgia 00000 \\hfill anon@anon.com (fresh-line s)) (invoice-item-list invoice)) (princ end-table s) (fresh-line s) - (princ tail-conf s)) + (princ tail-conf s) + (princ begin-img-table s) + (mapc (lambda (b) (princ (format-picture b) s) + (fresh-line s)) (invoice-item-list invoice)) + (princ end-img-table s) + (princ end-document s)) (trivial-shell:shell-command (concatenate 'string "pdflatex " "-output-directory=" @@ -1111,7 +1137,12 @@ Norfolk, Georgia 00000 \\hfill anon@anon.com (item-quantity b) "}{" (item-price b) "}{" (item-returned-on b) "}")) - + +(defun format-picture (b) + (concatenate 'string picrow + (subseq (item-picture b) + (+ (search "webimg" (item-picture b)) 7)) "}")) + ;;;Alot of the latex code was ported from the racket version and has already been tested alot ;;;Shouldn't need to mess with this at all unless I'm adding note taking abilities ;;;-------------------------------------------------------------------- diff --git a/www/js/ajax-item.js b/www/js/ajax-item.js index e2ff611..8fe3992 100644 --- a/www/js/ajax-item.js +++ b/www/js/ajax-item.js @@ -17,15 +17,34 @@ $(function() { 'image-data': imageloc.name }, success: function() { - var table = document.getElementById('itemlist'); - var row = table.insertRow(1); - var cell1 = row.insertCell(0); - var cell2 = row.insertCell(1); - var cell3 = row.insertCell(2); - var cell4 = row.insertCell(3); - cell1.innerHTML = desc; - cell2.innerHTML = price; - cell3.innerHTML = qty; + $('#myUL').prepend(" +
  • +
    +
    +
    + + Panda + +
    +
    +
    Price: 2 +
    +
    Quantity: 2 +
    +
    +
    +
    + + + + + +
    +
    +
    +
    +
  • ") var newimg = $("#image-name"); if ($("#image-name").attr("value") == null) { From a39c632d3835132ea1784ef1536e2449eb921b98 Mon Sep 17 00:00:00 2001 From: Jack Lucas Date: Sun, 12 Mar 2017 19:51:55 -0400 Subject: [PATCH 8/9] Picture table works --- main.lisp | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/main.lisp b/main.lisp index 20b2c01..4234237 100644 --- a/main.lisp +++ b/main.lisp @@ -1037,7 +1037,7 @@ {\\color{red} \\textsc{Signature}}\\hspace{0.5cm} \\makebox[3in]{\\hrulefill} \\hspace{0.5cm} \\textsc{Date}\\hspace{0.5cm} \\makebox[1in]{\\hrulefill} \\\\ \\textsc{Print}\\hspace{1.25cm} \\makebox[3in]{\\hrulefill} -\\newpage") +\\newpage ") (defparameter document-conf "\\documentclass{invoice} % Use the custom invoice class (invoice.cls) @@ -1118,12 +1118,13 @@ Norfolk, Georgia 00000 \\hfill anon@anon.com (princ tail-conf s) (princ begin-img-table s) (mapc (lambda (b) (princ (format-picture b) s) - (fresh-line s)) (invoice-item-list invoice)) + (fresh-line s)) + (picture-list (invoice-item-list invoice))) (princ end-img-table s) (princ end-document s)) (trivial-shell:shell-command (concatenate 'string "pdflatex " - "-output-directory=" + "-interaction=nonstopmode -output-directory=" root-dir "pdf/" " " complete-stream)) (setf (invoice-pdf-location invoice) @@ -1138,11 +1139,39 @@ Norfolk, Georgia 00000 \\hfill anon@anon.com (item-price b) "}{" (item-returned-on b) "}")) +(defun subseq-img (b) + (if (null b) + "" + (subseq (item-picture b) + (+ (search "webimg" (item-picture b)) 7)))) + + +;;;I know this is ugly as sin. I'm tired +;;;I'll fix it in a little bit. + (defun format-picture (b) (concatenate 'string picrow - (subseq (item-picture b) - (+ (search "webimg" (item-picture b)) 7)) "}")) - + (if (null (first b)) + "" + (item-description (first b))) + "}" + "{"(subseq-img (first b)) "}{" + (if (null (second b)) + "" + (item-description (second b))) + "}{" + (subseq-img (second b)) "}{" + (if (null (third b)) + "" + (item-description (third b))) + "}{" + (subseq-img (third b)) "}")) + +(defun picture-list (b) + (cond + ((null b) nil) + (t + (cons (list (car b) (cadr b) (third b)) (picture-list (cdddr b)))))) ;;;Alot of the latex code was ported from the racket version and has already been tested alot ;;;Shouldn't need to mess with this at all unless I'm adding note taking abilities ;;;-------------------------------------------------------------------- From 85686c3a250416b59602459d9be5fdd44c7c5372 Mon Sep 17 00:00:00 2001 From: Jack Lucas Date: Sun, 12 Mar 2017 20:18:17 -0400 Subject: [PATCH 9/9] Numbering instead of letters on table --- invoice.cls | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/invoice.cls b/invoice.cls index 7be12e9..fd5a6d2 100644 --- a/invoice.cls +++ b/invoice.cls @@ -10,7 +10,7 @@ \usepackage{calc} % Counters for totaling hours and cost \usepackage{longtable} \usepackage[table]{xcolor} - +\usepackage{subfig} % Define color of grey lines \definecolor{lightgray}{gray}{0.9} @@ -45,19 +45,23 @@ %------------------------------------ % Generate Table of Images %------------------------------------ -\newenvironment{pictureTable}{ - \newcommand*{\picrow}[3]{ - \includegraphics[height=4cm]{##1} & \includegraphics[height=4cm]{##2} & - \includegraphics[height=4cm]{##3} \\ - } - - \begin{longtable}{|c|c|c|} - {\bf Item} & {\bf Item} & {\bf Item} \\ - \hline \hline - \endhead -}{ \hline - \end{longtable} + +\newenvironment{pictureTable}{ + \newcommand*{\picrow}[6]{ + \subfloat[##1]{\includegraphics[width=2.3in]{##2}} & + \subfloat[##3]{\includegraphics[width=2.3in]{##4}} & + \subfloat[##5]{\includegraphics[width=2.3in]{##6}} \\ + } + + \begin {figure} + \renewcommand*\thesubfigure{\arabic{subfigure}} + \begin{tabular}{ccc} + +}{ + \end{tabular} + \end{figure} + } %-----------------------------------