From e49e6381f6c55e7e31e92027ffee5ededb291fec Mon Sep 17 00:00:00 2001 From: abki Date: Thu, 2 Jul 2009 00:12:39 +0200 Subject: [PATCH] take care some files are modifier because of the local environnement. new file: .gitignore modified: commands/mylayman.cfg modified: commands/parse.py modified: commands/whoosh_manager.py modified: models.py css for mobile/hanheld (don't work actually : use a subdomain new file: static/css/handheld.css modified: static/css/layout.css modified: static/css/nav.css new file: templates/500.html modified: templates/ebuildfind/base.html modified: templates/ebuildfind/search.html modified: views.py --- .gitignore | 4 +++ commands/mylayman.cfg | 10 +++---- commands/parse.py | 25 ++++-------------- commands/whoosh_manager.py | 5 ++-- models.py | 16 +++++++----- static/css/handheld.css | 5 ++++ static/css/layout.css | 56 +++++++++++++++++++++------------------- static/css/nav.css | 4 --- templates/500.html | 1 + templates/ebuildfind/base.html | 5 ++-- templates/ebuildfind/search.html | 20 ++++++++++++-- views.py | 16 +++++++----- 12 files changed, 91 insertions(+), 76 deletions(-) create mode 100644 .gitignore create mode 100644 static/css/handheld.css create mode 100644 templates/500.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9d0a4eb --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*~ +*pyc +.*\#* +\#* \ No newline at end of file diff --git a/commands/mylayman.cfg b/commands/mylayman.cfg index d0ddbfa..75709d8 100644 --- a/commands/mylayman.cfg +++ b/commands/mylayman.cfg @@ -3,24 +3,24 @@ #----------------------------------------------------------- # Defines the directory where overlays should be installed -storage : /home/timemachine/www/ebuildfnd/ebuildfind/commands/var/ +storage : /home/amir/Desktop/ebuildfind-project/ebuilds/ebuildfind/commands/var/overlays #----------------------------------------------------------- # Remote overlay lists will be stored here # layman will append _md5(url).xml to each filename -cache : %(storage)s/cache +cache : %(storage)s/../cache #----------------------------------------------------------- # The list of locally installed overlays -local_list: /home/timemachine/www/ebuildfnd/ebuildfind/commands/overlays.xml +local_list: %(storage)s/../overlays.xml #----------------------------------------------------------- # Path to the make.conf file that should be modified by # layman -make_conf : %(storage)s/make.conf +make_conf : %(storage)s/../make.conf #----------------------------------------------------------- # URLs of the remote lists of overlays (one per line) or @@ -31,7 +31,7 @@ make_conf : %(storage)s/make.conf # http://mydomain.org/my-layman-list.xml # file:///usr/portage/local/layman/my-list.xml -overlays : file:///home/timemachine/www/ebuildfnd/ebuildfind/commands/overlays.txt +overlays : file://%(storage)s/../../overlays.txt #----------------------------------------------------------- # Proxy support diff --git a/commands/parse.py b/commands/parse.py index 8fff38a..3b346a5 100644 --- a/commands/parse.py +++ b/commands/parse.py @@ -4,24 +4,20 @@ import os, re from django.conf import settings -os.environ['DJANGO_SETTINGS_MODULE'] = 'ebuildfnd.settings' +os.environ['DJANGO_SETTINGS_MODULE'] = 'ebuilds.settings' from layman.debug import Message -from manage_layman import LaymanManager -from ebuildfnd.ebuildfind.models import Ebuild, Overlay +from ebuilds.ebuildfind.models import Ebuild, Overlay from whoosh_manager import WhooshEbuildManager +from manage_layman import LaymanManager -OVERLAYS_BASE = "/home/timemachine/www/ebuildfnd/ebuildfind/commands/var/" -OUT = Message("parser") +OVERLAYS_BASE = settings.ROOT_PATH + "ebuilds/" + "ebuildfind/commands/var/overlays/" class EbuildParser: def __init__(self, overlay, category, app, file_path): path, filename = os.path.split(os.path.realpath(file_path)) - - #OUT.warn("%s\n%s\n%s\n%s" % (overlay, category, app, file_path)) - #OUT.warn("****************************************************") name_version, ext = os.path.splitext(filename) n = len(app) @@ -78,7 +74,6 @@ def ParseEbuilds(): path_overlay = os.path.join(OVERLAYS_BASE, overlay) if exclude_directory(path_overlay, overlay): - print overlay overlay_name = overlay overlay = Overlay.objects.get(name=overlay) @@ -97,7 +92,6 @@ def ParseEbuilds(): for ebuild in ebuilds: if ebuild.endswith(".ebuild"): if exclude_directory(path_overlay_category_app, ebuild): - #OUT.warn(ebuild) path_ebuild = os.path.join(path_overlay_category_app, ebuild) @@ -114,18 +108,10 @@ def ParseEbuilds(): ebuild.iuse = unicode(e.iuse) ebuild.homepage = unicode(e.homepage) ebuild.overlay = overlay - #ebuild.save() + ebuild.save() - whoosh.Update(ebuild) - - i +=1 - print i -def SyncOverlays(): - h = LaymanManager() - h.AddAll() - def ParseOverlays(): h = LaymanManager() overlays = h.List() @@ -142,7 +128,6 @@ def ParseOverlays(): o.save() def main(): - #SyncOverlays() ParseOverlays() ParseEbuilds() diff --git a/commands/whoosh_manager.py b/commands/whoosh_manager.py index e4acb95..b713390 100644 --- a/commands/whoosh_manager.py +++ b/commands/whoosh_manager.py @@ -11,7 +11,7 @@ from django.conf import settings os.environ['DJANGO_SETTINGS_MODULE'] = 'ebuilds.settings' -INDEX_BASE = settings.ROOT_PATH + "/ebuildfind/commands/var/index" +INDEX_BASE = settings.ROOT_PATH + "ebuilds" + "/ebuildfind/commands/var/index" class WhooshEbuildManager: def __init__(self, reset=False): @@ -48,8 +48,9 @@ class WhooshEbuildManager: content = ' '.join(content) - writer.add_document(permalink=ebuild.permalink(), + writer.add_document(permalink=unicode(ebuild.id), content=content) + print ">", ebuild.overlay.name, ">>> ", ebuild.name writer.commit() def Search(self, query): diff --git a/models.py b/models.py index 7e062d6..2e6741e 100644 --- a/models.py +++ b/models.py @@ -1,10 +1,12 @@ from django.db import models + + class Overlay(models.Model): name = models.CharField(max_length=255) description = models.TextField() link = models.URLField() - + def __repr__(self): return self.name @@ -16,14 +18,14 @@ class Ebuild(models.Model): category = models.CharField(max_length=255) version = models.CharField(max_length=255) description = models.TextField() - keywords = models.CharField(max_length=255) - license = models.CharField(max_length=255) - iuse = models.CharField(max_length=255) + keywords = models.TextField(max_length=255) + license = models.TextField(max_length=255) + iuse = models.TextField(max_length=255) homepage = models.URLField() overlay = models.ForeignKey(Overlay) - - def permalink(self): + + def path(self): return "/%s/%s/%s/%s" % (self.overlay.name, self.category, self.name, self.version) def get_absolute_url(self): - return "/search/?q=%s" % self.name \ No newline at end of file + return "/search/?q=%s" % self.name diff --git a/static/css/handheld.css b/static/css/handheld.css new file mode 100644 index 0000000..1f42243 --- /dev/null +++ b/static/css/handheld.css @@ -0,0 +1,5 @@ +* { + position: static !important; + float: none !important; + background: none !important; +} \ No newline at end of file diff --git a/static/css/layout.css b/static/css/layout.css index 61def42..f1c901d 100755 --- a/static/css/layout.css +++ b/static/css/layout.css @@ -13,6 +13,7 @@ body { h7 { font-size: 11px; font-weight: normal;} .post { overflow : hidden; } + /* anchors ----------------------------------------------- */ @@ -49,38 +50,39 @@ h7 { font-size: 11px; font-weight: normal;} text-align: center; } -/* boxes ------------------------------------------------ */ - -/* paragraphs, quotes and lists ------------------------------------------------ */ - -/* menus ------------------------------------------------ */ - -/* submenus ------------------------------------------------ */ - -/* section menus +/* results ----------------------------------------------- */ +.ebuild { + background-color: #DDDDFF; + margin: 0px; + padding: 10px; + margin-bottom: 10px; +} -/* table ------------------------------------------------ */ +ul, li { + list-style-type: none; + margin: 0px; + padding: 0px; -/* forms ------------------------------------------------ */ +} -/* articles ------------------------------------------------ */ +.ebuild:hover { + background-color: #7A5ADA; + color: black; +} -/* site information ------------------------------------------------ */ +.ebuild { + font-size: 1.2em; +} -/* AJAX sliding shelf ------------------------------------------------ */ +.ebuild .description { + font-size: 1.5em; +} -/* Accordian ------------------------------------------------ */ +.ebuild .homepage { + float: right; +} -/* Mootools Kwicks ------------------------------------------------ */ +.ebuild .path { + float: left; +} \ No newline at end of file diff --git a/static/css/nav.css b/static/css/nav.css index 7cb8440..53bff8d 100755 --- a/static/css/nav.css +++ b/static/css/nav.css @@ -165,7 +165,3 @@ ul.nav li.secondary:hover a:hover { background:#555; } ul.nav li.secondary:hover a:active {background:#444;} - -#results li:hover { - font-weight: bold; -} \ No newline at end of file diff --git a/templates/500.html b/templates/500.html new file mode 100644 index 0000000..2bf3dd1 --- /dev/null +++ b/templates/500.html @@ -0,0 +1 @@ +Sory Fattal Error diff --git a/templates/ebuildfind/base.html b/templates/ebuildfind/base.html index a332a1d..4ef4227 100644 --- a/templates/ebuildfind/base.html +++ b/templates/ebuildfind/base.html @@ -7,9 +7,10 @@ - - + + diff --git a/templates/ebuildfind/search.html b/templates/ebuildfind/search.html index ced17d8..9ecf917 100644 --- a/templates/ebuildfind/search.html +++ b/templates/ebuildfind/search.html @@ -11,8 +11,24 @@ {% endif %} diff --git a/views.py b/views.py index cc17e83..aabd229 100644 --- a/views.py +++ b/views.py @@ -1,14 +1,10 @@ - - - - - from commands.whoosh_manager import WhooshEbuildManager from django.shortcuts import render_to_response from planet import Parser -whoosh = WhooshEbuildManager() +from models import Ebuild, Overlay +whoosh = WhooshEbuildManager() def index(request): GPlanet = Parser("http://planet.gentoo.org/atom.xml") @@ -25,6 +21,11 @@ def index(request): return render_to_response("ebuildfind/index.html", response) +overlay = {} + +def add_overlay(name, description): + overlay["name"] = description + def search(request): response = {"error":"Query should be at least 3 caracters long"} query = "" @@ -43,6 +44,7 @@ def search(request): response["results"] = list() for result in results: - response["results"].append(result["permalink"]) + ebuild = Ebuild.objects.get(id=result["permalink"]) + response["results"].append(ebuild) return render_to_response("ebuildfind/search.html", response) -- 2.11.4.GIT