Skip to content

Commit

Permalink
sync with restas
Browse files Browse the repository at this point in the history
  • Loading branch information
archimag committed Jan 21, 2011
1 parent c2c59b0 commit 02f4dad
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 56 deletions.
5 changes: 5 additions & 0 deletions resources/rulisp.tmpl
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
</html> </html>
{/template} {/template}


{template notFoundContent}
<h1>Not Found</h1>
Страница по адрессу {$href} не обнаруженна.
{/template}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Tools * Tools
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Expand Down
40 changes: 20 additions & 20 deletions src/pcl.lisp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@
;; contents ;; contents
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(define-route pcl-main ("") (restas:define-route pcl-main ("")
(finalize-page (rulisp.view:pcl-main (list :pdf-href (restas:genurl 'pcl-pdf) (finalize-page (rulisp.view:pcl-main (list :pdf-href (restas:genurl 'pcl-pdf)
:jpg-href "/image/pcl.jpg" :jpg-href "/image/pcl.jpg"
:chapters (iter (for chapter in-vector *pcl-files-map*) :chapters (iter (for chapter in-vector *pcl-files-map*)
(collect (list :href (genurl 'pcl-chapter-view (collect (list :href (restas:genurl 'pcl-chapter-view
:chapter (first chapter)) :chapter (first chapter))
:title (second chapter)))))) :title (second chapter))))))
"Перевод Practical Common Lisp")) "Перевод Practical Common Lisp"))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand All @@ -154,29 +154,29 @@
(defun chapter-url (number) (defun chapter-url (number)
(if (and (> number -1) (if (and (> number -1)
(< number (1- (length *pcl-files-map*)))) (< number (1- (length *pcl-files-map*))))
(genurl 'pcl-chapter-view (restas:genurl 'pcl-chapter-view
:chapter (first (aref *pcl-files-map* :chapter (first (aref *pcl-files-map*
number))))) number)))))


(define-route pcl-chapter-view (":(chapter)") (restas:define-route pcl-chapter-view (":(chapter)")
(let* ((number (position chapter (let* ((number (position chapter
*pcl-files-map* *pcl-files-map*
:key #'first :key #'first
:test #'string=)) :test #'string=))
(path (pcl-source-path (third (aref *pcl-files-map* number))))) (path (pcl-source-path (third (aref *pcl-files-map* number)))))
(if (fad:file-exists-p path) (if (fad:file-exists-p path)
(finalize-page (rulisp.view:pcl-chapter-view (list :prev (chapter-url (1- number)) (finalize-page (rulisp.view:pcl-chapter-view (list :prev (chapter-url (1- number))
:menu (genurl 'pcl-main) :menu (restas:genurl 'pcl-main)
:next (chapter-url (1+ number)) :next (chapter-url (1+ number))
:content (xtree:with-object (el (rulisp::render-wiki-page :content (xtree:with-object (el (rulisp::render-wiki-page
(wiki-parser:parse :dokuwiki path))) (wiki-parser:parse :dokuwiki path)))
(xtree:serialize el :to-string)))) (xtree:serialize el :to-string))))
(second (aref *pcl-files-map* number))) (second (aref *pcl-files-map* number)))
hunchentoot:+HTTP-NOT-FOUND+))) hunchentoot:+HTTP-NOT-FOUND+)))




(define-route pcl-chapter-pdf ("pdf/:(chapter)" (restas:define-route pcl-chapter-pdf ("pdf/:(chapter)"
:content-type "application/pdf") :content-type "application/pdf")
(let* ((number (position chapter (let* ((number (position chapter
*pcl-files-map* *pcl-files-map*
:key #'first :key #'first
Expand All @@ -185,8 +185,8 @@
(flexi-streams:with-output-to-sequence (out) (flexi-streams:with-output-to-sequence (out)
(let ((out* (flexi-streams:make-flexi-stream out))) (let ((out* (flexi-streams:make-flexi-stream out)))
(rulisp::pdf-render-wiki-page (wiki-parser:parse :dokuwiki (rulisp::pdf-render-wiki-page (wiki-parser:parse :dokuwiki
path) path)
out*)) out*))
out))) out)))




Expand Down Expand Up @@ -235,7 +235,7 @@
10)))) 10))))
(pdf:write-document out)))))) (pdf:write-document out))))))


