Skip to content

Instantly share code, notes, and snippets.

@html
html / oz-parsing-util.lisp
Last active November 8, 2017 04:47
Utilities I use for parsing, it depends on "php funcs for cl" https://gist.github.com/html/4707958
(defvar *cache-dir* '(:relative "cache"))
(defvar *cache-enabled-p* nil)
(defvar *drakma-request-max-tries* nil) ;
(defvar *character-for-wrong-utf-8-chars* #\@)
; V5
(defun drakma-request (&rest args)
"Gets url contents using drakma:http-request.
Tries several times to do it on error.
@html
html / php-functions-for-cl.lisp
Last active December 19, 2018 19:46
Php utility functions for common lisp
(ql:quickload :ironclad)
(ql:quickload :cl-ppcre)
(ql:quickload :arnesi)
(ql:quickload :cl-prevalence)
(ql:quickload :closure-html)
(ql:quickload :cxml)
(ql:quickload :split-sequence)
(defun nl2br (text)
(cl-ppcre:regex-replace-all #\newline text "<br/>"))
(defclass bootstrap-date-parser (date-parser)
())
(defmethod parse-view-field-value ((parser date-parser) value obj
(view form-view) (field form-view-field) &rest args)
(declare (ignore args))
(let* ((name (attributize-name (view-field-slot-name field)))
(date (request-parameter (format nil "~A[date]" name)))
(time (request-parameter (format nil "~A[time]" name)))
(hour))
@html
html / weblocks-tinymce-textarea-presentation.lisp
Created January 8, 2013 14:25
Tinymce textarea presentation for weblocks. Uses cl-config (https://github.com/html/cl-config) and jquery-seq (https://github.com/html/jquery-seq) and tinymce itself.
(cl-config:set-value :weblocks.tinymce-textarea-presentation.tinymce-settings "({
debug: true,
script_url : '/pub/scripts/tiny_mce/tiny_mce.js',
theme : 'advanced',
plugins : 'pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template',
theme_advanced_buttons1: 'save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect',
theme_advanced_buttons2: 'cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor',
theme_advanced_bu
@html
html / weblocks-table-view-with-ordered-fields.lisp
Last active December 10, 2015 13:58
Snippet allows to order fields in table view (columns in gridedit for example), use :fields-order view option like this :fields-order '(:id :name :group :time-created)
(defclass advanced-table-view (table-view)
((fields-order :initarg :fields-order :initform nil)))
(defclass advanced-table-view-field (table-view-field)
())
(defclass advanced-table-scaffold (table-scaffold)
())
(defun %map-object-view-fields (proc obj view-designator
(eval-when (:compile-toplevel :load-toplevel :execute)
(yaclml::def-empty-html-tag <:input :core :event :i18n
accept
accesskey
alt
checked
disabled
maxlength
name
onblur
@html
html / weblocks-twitter-bootstrap-tabs-mustache-templates.lisp
Created January 1, 2013 16:00
Templates for render-menu-with-template ( https://gist.github.com/4427596 ) to display navigation as twitter bootstrap tabs.
(def-weblocks-yaclml-mustache
bootstrap-navigation-tabs-item-layout
(<:li :id "{{{item-id}}}" :class "{{#pane-selected-p}} active{{/pane-selected-p}}"
"{{#pane-selected-or-disabled-p}}"
(<:a :href "#" "{{{label}}}")
"{{/pane-selected-or-disabled-p}}"
"{{^pane-selected-or-disabled-p}}"
(<:a :href "{{{link}}}"
(<:as-is "{{{label}}}"))
"{{/pane-selected-or-disabled-p}}"))
@html
html / weblocks-render-menu-extension.lisp
Last active December 10, 2015 11:28
Replacement for render-menu function. Depends on https://gist.github.com/4427396 Uses mustache views and replaces most of (or all of) standard markup.
(def-weblocks-yaclml-mustache
navigation-tabs-item-layout
(<:li :id "{{{item-id}}}" :class "{{{item-class}}}"
(<:span :class "{{{inner-class}}}"
"{{#pane-selected-or-disabled-p}}"
(<:span :class "label" "{{{label}}}")
"{{/pane-selected-or-disabled-p}}"
"{{^pane-selected-or-disabled-p}}"
(<:a :href "{{{link}}}"
(<:as-is "{{{label}}}"))
@html
html / weblocks-mustache-yaclml-macros.lisp
Created January 1, 2013 13:13
weblocks mustache and yaclml macros
(defmacro def-weblocks-mustache (name template)
"Define a named renderer of string TEMPLATE."
(let ((obj (gensym)))
`(let ((,obj (mustache::parse ,template)))
(defun ,name (&optional context)
(let ((mustache:*mustache-output* (make-string-output-stream)))
(mustache::render-body ,obj context ,template)
(get-output-stream-string mustache:*mustache-output*))))))
(defmacro def-weblocks-yaclml-mustache (name &body body)
@html
html / normalize-newlines.lisp
Created November 16, 2012 09:18
Normalize newlines for Common Lisp
(defun normalize-newlines (string)
(ppcre:regex-replace-all (format nil "~C(\n)?" #\return) string "\n"))
(assert (string= (normalize-newlines "as\ndf") "as\ndf"))
(assert (string= (normalize-newlines (format nil "as~C\ndf" #\return)) "as\ndf"))
(assert (string= (normalize-newlines (format nil "as~Cdf" #\return)) "as\ndf"))