Skip to content

Commit 7f88aa5

Browse files
authored
Merge pull request #11 from opencitations/fix-log-2025
removing wl logger
2 parents 2fdcdda + 6726ccf commit 7f88aa5

File tree

10 files changed

+371
-168
lines changed

10 files changed

+371
-168
lines changed

api_oc.py

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import web
22
import os
33
import json
4-
from src.wl import WebLogger
4+
#from src.wl import WebLogger
55
import requests
66
import urllib.parse as urlparse
77
import re
@@ -51,7 +51,6 @@
5151
"oci": "tools",
5252
"intrepid": "tools",
5353
"api": "querying",
54-
"api": "querying",
5554
"search": "querying"
5655
}
5756

@@ -70,19 +69,19 @@
7069
)
7170

7271
# Set the web logger
73-
web_logger = WebLogger(env_config["base_url"], env_config["log_dir"], [
74-
"HTTP_X_FORWARDED_FOR", # The IP address of the client
75-
"REMOTE_ADDR", # The IP address of internal balancer
76-
"HTTP_USER_AGENT", # The browser type of the visitor
77-
"HTTP_REFERER", # The URL of the page that called your program
78-
"HTTP_HOST", # The hostname of the page being attempted
79-
"REQUEST_URI", # The interpreted pathname of the requested document
80-
# or CGI (relative to the document root)
81-
"HTTP_AUTHORIZATION", # Access token
82-
],
83-
# comment this line only for test purposes
84-
{"REMOTE_ADDR": ["130.136.130.1", "130.136.2.47", "127.0.0.1"]}
85-
)
72+
# web_logger = WebLogger(env_config["base_url"], env_config["log_dir"], [
73+
# "HTTP_X_FORWARDED_FOR", # The IP address of the client
74+
# "REMOTE_ADDR", # The IP address of internal balancer
75+
# "HTTP_USER_AGENT", # The browser type of the visitor
76+
# "HTTP_REFERER", # The URL of the page that called your program
77+
# "HTTP_HOST", # The hostname of the page being attempted
78+
# "REQUEST_URI", # The interpreted pathname of the requested document
79+
# # or CGI (relative to the document root)
80+
# "HTTP_AUTHORIZATION", # Access token
81+
# ],
82+
# # comment this line only for test purposes
83+
# {"REMOTE_ADDR": ["130.136.130.1", "130.136.2.47", "127.0.0.1"]}
84+
# )
8685

8786
# API Managers
8887
meta_api_manager = APIManager(c["api_meta"])
@@ -104,10 +103,22 @@
104103

105104
application = app.wsgifunc()
106105

107-
rconn = Redis(host=env_config["redis"]["host"],
108-
port=env_config["redis"]["port"],
109-
db=env_config["redis"]["db"],
110-
password=env_config["redis"]["password"])
106+
if env_config["redis"]["enabled"]:
107+
try:
108+
rconn = Redis(
109+
host=env_config["redis"]["host"],
110+
port=env_config["redis"]["port"],
111+
db=env_config["redis"]["db"],
112+
password=env_config["redis"]["password"]
113+
)
114+
# Test della connessione
115+
rconn.ping()
116+
print("Redis connection established")
117+
except Exception as e:
118+
print(f"Redis connection failed: {e}")
119+
rconn = None
120+
else:
121+
rconn = None
111122

