Skip to content

Commit 4bf4987

Browse files
authored
Merge pull request #31 from MrIbrahem/z
Z
2 parents d530200 + c0db76e commit 4bf4987

File tree

16 files changed

+220
-196
lines changed

16 files changed

+220
-196
lines changed

.github/workflows/update_html.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ jobs:
1818
script_stop: true
1919
key: ${{ secrets.KEY }}
2020
script: |
21-
become arlexemes sh -c "~/sh/update_html.sh"
21+
become arlexemes bash -lc "~/sh/update_html.sh"

.github/workflows/update_py.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ jobs:
1818
script_stop: true
1919
key: ${{ secrets.KEY }}
2020
script: |
21-
become arlexemes sh -c "
21+
become arlexemes bash -lc "
2222
~/sh/update_py.sh &&
23+
toolforge-jobs run pipup --image python3.11 --command "~/sh/install_req.sh" --wait &&
2324
toolforge-webservice stop &&
2425
toolforge-webservice python3.11 start &&
25-
echo 'done..'
26+
echo \"Updated on: $(date '+%Y-%m-%d %H:%M:%S')\" > ~/update_from_github &&
27+
echo ''
2628
"

.gitignore

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,20 @@ python/src/insert_data/Qabas-dataset_with_SAMA.json
1212
/python/src/insert_data1
1313
python/src/no_data_tab1.json
1414
python/src/no_data_tab.json
15-
/public_html/cache
16-
17-
/public_html/adminer
18-
/public_html/cssx
19-
/public_html/jsx
20-
public_html/web.config
21-
/public_html
2215
python/src/static/js/duplicate_lemmas2.js
2316
python/src/static/js/‏‏duplicate_lemmas - نسخة.js
2417
python/src/logs/errors.log
2518
logs/errors.log
2619
.claude/
20+
21+
public_html/**
22+
23+
!public_html/edit
24+
!public_html/edit1
25+
!public_html/edit2
26+
27+
!public_html/edit/**
28+
!public_html/edit1/**
29+
!public_html/edit2/**
30+
/public_html1
31+
/public_html

python/src/jobs/insert_data/insert_all.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
"""
3-
python3 I:/milion/arlexemes/python/src/jobs/insert_data/insert_all.py
3+
python3 D:/arlexemes/python/src/jobs/insert_data/insert_all.py
44
55
This script inserts lemma data from JSON files into the database.
66
"""

python/src/jobs/insert_data/x.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
3-
python I:/milion/arlexemes/python/src/insert_data/x.py
3+
python D:/arlexemes/python/src/insert_data/x.py
44
55
"""
66
from pathlib import Path

python/src/jobs/update_wd/wd_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
"""
33
4-
python3 I:/milion/arlexemes/python/src/jobs/update_wd/wd_data.py
4+
python3 D:/arlexemes/python/src/jobs/update_wd/wd_data.py
55
python3 www/python/src/jobs/update_wd/wd_data.py
66
77
"""

python/src/run.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python3 I:\milion\arlexemes\python\src\app.py debug
1+
python3 D:\arlexemes\python\src\app.py debug
Lines changed: 99 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
1-
21
let treeData = [];
2+
let currentPage = 1;
3+
let currentLimit = 1000;
4+
let currentDataSource = "all";
35

4-
async function make_wd_result_for_list(limit, data_source) {
5-
6-
let sparqlQuery = list_lexemes_query(limit, data_source);
7-
// ---
6+
async function make_wd_result_for_list(data_source, limit, offset, page_type) {
7+
let sparqlQuery;
8+
if (page_type === "new") {
9+
// Use the new lexemes query for the "new" page type
10+
sparqlQuery = new_ar_lexemes_query(data_source, limit, offset);
11+
} else {
12+
// Use the list lexemes query for the "list" page type
13+
sparqlQuery = list_lexemes_query(data_source, limit, offset);
14+
}
815
add_sparql_url(sparqlQuery);
9-
// ---
16+
1017
let result = await loadsparqlQuery(sparqlQuery);
1118

1219
let wd_result = parse_results_group_by(result);
1320

1421
return wd_result;
1522
}
1623

17-
async function fetchListData(limit, data_source) {
18-
// ---
19-
let treeMap = await make_wd_result_for_list(limit, data_source);
24+
async function fetchListData(data_source, limit, page, page_type) {
25+
26+
let offset = (page - 1) * limit;
27+
28+
let treeMap = await make_wd_result_for_list(data_source, limit, offset, page_type);
2029

2130
treeMap = slice_data(treeMap);
2231

@@ -28,28 +37,37 @@ async function fetchListData(limit, data_source) {
2837

2938
treeData = Object.values(treeMap);
3039
renderTree(treeData);
40+
41+
// Update pagination controls
42+
updatePaginationControls(page, limit, count);
3143
}
3244

33-
function loadfetchData() {
34-
// ---
45+
function loadfetchData(page_type = "list") {
46+
3547
showLoading();
36-
// ---
37-
let limit = get_param_from_window_location("limit", 1000);
48+
49+
let limit = parseInt(get_param_from_window_location("limit", 100));
3850
let data_source = get_param_from_window_location("data_source", "all");
3951
let custom_data_source = get_param_from_window_location("custom_data_source", "");
40-
// ---
52+
let page = parseInt(get_param_from_window_location("page", 1));
53+
4154
// document.getElementById('custom_data_source').value = custom_data_source;
42-
// ---
55+
4356
$("#limit").val(limit);
4457
$("#data_source").val(data_source);
45-
// ---
58+
4659
if (custom_data_source !== "" && data_source === "custom") {
4760
$("#custom_data_source").val(custom_data_source);
4861
data_source = custom_data_source;
4962
document.getElementById('custom_data_source').style.display = 'block';
5063
}
51-
// ---
52-
fetchListData(limit, data_source);
64+
65+
// Store current state
66+
currentPage = page;
67+
currentLimit = limit;
68+
currentDataSource = data_source;
69+
70+
fetchListData(currentDataSource, currentLimit, currentPage, page_type);
5371
}
5472

5573
function toggleCustomInput() {
@@ -61,10 +79,69 @@ function toggleCustomInput() {
6179
customInput.style.display = 'none';
6280
}
6381
}
82+
function updatePaginationControls(page, limit, count) {
83+
// Show or hide pagination based on whether we got full results
84+
const paginationDiv = document.getElementById("pagination_controls");
85+
if (!paginationDiv) return;
86+
87+
const prevBtn = document.getElementById("prev_page");
88+
const nextBtn = document.getElementById("next_page");
89+
// Only show pagination if we got results equal to limit (suggesting more pages exist)
90+
if (count < limit && page === 1) {
91+
prevBtn.classList.add('d-none');
92+
nextBtn.classList.add('d-none');
93+
return;
94+
}
95+
96+
// paginationDiv.classList.remove('d-none');
97+
// paginationDiv.classList.add('d-flex');
98+
99+
// Update page info
100+
// document.getElementById("page_info").textContent = `الصفحة ${page}`;
101+
102+
// Enable/disable previous button
103+
if (page <= 1) {
104+
prevBtn.classList.add('disabled');
105+
prevBtn.setAttribute('disabled', 'disabled');
106+
} else {
107+
prevBtn.classList.remove('disabled');
108+
prevBtn.removeAttribute('disabled');
109+
}
110+
111+
// Enable/disable next button based on whether we got full results
112+
if (count < limit) {
113+
nextBtn.classList.add('disabled');
114+
nextBtn.setAttribute('disabled', 'disabled');
115+
} else {
116+
nextBtn.classList.remove('disabled');
117+
nextBtn.removeAttribute('disabled');
118+
}
119+
}
120+
121+
function navigateToPage(page) {
122+
const urlParams = new URLSearchParams(window.location.search);
123+
urlParams.set('page', page);
124+
window.location.search = urlParams.toString();
125+
}
126+
127+
function previousPage() {
128+
if (currentPage > 1) {
129+
navigateToPage(currentPage - 1);
130+
}
131+
}
132+
133+
function nextPage() {
134+
navigateToPage(currentPage + 1);
135+
}
136+
64137
async function load_list() {
65-
// ---
66-
loadfetchData();
67-
// ---
138+
loadfetchData("list");
68139
toggleCustomInput();
69-
// ---
140+
141+
}
142+
143+
async function load_new() {
144+
loadfetchData("new");
145+
toggleCustomInput();
146+
70147
}

python/src/static/js/lexemes/new.js

Lines changed: 0 additions & 68 deletions
This file was deleted.

python/src/static/js/lexemes/queries.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function wg_tree_query(data_source, to_group_by, limit) {
7676
return sparqlQuery;
7777
}
7878

79-
function new_ar_lexemes_query(data_source, limit) {
79+
function new_ar_lexemes_query(data_source, limit, offset) {
8080
// ---
8181
let VALUES = ``;
8282
// ---
@@ -91,6 +91,10 @@ function new_ar_lexemes_query(data_source, limit) {
9191
limit_line = ` LIMIT ${limit} `;
9292
}
9393
// ---
94+
if (offset && isFinite(offset)) {
95+
limit_line += ` OFFSET ${offset} `;
96+
}
97+
// ---
9498
let sparqlQuery = `
9599
SELECT
96100
?item
@@ -125,16 +129,7 @@ function new_ar_lexemes_query(data_source, limit) {
125129
}
126130

127131

128-
function list_lexemes_query(limit, data_source) {
129-
// ---
130-
const sparqlQuery1 = `
131-
VALUES ?category {
132-
wd:Q111029 # جذر
133-
wd:Q1084 # اسم
134-
wd:Q24905 # فعل
135-
wd:Q34698 # صفة
136-
}
137-
`;
132+
function list_lexemes_query(data_source, limit, offset) {
138133
// ---
139134
let VALUES = ``;
140135
// ---
@@ -149,6 +144,10 @@ function list_lexemes_query(limit, data_source) {
149144
limit_line = ` LIMIT ${limit} `;
150145
}
151146
// ---
147+
if (offset && isFinite(offset)) {
148+
limit_line += ` OFFSET ${offset} `;
149+
}
150+
// ---
152151
let sparqlQuery = `
153152
SELECT
154153
?item

0 commit comments

Comments
 (0)