--- /dev/null
+# -*- coding: utf-8 -*-
+# Leśmianator do działania wymaga pliku dictionary.p w katalogu aplikacji
+# plik ten powinien zawierać słownik postaci:
+# <3-znakowy ciąg> => <kolejny znak> => <częstość występowania>
+#
+# automat generujący taki słownik zostanie dodany później :)
--- /dev/null
+# Create your views here.
+
+import pickle
+from django.shortcuts import render_to_response
+from django.template import RequestContext
+from random import randint
+
+import os.path
+
+
+def _choose_word(word):
+ try:
+ choices = sum((_dictionary[word][post] for post in _dictionary[word]))
+ r = randint(0, choices - 1)
+
+ for post in _dictionary[word]:
+ r -= _dictionary[word][post]
+ if r < 0:
+ return post
+ except KeyError:
+ return ''
+
+# load dictionary on start, it won't change
+try:
+ f = open(os.path.join(os.path.dirname(__file__), 'dictionary.p'))
+ _dictionary = pickle.load(f)
+except:
+ _dictionary = {}
+
+
+def poem(request):
+ letters = []
+ word = u''
+ empty = -10
+ left = 1000
+ if not _dictionary:
+ left = 0
+ while empty != 3 and left:
+ letter = _choose_word(word)
+ letters.append(letter)
+ word = word[-2:] + letter
+ if letter == u'\n':
+ empty += 1
+ else:
+ empty = 0
+ left -= 1
+
+ poem = ''.join(letters).strip()
+
+ return render_to_response('lesmianator/poem.html',
+ {"object": poem},
+ context_instance=RequestContext(request))
'rosetta',
'infopages',
'suggest',
+ 'lesmianator',
]
CACHE_BACKEND = 'locmem:///?max_entries=3000'
color: #000;
background: #FFF url(/static/img/arrow-up.png) no-repeat center right;
}
+#menu a.menu-link {
+ display: block;
+ float: left;
+ height: 1.5em;
+ margin-left: 0.5em;
+ text-align: center;
+ color: #FFF;
+}
+#menu span {
+ color: #888;
+ font-style: italic;
+ font-size: .75em;
+}
+
#toc, #themes {
position: fixed;
<div id="intro">
<p id="tags-description">↓ {% trans "Browse books by categories" %} ↓</p>
<div id="propaganda">
- <p><a href="{% url epub %}"><img src="/static/img/epub-www.jpg" alt="epub: lektury w kieszeni" /></a></p>
+ <!--p><a href="{% url epub %}"><img src="/static/img/epub-www.jpg" alt="epub: lektury w kieszeni" /></a></p-->
+
+ <h2>Leśmianator — poeta automagiczny</h2>
+ <p><img src="/static/img/mats_erikssonCCBYNCSA.jpg" title="{% trans "Author" %}: Mats Eriksson@Flickr, CC BY-NC-SA" /><br/>
+ <cite>Z drogi! — Idzie poeta — niebieski wycieruch!<br/>
+Zbój obłoczny, co z światem jest — wspak i na noże!
+Baczność! — Nic się przed takim uchronić nie może!</cite></p>
+
+<p>Poezja z Wolnych Lektur przepuszczona przez mikser.</p>
+ <p class="see-more"><a href="{% url lesmianator %}">{% trans "Twórz-że się!" %} ⇒</a></p>
<h2>{% trans "Wolne Lektury Widget" %}</h2>
<p>{% trans "Place our widget - search engine for Wolne Lektury which gives access to free books and audiobooks - on your homepage! Just copy the HTML code below onto your page:" %}</p>
--- /dev/null
+{% load i18n %}
+{% load chunks compressed catalogue_tags %}
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+ <title>{% block title %}WolneLektury.pl{% endblock %}</title>
+ <link rel="icon" href="{{ STATIC_URL }}img/favicon.png" type="image/x-icon" />
+ {% compressed_css "book" %}
+ </head>
+ <body>
+ <div id="menu">
+ <a href='' class='menu-link'>Twórz-że się jeszcze raz!</a>
+ <span style='float: right'>Poezja z Wolnych Lektur przepuszczona przez mikser.</a>
+ </div>
+ <div id="header">
+ <div id="logo">
+ <a href="/"><img src="{{ STATIC_URL }}img/logo.png" alt="WolneLektury.pl - logo" /></a>
+ </div>
+ </div>
+ <div id="book-text">
+ <h1>
+ <span class="author">Leśmianator</span>
+ <span class="title">***</span>
+ </h1>
+ {{ object|linebreaksbr }}
+ </div>
+ <script type="text/javascript">
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+ </script>
+ <script type="text/javascript">
+ var pageTracker = _gat._getTracker("UA-2576694-1");
+ pageTracker._trackPageview();
+ </script>
+ </body>
+</html>
url(r'^katalog/', include('catalogue.urls')),
url(r'^materialy/', include('lessons.urls')),
url(r'^sugestia/', include('suggest.urls')),
+ url(r'^lesmianator/?$', 'lesmianator.views.poem', name='lesmianator'),
# Static pages
url(r'^wolontariat/$', 'infopages.views.infopage', {'slug': 'voluntary_services'}, name='voluntary_services'),