112123
def sync_static_files():
113124
"""
@@ -123,7 +134,7 @@ def sync_static_files():
123134
print(f"Unexpected error during synchronization: {e}")
124135

125136
def validateAccessToken():
126-
if not env_config["redis"]["enabled"]:
137+
if not env_config["redis"]["enabled"] or rconn is None:
127138
# If Redis is not enabled, skip token validation
128139
return True
129140
auth_code = web.ctx.env.get('HTTP_AUTHORIZATION')
@@ -205,7 +216,7 @@ def __init__(self, sparql_endpoint, sparql_endpoint_title, yasqe_sparql_endpoint
205216
self.collparam = ["query"]
206217

207218
def GET(self):
208-
web_logger.mes()
219+
#web_logger.mes()
209220
content_type = web.ctx.env.get('CONTENT_TYPE')
210221
return self.__run_query_string(self.sparql_endpoint_title, web.ctx.env.get("QUERY_STRING"), content_type)
211222

@@ -247,7 +258,7 @@ def __contact_tp(self, data, is_post, content_type):
247258
web.header('Content-Type', 'application/sparql-results+json')
248259
else:
249260
web.header('Content-Type', req.headers["content-type"])
250-
web_logger.mes()
261+
#web_logger.mes()
251262
req.encoding = "utf-8"
252263
return req.text
253264
else:
@@ -298,7 +309,7 @@ def __run_query_string(self, active, query_string, is_post=False,
298309

299310
class Main:
300311
def GET(self):
301-
web_logger.mes()
312+
#web_logger.mes()
302313
current_subdomain = web.ctx.host.split('.')[0].lower()
303314
return render.api(active="", sp_title="", sparql_endpoint="", current_subdomain=current_subdomain, render=render)
304315

@@ -362,7 +373,7 @@ def GET(self, dataset, call):
362373
web.header('Content-Type', "text/html")
363374
web.header('Access-Control-Allow-Methods', '*')
364375
web.header('Access-Control-Allow-Headers', 'Authorization')
365-
web_logger.mes()
376+
#web_logger.mes()
366377
return doc.get_documentation()[1]
367378
else:
368379
content_type = web.ctx.env.get('HTTP_ACCEPT')
@@ -391,7 +402,7 @@ def GET(self, dataset, call):
391402
web.header('Access-Control-Allow-Methods', '*')
392403
web.header('Access-Control-Allow-Headers',
393404
'Authorization')
394-
web_logger.mes()
405+
#web_logger.mes()
395406
return res
396407
else:
397408
try:

docker_version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.2sync
1+
1.6.0sync

html-template/common/footer.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</div>
3030
<p class="text-center mt-3">
3131
<span class="d-block d-sm-inline mb-3 mb-sm-0">
32-
<a class="policy oc-purple" href="https://opencitations.net/policy">Privacy Policies</a>
32+
<a class="policy oc-purple" href="https://opencitations.net/privacy-policy/">Privacy Policies</a>
3333
</span>
3434

3535
<span class="separator d-none d-sm-inline"></span>
@@ -55,8 +55,8 @@
5555
<span class="separator d-none d-sm-inline"></span>
5656

5757
<span class="d-block d-sm-inline">
58-
<a href="https://opencitations.net" class="policy oc-purple">
59-
Back to OC Home Page
58+
<a href="https://statistics.opencitations.net" class="policy oc-purple">
59+
Statistics
6060
</a>
6161
</span>
6262
</p>

html-template/common/header.html

Lines changed: 44 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
<nav class="navbar navbar-expand-lg navbar-light bg-light">
44
<div class="container-fluid">
55
<!-- Brand logo -->
6-
<a class="navbar-brand" href="/">
6+
<a class="navbar-brand" href="https://opencitations.net">
77
<img
88
src="/static/img/opencitations-new-logo-small.png"
9-
height="50"
9+
height="80"
10+
width="auto"
1011
alt="Logo"
1112
class="d-inline-block align-top"
1213
/>
1314
</a>
14-
15+
1516
<!-- Mobile hamburger menu -->
1617
<button
1718
class="navbar-toggler"
@@ -24,85 +25,71 @@
2425
>
2526
<span class="navbar-toggler-icon"></span>
2627
</button>
27-
28+
2829
<!-- Main navigation menu -->
2930
<div class="collapse navbar-collapse justify-content-center" id="navbarNav">
30-
<ul class="navbar-nav">
31+
<ul class="navbar-nav navbar-nav-centered">
3132
<!-- Search -->
3233
<li class="nav-item">
33-
<a class="nav-link fw-semibold px-3 ${'active' if current_subdomain == 'search' else ''}"
34+
<a class="nav-link fw-semibold px-3 ${'active' if current_subdomain in ['search', 'search-stg'] else ''}"
3435
href="https://search.opencitations.net">
3536
Search
3637
</a>
3738
</li>
38-
39-
<!-- SPARQL dropdown menu -->
40-
<li class="nav-item dropdown">
41-
<a class="nav-link dropdown-toggle fw-semibold px-3 ${'active' if current_subdomain == 'sparql' else ''}"
42-
href="https://sparql.opencitations.net"
43-
id="sparqlDropdown"
44-
role="button"
45-
data-bs-toggle="dropdown"
46-
aria-expanded="false">
39+
40+
<li class="nav-item">
41+
<a class="nav-link fw-semibold px-3 ${'active' if current_subdomain in ['sparql', 'sparql-stg'] else ''}"
42+
href="https://sparql.opencitations.net">
4743
SPARQL
4844
</a>
49-
<ul class="dropdown-menu" aria-labelledby="sparqlDropdown">
50-
<li>
51-
<a class="dropdown-item ${'active' if sp_title == 'meta' else ''}" href="https://sparql.opencitations.net/meta">
52-
Meta
53-
</a>
54-
</li>
55-
<li>
56-
<a class="dropdown-item ${'active' if sp_title == 'index' else ''}" href="https://sparql.opencitations.net/index">
57-
Index
58-
</a>
59-
</li>
60-
</ul>
6145
</li>
62-
63-
<!-- API dropdown menu -->
64-
<li class="nav-item dropdown">
65-
<a class="nav-link dropdown-toggle fw-semibold px-3 ${'active' if current_subdomain == 'api' else ''}"
66-
href="https://api.opencitations.net"
67-
id="apiDropdown"
68-
role="button"
69-
data-bs-toggle="dropdown"
70-
aria-expanded="false">
46+
47+
<li class="nav-item">
48+
<a class="nav-link fw-semibold px-3 ${'active' if current_subdomain in ['api', 'api-stg'] else ''}"
49+
href="https://api.opencitations.net">
7150
API
7251
</a>
73-
<ul class="dropdown-menu" aria-labelledby="apiDropdown">
74-
<li>
75-
<a class="dropdown-item"
76-
href="https://api.opencitations.net/meta">
77-
Meta
78-
</a>
79-
</li>
80-
<li>
81-
<a class="dropdown-item"
82-
href="https://api.opencitations.net/index">
83-
Index
84-
</a>
85-
</li>
86-
</ul>
8752
</li>
88-
89-
<!-- Dataset Downloads link -->
53+
9054
<li class="nav-item">
91-
<a class="nav-link fw-semibold px-3 ${'active' if current_subdomain == 'download' else ''}"
55+
<a class="nav-link fw-semibold px-3 ${'active' if current_subdomain in ['download', 'download-stg'] else ''}"
9256
href="https://download.opencitations.net">
9357
Download
9458
</a>
9559
</li>
60+
<li class="nav-item">
61+
<a class="nav-link fw-semibold px-3 ${'active' if current_subdomain in ['statistics', 'statistics-stg'] else ''}"
62+
href="https://statistics.opencitations.net">
63+
Statistics
64+
</a>
65+
</li>
9666
</ul>
9767
</div>
9868
</div>
9969
</nav>
10070
</header>
101-
102-
$if current_subdomain == 'sparql' and sp_title in ['meta', 'index']:
71+
$if current_subdomain in ['sparql', 'sparql-stg'] and sp_title in ['meta', 'index']:
10372
<nav aria-label="breadcrumb" class="mt-3 ms-3">
10473
<ol class="breadcrumb">
105-
<li class="breadcrumb-item"><a href="https://sparql.opencitations.net">SPARQL</a></li>
74+
<li class="breadcrumb-item"><a href="https://${current_subdomain}.opencitations.net">SPARQL</a></li>
10675
<li class="breadcrumb-item active" aria-current="page">$sp_title.capitalize()</li>
10776
</ol>
108-
</nav>
77+
</nav>
78+
79+
$if current_subdomain in ['search', 'search-stg'] and web.ctx.path.startswith('/search'):
80+
$ query_params = web.input(text="", rule="")
81+
<nav aria-label="breadcrumb" class="mt-3 ms-3">
82+
<ol class="breadcrumb">
83+
<li class="breadcrumb-item"><a href="https://${current_subdomain}.opencitations.net">Search</a></li>
84+
<li class="breadcrumb-item active" aria-current="page">
85+
$if query_params.rule == "citeddoi" and query_params.text:
86+
Citing $query_params.text
87+
$elif query_params.rule == "citingdoi" and query_params.text:
88+
Cited by $query_params.text
89+
$else:
90+
Current Search
91+
</li>
92+
</ol>
93+
</nav>
94+
95+

src/wl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __set_file_handler(self):
4646
if not path.exists(file_path):
4747
file_dir = path.dirname(file_path)
4848
if not path.exists(file_dir):
49-
makedirs(file_dir)
49+
makedirs(file_dir, exist_ok=True)
5050
open(file_path, "a").close()
5151

5252
file_handler = logging.FileHandler(file_path)

static/css/cover.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ dd > blockquote {
9999
}
100100

101101
.search-entry .form-control{
102-
font-size:20px;
102+
font-size:15pt;
103+
}
104+
.search-entry .form-control::placeholder {
105+
color: #999999 ;
106+
opacity: 1;
103107
}
104108

105109
pre code {

0 commit comments

Comments
 (0)