From 048c03a936a31dc5e1a1f14a8e2541e7fb28882d Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 23 Sep 2014 12:52:52 +0200 Subject: [PATCH] Widget upgrade. --- apps/search/urls.py | 2 +- apps/search/views.py | 48 ++++-- apps/wolnelektury_core/static/css/widget.css | 153 ------------------ apps/wolnelektury_core/static/img/search.png | Bin 738 -> 637 bytes apps/wolnelektury_core/static/js/widget.js | 115 +------------ .../wolnelektury_core/static/js/widget_run.js | 26 +++ .../wolnelektury_core/static/scss/widget.scss | 150 +++++++++++++++++ apps/wolnelektury_core/static/widget.html | 12 -- apps/wolnelektury_core/templates/widget.html | 37 +++++ apps/wolnelektury_core/views.py | 5 + wolnelektury/settings/static.py | 16 +- wolnelektury/urls.py | 1 + 12 files changed, 276 insertions(+), 289 deletions(-) delete mode 100644 apps/wolnelektury_core/static/css/widget.css create mode 100644 apps/wolnelektury_core/static/js/widget_run.js create mode 100644 apps/wolnelektury_core/static/scss/widget.scss delete mode 100644 apps/wolnelektury_core/static/widget.html create mode 100644 apps/wolnelektury_core/templates/widget.html diff --git a/apps/search/urls.py b/apps/search/urls.py index 695a7e603..d77d7220a 100644 --- a/apps/search/urls.py +++ b/apps/search/urls.py @@ -6,6 +6,6 @@ from django.conf.urls import patterns, url urlpatterns = patterns('search.views', url(r'^$', 'main', name='search'), - url(r'^hint/$', 'hint'), + url(r'^hint/$', 'hint', name='search_hint'), ) diff --git a/apps/search/views.py b/apps/search/views.py index a50897199..f7aa77cd9 100644 --- a/apps/search/views.py +++ b/apps/search/views.py @@ -73,9 +73,6 @@ def hint(request): # jezeli tagi dot tylko ksiazki, to wazne zeby te nowe byly w tej samej ksiazce # jesli zas dotycza themes, to wazne, zeby byly w tym samym fragmencie. - tags = search.hint_tags(prefix, pdcounter=True) - books = search.hint_books(prefix) - def is_dupe(tag): if isinstance(tag, PDCounterAuthor): if filter(lambda t: t.slug == tag.slug and t != tag, tags): @@ -85,24 +82,47 @@ def hint(request): return True return False - tags = filter(lambda t: not is_dupe(t), tags) - def category_name(c): if c.startswith('pd_'): c = c[len('pd_'):] return _(c) - callback = request.GET.get('callback', None) - data = [{'label': t.name, - 'category': category_name(t.category), - 'id': t.id, - 'url': t.get_absolute_url()} - for t in tags] + \ - [{'label': b.title, + try: + limit = int(request.GET.get('max', '')) + except ValueError: + limit = -1 + else: + if limit < 1: + limit = -1 + + data = [] + + tags = search.hint_tags(prefix, pdcounter=True) + tags = filter(lambda t: not is_dupe(t), tags) + for t in tags: + if not limit: + break + limit -= 1 + data.append({ + 'label': t.name, + 'category': category_name(t.category), + 'id': t.id, + 'url': t.get_absolute_url() + }) + if limit: + books = search.hint_books(prefix) + for b in books: + if not limit: + break + limit -= 1 + data.append({ + 'label': b.title, 'category': _('book'), 'id': b.id, - 'url': b.get_absolute_url()} - for b in books] + 'url': b.get_absolute_url() + }) + + callback = request.GET.get('callback', None) if callback: return HttpResponse("%s(%s);" % (callback, json.dumps(data)), content_type="application/json; charset=utf-8") diff --git a/apps/wolnelektury_core/static/css/widget.css b/apps/wolnelektury_core/static/css/widget.css deleted file mode 100644 index 8da8bf36c..000000000 --- a/apps/wolnelektury_core/static/css/widget.css +++ /dev/null @@ -1,153 +0,0 @@ - -/* - * RESET - * src: http://meyerweb.com/eric/tools/css/reset/ - */ - -#wl div, #wl span, #wl applet, #wl object, #wl iframe, -#wl #eh1, #wl h2, #wl h3, #wl h4, #wl h5, #wl h6, #wl p, #wl blockquote, #wl pre, -#wl a, #wl abbr, #wl acronym, #wl address, #wl big, #wl cite, #wl code, -#wl del, #wl dfn, #wl em, #wl img, #wl ins, #wl kbd, #wl q, #wl s, #wl samp, -#wl small, #wl strike, #wl strong, #wl sub, #wl sup, #wl tt, #wl var, -#wl b, #wl u, #wl i, #wl center, -#wl dl, #wl dt, #wl dd, #wl ol, #wl ul, #wl li, -#wl fieldset, #wl form, #wl label, #wl legend, -#wl table, #wl caption, #wl tbody, #wl tfoot, #wl thead, #wl tr, #wl th, #wl td, -#wl article, #wl aside, #wl canvas, #wl details, #wl embed, -#wl figure, #wl figcaption, #wl footer, #wl header, #wl hgroup, -#wl menu, #wl nav, #wl output, #wl ruby, #wl section, #wl summary, -#wl time, #wl mark, #wl audio, #wl video { - margin: 0; - padding: 0; - border: 0; - font-size: 100%; - font: inherit; - vertical-align: baseline; -} - -#wl { - line-height: 1; -} - -#wl ol, #wl ul { - list-style: none; -} -#wl blockquote, #wl q { - quotes: none; -} - -#wl blockquote:before, #wl blockquote:after, -#wl q:before, #wl q:after { - content: ''; - content: none; -} -#wl table { - border-collapse: collapse; - border-spacing: 0; -} - -/* END RESET */ - -#wl { - background-color: white; -} - -#wl a, a:visited, a:hover { - border: 0; -} - -#wl img { - border: 0; - width: 8.625em; - margin: 0.375em 0; -} - - -.ui-menu { - width: 29em; - font-size: small; - list-style-type: none; - padding: 0; - margin:0; - border: 1px solid #ddd; -} - -.ui-menu .search-hint-label { - display: inline-block; - width: 20em; - margin-right: 2em; - font-size: 1.1em; - line-height: 1.636em; - white-space: nowrap; - overflow: hidden; -} - -.ui-menu .search-hint-category { - width: 9em; -} - -.ui-corner-all { - /*width: 160px;*/ - cursor: pointer; - display:block; -} - -.ui-corner-all a { - text-decoration: none; - color: #0D7E85; - font-size: small; - padding: 5px; - -} - -.ui-menu li { -} - -.ui-menu li:nth-child(odd) { - background-color: white; -} - -.ui-menu li:nth-child(even){ - background-color: #EEE; -} - -.ui-menu li .ui-state-hover { - background-color: #fdf5ce; -} - -.ui-menu li:hover{ - background-color: #053469; - color:white; -} - -.ui-menu a:hover { -/* color:white;*/ - text-decoration: none; -} - - -#wl #id_qq { - font-family: Georgia; - font-size: 0.75em; - - background-color: #FFFFFF; - border: medium none; - border-radius: 0.38em 0.38em 0.38em 0.38em; - box-shadow: 0 0 0.5em #444444 inset; - color: #000000; - height: 2.54em; - width: 9.125em; - - line-height: 2.5em; - padding: 0 0 0 1em; - position: relative; -} - -#wl input[type=image] { - width: 1.5em; - height: 1.5625em; - top: 0.375em; - position: relative; - margin-left: 0.625em; -} - diff --git a/apps/wolnelektury_core/static/img/search.png b/apps/wolnelektury_core/static/img/search.png index 16b2a507714d8b75226f91beb84214e99e6e52e4..8f032bf0b93f2876c953c458c966f894ebfd428e 100644 GIT binary patch delta 592 zcmV-W0f1H;fu;CXMm$&H_cON0GHsQdr5XXv7Lj7P3$znq+4q z|5D0ASy<1cCesYjOc556@^6}&WAj`cuY0dMxB1oE+jE}N`JVTA&igwpDJ3M)0bMwQEgDzCUEIJ_JwPXJVrgN{3?}gk zi?II&cDgh4JgST@7#m$FuPXoQroo?T(Vp&o*@w zZ}Nt=M?>?SH?lZ9#b6e<;#Bd(>_l5OHrU|ee-+)qNEUC#k{r-mXy`+;(@a4AlpULL zKsifJ;-}ebv=EnbKu?w!*PK4#OBVO!fNxo1d6R(Fyzcm(1IDsMZgQ}-n56! zC%nh!SmSxU8*Nt@*78|c#lq~enTisRRCZm|GaSO>{D-NckKzA)c#w^^;Ud=5`hwyq z>5NmdHZGpm(T}g$ym`13&Ya)Z{r>~ZHb#r0!5gx%p^~}N51fwDRSfX5l+s*3-6^Fj eDW#PuCBFgwYSGq;Ii>ah0000q_x!>v&dmJ2-}#+0XHI0MK19Tm*n#=Zw&FGxa0wT2 zE;H};5)64J1tMaAH?aqg-tS{v!@w|^Xg4i_iZBhCS~l)%CY$Ythr z{8L;b&H?@{fhSfX5D_z2TUI$0K6%3ItxBSdR((G7
Z29*gWcn-4>k2Po167M#pSs>N9M_ z54h3U?|(RsnVMIp={wjvQRJWaPV4gptyAW;asC#zm)yjG%sf2ymqlQJ19<%&JCfQh ztyqt_E_M}vcOqw(2#g#NuW18o+B>m`)fhfDceHom0_~8;%gj8DxADDlVS4Zvj%aVf zsp6l-rxCHK_YW$%E}7H1 - - -
- - - - - - - - diff --git a/apps/wolnelektury_core/templates/widget.html b/apps/wolnelektury_core/templates/widget.html new file mode 100644 index 000000000..bfd0358e0 --- /dev/null +++ b/apps/wolnelektury_core/templates/widget.html @@ -0,0 +1,37 @@ +{% spaceless %} + +{% load static from staticfiles %} +{% load compressed %} + + + + + + + Widget Wolnych Lektur + {% compressed_css 'widget' %} + + +
+ + + + + +
+ + +
+ +
+ +{% compressed_js 'widget' %} + + + + +{% endspaceless %} \ No newline at end of file diff --git a/apps/wolnelektury_core/views.py b/apps/wolnelektury_core/views.py index 1ccd24a59..51371735a 100644 --- a/apps/wolnelektury_core/views.py +++ b/apps/wolnelektury_core/views.py @@ -145,3 +145,8 @@ def latest_blog_posts(request, feed_url=None, posts_to_show=5): except: posts = [] return render(request, 'latest_blog_posts.html', {'posts': posts}) + + +@ssi_included(use_lang=False) +def widget(request): + return render(request, 'widget.html') diff --git a/wolnelektury/settings/static.py b/wolnelektury/settings/static.py index 306e718b6..0a520ad7e 100644 --- a/wolnelektury/settings/static.py +++ b/wolnelektury/settings/static.py @@ -66,6 +66,10 @@ PIPELINE_CSS = { 'source_filenames': ('css/simple.css',), 'output_filename': 'css/compressed/simple.css', }, + 'widget': { + 'source_filenames': ('scss/widget.scss',), + 'output_filename': 'css/compressed/widget.css', + }, } PIPELINE_JS = { @@ -135,8 +139,16 @@ PIPELINE_JS = { 'book_ie': { 'source_filenames': ('js/contrib/ierange-m2.js',), 'output_filename': 'js/book_ie.min.js', - } - + }, + 'widget': { + 'source_filenames': ( + 'js/contrib/jquery.js', + 'js/contrib/jquery-ui-1.8.16.custom.min.js', + 'js/search.js', + 'js/widget_run.js', + ), + 'output_filename': 'js/widget.min.js', + }, } STATICFILES_STORAGE = 'fnpdjango.utils.pipeline_storage.GzipPipelineCachedStorage' diff --git a/wolnelektury/urls.py b/wolnelektury/urls.py index 2dfd4d410..bdfb474fd 100644 --- a/wolnelektury/urls.py +++ b/wolnelektury/urls.py @@ -12,6 +12,7 @@ import wolnelektury_core.views urlpatterns = patterns('wolnelektury_core.views', url(r'^$', 'main_page', name='main_page'), url(r'^planowane/$', 'publish_plan', name='publish_plan'), + url(r'^widget\.html$', 'widget', name='widget'), url(r'^zegar/$', 'clock', name='clock'), -- 2.20.1