(define-route pcl-pdf ("pcl.pdf") (restas:define-route pcl-pdf ("pcl.pdf")
(merge-pathnames "pcl.pdf" (merge-pathnames "pcl.pdf"
*pcl-snapshot-dir*)) *pcl-snapshot-dir*))


Expand Down
68 changes: 32 additions & 36 deletions src/rulisp.lisp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(defun compute-user-login-name () (defun compute-user-login-name ()
(labels ((rulisp (submodule) (restas:with-submodule (restas:find-submodule 'rulisp-auth
(if (eql (restas:submodule-module submodule) (restas:find-upper-submodule #.*package*))
#.*package*) (restas.simple-auth::compute-user-login-name)))
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))))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; rulisp templates ;; rulisp templates
Expand All @@ -44,48 +40,40 @@
("Поиск" nil google-search))) ("Поиск" nil google-search)))


(defun rulisp-finalize-page (&key title css js content) (defun rulisp-finalize-page (&key title css js content)
(labels ((rulisp (&optional (submodule restas:*submodule*)) (rulisp.view:main-frame
(if (eql (restas:submodule-module submodule) (list :title title
#.*package*) :css (iter (for item in css)
submodule (collect (format nil "/css/~A" item)))
(rulisp (restas:submodule-parent submodule)))) :js js
(main-menu-data () :gecko-png "/image/gecko.png"
(iter (for item in *mainmenu*) :user (compute-user-login-name)
(collect (list :href (apply #'restas:genurl-submodule :main-menu (restas:with-submodule (restas:find-upper-submodule #.*package*)
(second item) (iter (for item in *mainmenu*)
(if (cdddr item) (collect (list :href (apply #'restas:genurl-submodule
(cddr item) (second item)
(last item))) (if (cdddr item)
:name (first item))))) (cddr item)
(css-urls (items) (last item)))
(iter (for item in items) :name (first item)))))
(collect (format nil "/css/~A" item))))) :content content
(let ((restas::*submodule* (rulisp))) :callback (hunchentoot:request-uri*))))
(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*))))))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; routes ;; routes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(define-route main ("") (restas:define-route main ("")
(rulisp-finalize-page :title "Русскоязычное сообщество Common Lisp разработчиков" (rulisp-finalize-page :title "Русскоязычное сообщество Common Lisp разработчиков"
:css '("style.css") :css '("style.css")
:content (alexandria:read-file-into-string (merge-pathnames "index.html" :content (alexandria:read-file-into-string (merge-pathnames "index.html"
*resources-dir*)))) *resources-dir*))))


(define-route tools-list ("apps/") (restas:define-route tools-list ("apps/")
(rulisp-finalize-page :title "Инструменты" (rulisp-finalize-page :title "Инструменты"
:css '("style.css") :css '("style.css")
:content (rulisp.view:tools))) :content (rulisp.view:tools)))


(define-route google-search ("search") (restas:define-route google-search ("search")
(rulisp-finalize-page :title "Поиск по сайту Lisper.ru" (rulisp-finalize-page :title "Поиск по сайту Lisper.ru"
:css '("style.css") :css '("style.css")
:content (rulisp.view:google-search))) :content (rulisp.view:google-search)))
Expand All @@ -94,11 +82,19 @@
;; submodules ;; 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 ;;;; static files


(restas:mount-submodule rulisp-static (#:restas.directory-publisher) (restas:mount-submodule rulisp-static (#:restas.directory-publisher)
(restas.directory-publisher:*directory* (merge-pathnames "static/" *resources-dir*)) (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 ;;;; pcl


Expand Down

0 comments on commit 02f4dad

Please sign in to comment.