Exemplo n.º 1
0
    def GET(self, path=None):

        if not path.find('/') > -1:
            web.header('Content-Type', 'text/html; charset=utf-8', unique=True)
            self.api = API()
            i = web.input()
            if "q" in i.keys():
                path = i["q"]
            if path:
                now = time.time()
                self.api.query(path, False)
                return (Template(results,
                                 default_filters=['unicode'],
                                 input_encoding='utf-8').render_unicode(
                                     numfound=self.api.numfound,
                                     records=self.api.records,
                                     elapse=now,
                                     keyword=path))
        else:
            now = time.time()
            page = int(path.split('/')[0])
            query = path.split('/')[1]
            return (simplejson.dumps())

        return 'Hello, world!'
Exemplo n.º 2
0
 def GET(self, path=None):
     web.header('Content-Type', 'text/html; charset=utf-8', unique=True)
     self.api = API()
     i = web.input()
     if "q" in i.keys():
         path = i["q"]
     if not path:
         path = "Random OR Image OR Explorer"
     if path:
         if not path.find('OR') > -1 and not path.find('AND') > -1:
             path = escapejs(path).replace(" ", ' OR ')
         else:
             path = escapejs(path)
         now = time.time()
         self.api.query(path, False)
         done = time.time()
         return (Template(template.results,
                          default_filters=['unicode'],
                          input_encoding='utf-8').render_unicode(
                              numfound=self.api.numfound,
                              records=self.api.records,
                              now=now,
                              done=done,
                              keyword=path,
                              baseurl=BASEURL,
                              api=self.api))
     return 'Hello, world!'
Exemplo n.º 3
0
class query:
    def __init__(self):
        pass

    def GET(self, path=None):
        web.header('Content-Type','text/html; charset=utf-8', unique=True) 
        self.api = API()
        i = web.input()
        if "q" in i.keys():
            path=i["q"]
        if path:
            now=time.time()
            self.api.query(path, False)
            return(Template(results, default_filters=['unicode'],input_encoding='utf-8').render_unicode(numfound=self.api.numfound, records=self.api.records, elapse=now, keyword=path ))
        return 'Hello, world!'
Exemplo n.º 4
0
class get:
    def __init__(self):
        self.api = API()

    def __strclean__(self, strin):
        # Clean those evil strings.
        strout = ""
        for item in strin:
            if not item.find('http') > -1:
                if item.isalpha():
                    strout += item
                else:
                    strout += " "
        strout = strout.strip()
        return (strout.split(' '))

    def GET(self, path):
        try:
            # Get parsed Europeana fullrecord-data from url.
            fullrecord = self.api.get_parse_europeana_object(escapejs(path))
        except:
            # Else return empty record.
            return ({})

        words = []
        for item in fullrecord.keys():
            word_list = self.__strclean__(fullrecord[item])
            for word in word_list:
                if len(word) > 4:
                    words.append(word)
        fullrecord["word"] = words

        return (simplejson.dumps(fullrecord))
Exemplo n.º 5
0
class get:
    def __init__(self):
        self.api= API()
    def GET(self,path):
        url=self.api.get_parse_europeana_object(path)
        if "object" in url.keys():
            try:
                f = urllib2.urlopen(url["object"])
                if "content-type" in f.headers.keys():
                    return(simplejson.dumps(url))
            except:
                url["object"] = "http://www.lokaal.lan/blackcat.gif"
        else:
            url["object"] = "http://www.lokaal.lan/blackcat.gif"
        return(simplejson.dumps(url))
Exemplo n.º 6
0
class get:
    def __init__(self):
        self.api = API()

    def __strclean__(self, strin):
        # Clean those evil strings.
        strout = ""
        for item in strin:
            if not item.find('http') > -1:
                if item.isalpha():
                    strout += item
                else:
                    strout += " "
        strout = strout.strip()
        return (strout.split(' '))

    def GET(self, path):
        try:
            # Get parsed Europeana fullrecord-data from url.
            if path.find('/www.europeana.eu/portal/') > -1:
                fullrecord = self.api.get_parse_europeana_object(
                    escapejs(path))
        except:
            # Else return empty record.
            return ({})

        words = []
        for item in fullrecord.keys():
            word_list = self.__strclean__(fullrecord[item])
            for word in word_list:
                if len(word) > 4:
                    words.append(word)
        fullrecord["word"] = words
        referer = web.ctx.env.get('HTTP_REFERER')
        if referer:
            if referer.startswith(
                    'http://www.europeana.fe2.nl') or referer.startswith(
                        'http://europeana.fe2.nl'):
                return (simplejson.dumps(fullrecord))
            else:
                return (
                    '<a href="http://europeana.fe2.nl/">http://europeana.fe2.nl/</a>'
                )
        return (
            '<a href="http://europeana.fe2.nl/">http://europeana.fe2.nl/</a>')
Exemplo n.º 7
0
class get:
    def __init__(self):
        self.api = API()

    def GET(self, path):

        url = self.api.get_parse_europeana_object(path)
        words = []
        for word in url["description"].split(' ') + url["title"].split(' '):
            if len(word) > 4:
                if word.isalpha():
                    words.append(word)
        url["word"] = words
        if "object" in url.keys():
            try:
                f = urllib2.urlopen(url["object"], timeout=1)
                if "content-type" in f.headers.keys():
                    return (simplejson.dumps(url))
            except:
                url["object"] = "http://www.lokaal.lan/blackcat.gif"
        else:
            url["object"] = "http://www.lokaal.lan/blackcat.gif"
        return (simplejson.dumps(url))
Exemplo n.º 8
0
 def __init__(self):
     self.api = API()