caveman2-widgets-bootstrap

2018-02-28

An extension to caveman2-widgets which enables the simple usage of Twitter Bootstrap.

Upstream URL

github.com/ritschmaster/caveman2-widgets-bootstrap

Author

Richard Paul Bäck

License

LLGPL

README.org

1Caveman2-Widgets-Bootstrap

This is an extension to caveman2-widgets. It supplies widgets which are usingBootstrap. Before you start using it you may have a look at the [[https://github.com/ritschmaster/caveman2-widgets#usage][basic usagedocumentation]] to understand how to use those (extra) widgets.

1.1Installation

You can load it through Quicklisp or you can use the git repository. To use thegit repository clone it into "~/quicklisp/local-projects" or (if you are usingRoswell) "~/.roswell/local-projects".

To QUICKLOAD it, use:

(ql:quickload :caveman2-widgets-bootstrap)

1.2Contributions

You are very welcomed to contribute to this project! You can contribute by:
  • Using it and spreading the word!
  • Finding flaws and submitting Issues.
  • Finding flaws and removing them (as Pull-requests).
  • Adding new features (as Pull-requests). Before shooting in the darkcreate either an Issues or mail me. Maybe your feature is on myagenda too.
  • Showing your appreciation through a donation (please mail me for mydata).

If you add new features, please document them. Otherwise other developers will have a hard time using this framework.

1.3Usage

1.3.1A new header widget

A new header widget is added which uses specific CDN links for gettingBootstrap. Please notice, that the global variables, where you canspecify the locations, are not simple string variables! They are<FILE> objects.
BOOTSTRAP-JS
Must be a <JS-FILE> object.
BOOTSTRAP-CSS
Must be a <CSS-FILE> object.

1.3.2Navigation widget

The navigation widget is fully redesigned for the use withBootstrap. The <BOOTSTRAP-MENU-NAVIGATION-WIDGET> has some specialslots:
BRAND-TEXT
A HTML code which will be displayed in the upper leftcorner.
NAVBAR-FIXED
A non-nil value will fix the navbar on the upperedge.

You can use it fairly easy by just using <BOOTSTRAP-MENU-NAVIGATION-WIDGET> as KIND for the DEFNAV macro:

(defvar *first-widget*
  (make-widget :global '<string-widget>
               :text "<h1>Hello world from first</h1>"))

(defvar *second-widget*
  (make-widget :global '<string-widget>
               :text "<h1>Hello world from second</h1>"))

(defclass <proxy-widget> (<widget>)
  ()
  (:documentation "This class enables session based widgets for a
navigation."))

(defmethod render-widget ((this <proxy-widget>))
  (set-widget-for-session :string-widget
                          (make-widget :session '<string-widget>
                                       :text "hello world"))
  (render-widget (get-widget-for-session :string-widget)))

(defnav "/"
    ((make-instance '<bootstrap-header-widget>
                    :title "Navigation test")
     (list
      (list "First widget" "first" *first-widget*)
      (list "Second widget" "second" *second-widget*)
      (list "Third widget" "third" (make-widget :global
                                                '<proxy-widget>)))
     :kind '<bootstrap-menu-navigation-widget>))

If you need extra header objects, you can create them via the RENDER-WIDGET-HEADER method. This means you only have to overwrite it for your own navigation class.

(defvar *first-widget*
  (make-widget :global '<string-widget>
               :text "<h1>Hello world from first</h1>"))

(defvar *second-widget*
  (make-widget :global '<string-widget>
               :text "<h1>Hello world from second</h1>"))

(defclass <my-bootstrap-nav> (<bootstrap-menu-navigation-widget>)
  ()
  (:default-initargs
   :brand-text "<div id=\"brandlogo\"></div>"
    :navbar-fixed t))

(defmethod caveman2-widgets-bootstrap.navigation::render-widget-header
    ((this <my-bootstrap-nav>)
     (args (eql :right)))
  (with-output-to-string (ret-val)
    (format ret-val "<ul class=\"nav navbar-nav navbar-right\">
  <li><a href=\"~a\">GitHub</a></li>
</ul>"
            (let ((link (make-widget
                         :global '<link-widget>
                         :label "GitHub"
                         :callback #'(lambda ()
                                       "http://github.com/ritschmaster")
                         :target-foreign-p t)))
              (uri-path link)))))

(defnav "/"
    ((make-instance '<bootstrap-header-widget>
                    :title "Navigation test")
     (list
      (list "First widget" "first" *first-widget*)
      (list "Second widget" "second" *second-widget*))
     :kind '<my-bootstrap-nav>))

1.4Author

  • Richard Paul Bäck (richard.baeck@free-your-pc.com)

1.5Copyright

Copyright (c) 2016 Richard Paul Bäck (richard.baeck@free-your-pc.com)

1.6License

Licensed under the LLGPL License.

Dependencies (3)

  • caveman
  • caveman2-widgets
  • prove

Dependents (0)

    • GitHub
    • Quicklisp
    • Sponsor