Skip to content
Browse files

sync with restas

  • Loading branch information...
1 parent c2c59b0 commit 02f4dadd45b5d3bffced145a3af580733a8526dc @archimag committed
Showing with 57 additions and 56 deletions.
  1. +5 −0 resources/rulisp.tmpl
  2. +20 −20 src/pcl.lisp
  3. +32 −36 src/rulisp.lisp
View
5 resources/rulisp.tmpl
@@ -66,6 +66,11 @@
</html>
{/template}
+{template notFoundContent}
+ <h1>Not Found</h1>
+ Страница по адрессу {$href} не обнаруженна.
+{/template}
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Tools
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
View
40 src/pcl.lisp
@@ -137,13 +137,13 @@
;; contents
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(define-route pcl-main ("")
+(restas:define-route pcl-main ("")
(finalize-page (rulisp.view:pcl-main (list :pdf-href (restas:genurl 'pcl-pdf)
- :jpg-href "/image/pcl.jpg"
- :chapters (iter (for chapter in-vector *pcl-files-map*)
- (collect (list :href (genurl 'pcl-chapter-view
- :chapter (first chapter))
- :title (second chapter))))))
+ :jpg-href "/image/pcl.jpg"
+ :chapters (iter (for chapter in-vector *pcl-files-map*)
+ (collect (list :href (restas:genurl 'pcl-chapter-view
+ :chapter (first chapter))
+ :title (second chapter))))))
"Перевод Practical Common Lisp"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -154,11 +154,11 @@
(defun chapter-url (number)
(if (and (> number -1)
(< number (1- (length *pcl-files-map*))))
- (genurl 'pcl-chapter-view
- :chapter (first (aref *pcl-files-map*
- number)))))
+ (restas:genurl 'pcl-chapter-view
+ :chapter (first (aref *pcl-files-map*
+ number)))))
-(define-route pcl-chapter-view (":(chapter)")
+(restas:define-route pcl-chapter-view (":(chapter)")
(let* ((number (position chapter
*pcl-files-map*
:key #'first
@@ -166,17 +166,17 @@
(path (pcl-source-path (third (aref *pcl-files-map* number)))))
(if (fad:file-exists-p path)
(finalize-page (rulisp.view:pcl-chapter-view (list :prev (chapter-url (1- number))
- :menu (genurl 'pcl-main)
- :next (chapter-url (1+ number))
- :content (xtree:with-object (el (rulisp::render-wiki-page
- (wiki-parser:parse :dokuwiki path)))
- (xtree:serialize el :to-string))))
+ :menu (restas:genurl 'pcl-main)
+ :next (chapter-url (1+ number))
+ :content (xtree:with-object (el (rulisp::render-wiki-page
+ (wiki-parser:parse :dokuwiki path)))
+ (xtree:serialize el :to-string))))
(second (aref *pcl-files-map* number)))
hunchentoot:+HTTP-NOT-FOUND+)))
-(define-route pcl-chapter-pdf ("pdf/:(chapter)"
- :content-type "application/pdf")
+(restas:define-route pcl-chapter-pdf ("pdf/:(chapter)"
+ :content-type "application/pdf")
(let* ((number (position chapter
*pcl-files-map*
:key #'first
@@ -185,8 +185,8 @@
(flexi-streams:with-output-to-sequence (out)
(let ((out* (flexi-streams:make-flexi-stream out)))
(rulisp::pdf-render-wiki-page (wiki-parser:parse :dokuwiki
- path)
- out*))
+ path)
+ out*))
out)))
@@ -235,7 +235,7 @@
10))))
(pdf:write-document out))))))
-(define-route pcl-pdf ("pcl.pdf")
+(restas:define-route pcl-pdf ("pcl.pdf")
(merge-pathnames "pcl.pdf"
*pcl-snapshot-dir*))
View
68 src/rulisp.lisp
@@ -12,13 +12,9 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun compute-user-login-name ()
- (labels ((rulisp (submodule)
- (if (eql (restas:submodule-module submodule)
- #.*package*)
- submodule
- (rulisp (restas:submodule-parent submodule)))))
- (restas:with-submodule-context (restas:find-submodule 'rulisp-auth (rulisp restas:*submodule*))
- (restas.simple-auth::compute-user-login-name))))
+ (restas:with-submodule (restas:find-submodule 'rulisp-auth
+ (restas:find-upper-submodule #.*package*))
+ (restas.simple-auth::compute-user-login-name)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; rulisp templates
@@ -44,48 +40,40 @@
("Поиск" nil google-search)))
(defun rulisp-finalize-page (&key title css js content)
- (labels ((rulisp (&optional (submodule restas:*submodule*))
- (if (eql (restas:submodule-module submodule)
- #.*package*)
- submodule
- (rulisp (restas:submodule-parent submodule))))
- (main-menu-data ()
- (iter (for item in *mainmenu*)
- (collect (list :href (apply #'restas:genurl-submodule
- (second item)
- (if (cdddr item)
- (cddr item)
- (last item)))
- :name (first item)))))
- (css-urls (items)
- (iter (for item in items)
- (collect (format nil "/css/~A" item)))))
- (let ((restas::*submodule* (rulisp)))
- (rulisp.view:main-frame (list :title title
- :css (css-urls css)
- :js js
- :gecko-png "/image/gecko.png"
- :user (compute-user-login-name)
- :main-menu (main-menu-data)
- :content content
- :callback (hunchentoot:request-uri*))))))
+ (rulisp.view:main-frame
+ (list :title title
+ :css (iter (for item in css)
+ (collect (format nil "/css/~A" item)))
+ :js js
+ :gecko-png "/image/gecko.png"
+ :user (compute-user-login-name)
+ :main-menu (restas:with-submodule (restas:find-upper-submodule #.*package*)
+ (iter (for item in *mainmenu*)
+ (collect (list :href (apply #'restas:genurl-submodule
+ (second item)
+ (if (cdddr item)
+ (cddr item)
+ (last item)))
+ :name (first item)))))
+ :content content
+ :callback (hunchentoot:request-uri*))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; routes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(define-route main ("")
+(restas:define-route main ("")
(rulisp-finalize-page :title "Русскоязычное сообщество Common Lisp разработчиков"
:css '("style.css")
:content (alexandria:read-file-into-string (merge-pathnames "index.html"
*resources-dir*))))
-(define-route tools-list ("apps/")
+(restas:define-route tools-list ("apps/")
(rulisp-finalize-page :title "Инструменты"
:css '("style.css")
:content (rulisp.view:tools)))
-(define-route google-search ("search")
+(restas:define-route google-search ("search")
(rulisp-finalize-page :title "Поиск по сайту Lisper.ru"
:css '("style.css")
:content (rulisp.view:google-search)))
@@ -94,11 +82,19 @@
;; submodules
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(defclass rulisp-drawer () ())
+
+(defmethod restas:render-object ((designer rulisp-drawer) (code (eql hunchentoot:+http-not-found+)))
+ (rulisp-finalize-page :title "Not Found"
+ :css '("style.css")
+ :content (rulisp.view:not-found-content (list :href (hunchentoot:request-uri*)))))
+
;;;; static files
(restas:mount-submodule rulisp-static (#:restas.directory-publisher)
(restas.directory-publisher:*directory* (merge-pathnames "static/" *resources-dir*))
- (restas.directory-publisher:*autoindex* nil))
+ (restas.directory-publisher:*autoindex* nil)
+ (restas.directory-publisher:*default-render-method* (make-instance 'rulisp-drawer)))
;;;; pcl

0 comments on commit 02f4dad

Please sign in to comment.
Something went wrong with that request. Please try again.