Welcome to Havaiana’s documentation!¶
Havaiana is a dynamic web interface for Ojota (http://ojota.rtfd.org).
Havaiana is Free Software! you can check the code at http://github.com/felipelerena/havaiana
How to use it¶
Hello World¶
import ojota.examples.examples as pkg
from havaiana import Site
site = Site(pkg)
site.serve()
Custom rendering for a field¶
import food_data
from havaiana import Site
def ingredients_list(field, item, backwards):
required = field in item.required_fields
ingredients = getattr(item, field)
items = []
for element in ingredients:
item = '<li><a href="/Ingredients/%s">%s</a></li>' % (element.primary_key,
element)
items.append(item)
value = "<ul>%s</ul>" % "".join(items)
related = False
return (field, value, required, related)
if __name__ == "__main__":
renderers = [('Recipe', 'ingredients', ingredients_list)]
site = Site(food_data, "My Food Database", renderers)
site.serve()
Adding a chart on a view¶
import food_data
from havaiana import Site
from havaiana.charts import LineChart
class RainChartView(LineChart):
def __init__(self):
LineChart.__init__(self, "Recipes uploaded to the site",
"uploads", 800, 400)
def get_data(self, data):
keys = []
points = []
for element in data:
keys.append(element.date)
points.append({"value": int(element.number),
"xlink": "/Recipes uploaded by day/%s" % element.date})
return keys, points
if __name__ == "__main__":
renderers = [
('RecipesByDay', "__index_chart", RainChartView)
]
site = Site(food_data, "My Food Database", renderers)
site.serve()
Screenshots¶
sudo easy_install Havaiana
With pip
sudo pip install Havaiana
From source
git clone git@github.com:felipelerena/havaiana.git
sudo python setup.py install
Table of contents¶
Example¶
"""
This file is part of Havaiana.
Havaiana is free software: you can redistribute it and/or modify
it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Havaiana is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Havaiana. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import absolute_import
from .__init__ import Site
import ojota.examples.examples as pkg
if __name__ == '__main__':
site = Site(pkg)
site.serve()
Dependencies¶
- flask
- Ojota
- wtforms
- pygal
\ Sort by:\ best rated\ newest\ oldest\
\\
Add a comment\ (markup):
\``code``
, \ code blocks:::
and an indented block after blank line