Project

General

Profile

« Previous | Next » 

Revision 49818

Changed portal to scholexplorer

View differences:

modules/dli-service-portal/trunk/DLI.py
7 7

  
8 8
from logger import dlilogger
9 9

  
10
DLI_INDEX = 'dli_shadow'
10
DLI_INDEX = None
11
ES_HOST = None
11 12

  
12
ES_HOST = 'ip-90-147-167-27.ct1.garrservices.it'
13 13

  
14
def read_properies():
15
    f = open('api.properties')
16
    for line in f:
17
        s = line.strip().split('=')
18
        if s[0] == 'api.index':
19
            DLI_INDEX = s[1]
20
        if s[1] == 'es_index':
21
            ES_HOST = [x.strip() for x in s[1].split(',')]
14 22

  
23

  
24

  
25

  
26

  
15 27
class MyJSONEncoder(JSONEncoder):
16 28
    def default(self, obj):
17 29
        return obj.__dict__
......
21 33
app.debug = False
22 34
app.json_encoder = MyJSONEncoder
23 35

  
24
base_dnet_url = "http://localhost:8280/app"
36
base_dnet_url = "http://aggregator-dli.openaire.eu/dli/"
25 37

  
26 38

  
27
# q = QueryResolver("http://localhost:8983/solr/DLIF-index-cleaned_shard1_replica1")
28

  
29 39
class InvalidUsage(Exception):
30 40
    status_code = 400
31 41

  
......
81 91
@app.route('/api/ds_info/', methods=['post', 'get'])
82 92
def info():
83 93
    raise Exception("Method to be implemented")
84
    # q = QueryResolver(host, base_dnet_url)
85
    # if 'id' in request.form:
86
    #     id = request.form['id']
87
    #     name = request.form['name']
88
    #     result = q.get_ds_info(id, name)
89
    #     return jsonify(info=result)
90
    # result = q.get_all_ds()
91
    # return jsonify(info=result)
92 94

  
93 95

  
96

  
94 97
@app.route('/api/stats_detail/', methods=['post', 'get'])
95 98
def stats_detail():
96 99
    return ""
97 100

  
98
    # q = QueryResolver(host, base_dnet_url)
99
    # return jsonify(stats=q.get_stats_detail())
100 101

  
101

  
102 102
@app.route('/api/post/', methods=['post', 'get'])
103 103
def query_post():
104 104
    action = None
......
117 117
        filter_key = request.form['filter']
118 118

  
119 119
    if action == 'query' and query is not None:
120
        connector = DLIESConnector(ES_HOST, DLI_INDEX)
120
        connector = DLIESConnector()
121 121
        try:
122 122
            result = connector.simple_query(query, start=start, user_filter=filter_key)
123 123
        except Exception as e:
......
128 128

  
129 129

  
130 130
if __name__ == '__main__':
131

  
131 132
    app.logger.addHandler(dlilogger)
132 133
    monitor(app, port=8000)
133 134
    app.run()
modules/dli-service-portal/trunk/api.properties
1
api.index = dli
2
es_index = ip-90-147-167-25.ct1.garrservices.it,ip-90-147-167-26.ct1.garrservices.it,ip-90-147-167-27.ct1.garrservices.it, ip-90-147-167-28.ct1.garrservices.it
modules/dli-service-portal/trunk/static/partials/index.html
10 10
            <div class="container centered">
11 11
                <div class="row">
12 12
                    <div class="col-lg-12 centered">
13
                        <img ng-hide="facet"  img class="img-responsive img-centered"  src="images/dli_logo_big.png" alt="">
13
                        <img ng-hide="facet"  img class="img-responsive img-centered"  src="img/logo_big.png" alt="">
14 14
                        <div class="row">
15 15
                            <div class="form-group col-lg-10 floating-label-form-group controls">
16 16
                                <form ng-submit="makeQuery()">
modules/dli-service-portal/trunk/static/css/freelancer.css
151 151

  
152 152
.navbar {
153 153
    text-transform: uppercase;
154
    font-family: Montserrat,"Helvetica Neue",Helvetica,Arial,sans-serif;
154
    font-family: Lato;
155 155
    font-weight: 700;
156 156
}
157 157

  
......
170 170
.navbar-default,
171 171
.navbar-inverse {
172 172
    border: 0;
173
    background-color: #29b6f6 ;
173
    background-color: #2192f0 ;
174 174
}
175 175

  
176 176
section {
modules/dli-service-portal/trunk/static/index.html
9 9
    <meta name="description" content="">
10 10
    <meta name="author" content="">
11 11

  
12
    <title>Data Literature Interlinking Service</title>
12
    <title>ScholeXplorer - The Data Literature Interlinking Service</title>
13
    <link rel="icon" type="image/png" href="favicon.png">
13 14

  
14 15
    <!-- Bootstrap Core CSS - Uses Bootswatch Flatly Theme: http://bootswatch.com/flatly/ -->
15 16
    <link href="css/bootstrap.min.css" rel="stylesheet">
......
65 66
                    <span class="icon-bar"></span>
66 67
                    <span class="icon-bar"></span>
67 68
                </button>
68
                <a class="pull-left" href="index.html#/"><img src="images/dli_logo_small.png" style="max-height:80px; margin-top: -7px;"alt="DLI" /><img src="images/beta.png" style="max-height:80px; margin-top: -7px;"alt="DLI" /> </a>
69
                <a class="pull-left" href="index.html#/"><img src="img/logo.png" alt="ScholeXplorer" /></a>
69 70
            </div>
70 71

  
71 72
            <!-- Collect the nav links, forms, and other content for toggling -->
modules/dli-service-portal/trunk/eu/dnetlib/es_connector.py
2 2
from elasticsearch import Elasticsearch
3 3
from elasticsearch_dsl import *
4 4

  
5
import os
6
from os import path
5 7

  
8

  
9
def get_property():
10

  
11

  
12
    f = open(path.join(os.path.dirname(os.path.realpath(__file__)), '../../api.properties'))
13
    p = {}
14
    for line in f:
15
        data = line.strip().split("=")
16
        p[data[0].strip()] = data[1].strip()
17
    return p
18

  
19

  
6 20
def create_typology_filter(value):
7 21
    return Q('match', typology=value)
8 22

  
......
11 25
    args = {'localIdentifier.type': value}
12 26
    return Q('nested', path='localIdentifier', query=Q('bool', must=[Q('match', **args)]))
13 27

  
28

  
14 29
def create_publisher_filter(value):
15 30
    return Q('match', publisher=value)
16 31

  
......
35 50

  
36 51

  
37 52
class DLIESConnector(object):
38
    def __init__(self, index_host, index_name):
39
        self.index_host = index_host
40
        self.client = Elasticsearch(hosts=[index_host])
41
        self.index_name = index_name
53
    def __init__(self):
54
        props = get_property()
55
        self.index_host = [x.strip() for x in props['es_index'].split(',')]
56
        self.client = Elasticsearch(hosts=self.index_host)
57
        self.index_name = props['api.index']
42 58

  
43 59
    def simple_query(self, textual_query, start=None, end=None, user_filter=None):
44 60
        s = Search(using=self.client, index=self.index_name).doc_type('object')
......
99 115
                publishers.append(dict(key=tag.key, count=tag.doc_count))
100 116

  
101 117
        return DLIESResponse(total=response.hits.total,
102
                             facet=dict(pid=pid_types, typology=typologies, datasource=datasources, publishers= publishers), hits=hits)
118
                             facet=dict(pid=pid_types, typology=typologies, datasource=datasources,
119
                                        publishers=publishers), hits=hits)
103 120

  
104 121
    def related_type(self, object_id, object_type, start=None):
105 122
        args = {'target.objectType': object_type}

Also available in: Unified diff