quran-madina-html 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/db_test.yml +26 -0
- package/.github/workflows/npm-grunt.yml +28 -0
- package/.github/workflows/pylint.yml +24 -0
- package/.vscode/extensions.json +5 -0
- package/.vscode/launch.json +16 -0
- package/.vscode/settings.json +30 -0
- package/DBs/Madina-Amiri-16px.json +114356 -0
- package/DBs/Madina-Amiri-24px.json +114356 -0
- package/DBs/Madina-Uthman-14px.json +114356 -0
- package/DBs/Madina-Uthman-16px.json +114356 -0
- package/Gruntfile.js +52 -0
- package/README.md +41 -0
- package/assets/fonts/AmiriQuran.woff2 +0 -0
- package/assets/fonts/AmiriQuranColored.woff2 +0 -0
- package/assets/fonts/UthmanTN_v2-0.woff2 +0 -0
- package/assets/fonts/hafs.woff2 +0 -0
- package/bower.json +16 -0
- package/build_all.py +30 -0
- package/build_db.py +269 -0
- package/db_test.py +32 -0
- package/demo/index.html +20 -0
- package/demo/x-tag-components.js +4784 -0
- package/dist/quran-madina-html-0.1.2.min.js +2 -0
- package/dist/quran-madina-html.js +4915 -0
- package/package.json +181 -0
- package/part_width_test.html +41 -0
- package/requirements.txt +4 -0
- package/src/quran-madina-html.css +10 -0
- package/src/quran-madina-html.js +131 -0
package/package.json
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "quran-madina-html",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"devDependencies": {
|
|
5
|
+
"bower": "^1.8.14",
|
|
6
|
+
"grunt": "^1.6.1",
|
|
7
|
+
"grunt-contrib-concat": "^2.1.0",
|
|
8
|
+
"grunt-contrib-jshint": "^3.2.0",
|
|
9
|
+
"grunt-contrib-uglify": "^5.2.2",
|
|
10
|
+
"grunt-contrib-watch": "^1.1.0"
|
|
11
|
+
},
|
|
12
|
+
"description": "A Madina Quran HTML Renderer without images.",
|
|
13
|
+
"main": "Gruntfile.js",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"abbrev": "^1.1.1",
|
|
16
|
+
"ansi-styles": "^4.3.0",
|
|
17
|
+
"argparse": "^1.0.10",
|
|
18
|
+
"array-each": "^1.0.1",
|
|
19
|
+
"array-slice": "^1.1.0",
|
|
20
|
+
"async": "^2.6.4",
|
|
21
|
+
"balanced-match": "^1.0.2",
|
|
22
|
+
"body": "^5.1.0",
|
|
23
|
+
"brace-expansion": "^1.1.11",
|
|
24
|
+
"braces": "^3.0.2",
|
|
25
|
+
"bytes": "^1.0.0",
|
|
26
|
+
"call-bind": "^1.0.2",
|
|
27
|
+
"chalk": "^4.1.2",
|
|
28
|
+
"cli": "^1.0.1",
|
|
29
|
+
"color-convert": "^2.0.1",
|
|
30
|
+
"color-name": "^1.1.4",
|
|
31
|
+
"colors": "^1.1.2",
|
|
32
|
+
"concat-map": "^0.0.1",
|
|
33
|
+
"console-browserify": "^1.1.0",
|
|
34
|
+
"continuable-cache": "^0.3.1",
|
|
35
|
+
"core-util-is": "^1.0.3",
|
|
36
|
+
"date-now": "^0.1.4",
|
|
37
|
+
"dateformat": "^4.6.3",
|
|
38
|
+
"debug": "^3.2.7",
|
|
39
|
+
"detect-file": "^1.0.0",
|
|
40
|
+
"dom-serializer": "^0.2.2",
|
|
41
|
+
"domelementtype": "^1.3.1",
|
|
42
|
+
"domhandler": "^2.3.0",
|
|
43
|
+
"domutils": "^1.5.1",
|
|
44
|
+
"duplexer": "^0.1.2",
|
|
45
|
+
"entities": "^1.0.0",
|
|
46
|
+
"error": "^7.2.1",
|
|
47
|
+
"escape-string-regexp": "^1.0.5",
|
|
48
|
+
"esprima": "^4.0.1",
|
|
49
|
+
"eventemitter2": "^0.4.14",
|
|
50
|
+
"exit": "^0.1.2",
|
|
51
|
+
"expand-tilde": "^2.0.2",
|
|
52
|
+
"extend": "^3.0.2",
|
|
53
|
+
"faye-websocket": "^0.10.0",
|
|
54
|
+
"figures": "^3.2.0",
|
|
55
|
+
"fill-range": "^7.0.1",
|
|
56
|
+
"findup-sync": "^5.0.0",
|
|
57
|
+
"fined": "^1.2.0",
|
|
58
|
+
"flagged-respawn": "^1.0.1",
|
|
59
|
+
"for-in": "^1.0.2",
|
|
60
|
+
"for-own": "^1.0.0",
|
|
61
|
+
"fs.realpath": "^1.0.0",
|
|
62
|
+
"function-bind": "^1.1.1",
|
|
63
|
+
"gaze": "^1.1.3",
|
|
64
|
+
"get-intrinsic": "^1.2.1",
|
|
65
|
+
"getobject": "^1.0.2",
|
|
66
|
+
"glob": "^7.1.7",
|
|
67
|
+
"global-modules": "^1.0.0",
|
|
68
|
+
"global-prefix": "^1.0.2",
|
|
69
|
+
"globule": "^1.3.4",
|
|
70
|
+
"grunt-cli": "^1.4.3",
|
|
71
|
+
"grunt-known-options": "^2.0.0",
|
|
72
|
+
"grunt-legacy-log": "^3.0.0",
|
|
73
|
+
"grunt-legacy-log-utils": "^2.1.0",
|
|
74
|
+
"grunt-legacy-util": "^2.0.1",
|
|
75
|
+
"gzip-size": "^5.1.1",
|
|
76
|
+
"has": "^1.0.3",
|
|
77
|
+
"has-flag": "^4.0.0",
|
|
78
|
+
"has-proto": "^1.0.1",
|
|
79
|
+
"has-symbols": "^1.0.3",
|
|
80
|
+
"homedir-polyfill": "^1.0.3",
|
|
81
|
+
"hooker": "^0.2.3",
|
|
82
|
+
"htmlparser2": "^3.8.3",
|
|
83
|
+
"http-parser-js": "^0.5.8",
|
|
84
|
+
"iconv-lite": "^0.6.3",
|
|
85
|
+
"inflight": "^1.0.6",
|
|
86
|
+
"inherits": "^2.0.4",
|
|
87
|
+
"ini": "^1.3.8",
|
|
88
|
+
"interpret": "^1.1.0",
|
|
89
|
+
"is-absolute": "^1.0.0",
|
|
90
|
+
"is-core-module": "^2.12.1",
|
|
91
|
+
"is-extglob": "^2.1.1",
|
|
92
|
+
"is-glob": "^4.0.3",
|
|
93
|
+
"is-number": "^7.0.0",
|
|
94
|
+
"is-plain-object": "^2.0.4",
|
|
95
|
+
"is-relative": "^1.0.0",
|
|
96
|
+
"is-unc-path": "^1.0.0",
|
|
97
|
+
"is-windows": "^1.0.2",
|
|
98
|
+
"isarray": "^0.0.1",
|
|
99
|
+
"isexe": "^2.0.0",
|
|
100
|
+
"isobject": "^3.0.1",
|
|
101
|
+
"js-yaml": "^3.14.1",
|
|
102
|
+
"jshint": "^2.13.6",
|
|
103
|
+
"kind-of": "^6.0.3",
|
|
104
|
+
"liftup": "^3.0.1",
|
|
105
|
+
"livereload-js": "^2.4.0",
|
|
106
|
+
"lodash": "^4.17.21",
|
|
107
|
+
"make-iterator": "^1.0.1",
|
|
108
|
+
"map-cache": "^0.2.2",
|
|
109
|
+
"maxmin": "^3.0.0",
|
|
110
|
+
"micromatch": "^4.0.5",
|
|
111
|
+
"minimatch": "^3.0.8",
|
|
112
|
+
"ms": "^2.1.3",
|
|
113
|
+
"nopt": "^3.0.6",
|
|
114
|
+
"object-assign": "^4.1.1",
|
|
115
|
+
"object-inspect": "^1.12.3",
|
|
116
|
+
"object.defaults": "^1.1.0",
|
|
117
|
+
"object.map": "^1.0.1",
|
|
118
|
+
"object.pick": "^1.3.0",
|
|
119
|
+
"once": "^1.4.0",
|
|
120
|
+
"os-homedir": "^1.0.2",
|
|
121
|
+
"os-tmpdir": "^1.0.2",
|
|
122
|
+
"osenv": "^0.1.5",
|
|
123
|
+
"parse-filepath": "^1.0.2",
|
|
124
|
+
"parse-passwd": "^1.0.0",
|
|
125
|
+
"path-is-absolute": "^1.0.1",
|
|
126
|
+
"path-parse": "^1.0.7",
|
|
127
|
+
"path-root": "^0.1.1",
|
|
128
|
+
"path-root-regex": "^0.1.2",
|
|
129
|
+
"picomatch": "^2.3.1",
|
|
130
|
+
"pify": "^4.0.1",
|
|
131
|
+
"pretty-bytes": "^5.6.0",
|
|
132
|
+
"qs": "^6.11.2",
|
|
133
|
+
"raw-body": "^1.1.7",
|
|
134
|
+
"readable-stream": "^1.1.14",
|
|
135
|
+
"rechoir": "^0.7.1",
|
|
136
|
+
"resolve": "^1.22.2",
|
|
137
|
+
"resolve-dir": "^1.0.1",
|
|
138
|
+
"safe-buffer": "^5.2.1",
|
|
139
|
+
"safe-json-parse": "^1.0.1",
|
|
140
|
+
"safer-buffer": "^2.1.2",
|
|
141
|
+
"side-channel": "^1.0.4",
|
|
142
|
+
"source-map": "^0.5.7",
|
|
143
|
+
"sprintf-js": "^1.0.3",
|
|
144
|
+
"string-template": "^0.2.1",
|
|
145
|
+
"string_decoder": "^0.10.31",
|
|
146
|
+
"strip-json-comments": "^1.0.4",
|
|
147
|
+
"supports-color": "^7.2.0",
|
|
148
|
+
"supports-preserve-symlinks-flag": "^1.0.0",
|
|
149
|
+
"tiny-lr": "^1.1.1",
|
|
150
|
+
"to-regex-range": "^5.0.1",
|
|
151
|
+
"uglify-js": "^3.17.4",
|
|
152
|
+
"unc-path-regex": "^0.1.2",
|
|
153
|
+
"underscore.string": "^3.3.6",
|
|
154
|
+
"uri-path": "^1.0.0",
|
|
155
|
+
"util-deprecate": "^1.0.2",
|
|
156
|
+
"v8flags": "^3.2.0",
|
|
157
|
+
"websocket-driver": "^0.7.4",
|
|
158
|
+
"websocket-extensions": "^0.1.4",
|
|
159
|
+
"which": "^2.0.2",
|
|
160
|
+
"wrappy": "^1.0.2"
|
|
161
|
+
},
|
|
162
|
+
"scripts": {
|
|
163
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
164
|
+
},
|
|
165
|
+
"repository": {
|
|
166
|
+
"type": "git",
|
|
167
|
+
"url": "git+https://github.com/tarekeldeeb/quran-madina-html-no-images.git"
|
|
168
|
+
},
|
|
169
|
+
"keywords": [
|
|
170
|
+
"quran",
|
|
171
|
+
"html",
|
|
172
|
+
"x-tag",
|
|
173
|
+
"madina"
|
|
174
|
+
],
|
|
175
|
+
"author": "Tarek Eldeeb",
|
|
176
|
+
"license": "ISC",
|
|
177
|
+
"bugs": {
|
|
178
|
+
"url": "https://github.com/tarekeldeeb/quran-madina-html-no-images/issues"
|
|
179
|
+
},
|
|
180
|
+
"homepage": "https://github.com/tarekeldeeb/quran-madina-html-no-images#readme"
|
|
181
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
|
|
3
|
+
<html>
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8"/>
|
|
6
|
+
<title>Arabic Text with Amiri Font</title>
|
|
7
|
+
<link href="https://fonts.cdnfonts.com/css/amiri-quran-colored" rel="stylesheet"/>
|
|
8
|
+
<style>
|
|
9
|
+
@font-face {
|
|
10
|
+
font-family: 'me_quran';
|
|
11
|
+
src: url('https://icikiwir.github.io/test/me_quran.woff') format('woff');
|
|
12
|
+
font-weight: normal;
|
|
13
|
+
font-style: normal;
|
|
14
|
+
}
|
|
15
|
+
body {
|
|
16
|
+
font-family: "Amiri Quran Colored", serif;
|
|
17
|
+
font-size: 16px;
|
|
18
|
+
}
|
|
19
|
+
.container {
|
|
20
|
+
width: 260px;
|
|
21
|
+
margin: 0 auto; /* to center the container horizontally */
|
|
22
|
+
border-style: solid;
|
|
23
|
+
display: block;
|
|
24
|
+
}
|
|
25
|
+
.text {
|
|
26
|
+
direction: rtl;
|
|
27
|
+
float: right;
|
|
28
|
+
border-style: dotted;
|
|
29
|
+
border-width: thin;
|
|
30
|
+
border-color: blue;
|
|
31
|
+
white-space: nowrap;
|
|
32
|
+
}
|
|
33
|
+
</style>
|
|
34
|
+
</head>
|
|
35
|
+
<body>
|
|
36
|
+
<div class="container">
|
|
37
|
+
<span class="text" id="test">هذا نص باللغة العربية يستخدم خط الأميري</span>
|
|
38
|
+
</div>
|
|
39
|
+
</body>
|
|
40
|
+
</html>
|
|
41
|
+
<!-- document.getElementById("test").getBoundingClientRect().width - 4.8 -->
|
package/requirements.txt
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
(function(){
|
|
2
|
+
var name = "quran-madina-html";
|
|
3
|
+
var cdn = 'https://raw.githubusercontent.com/tarekeldeeb/quran-madina-html-no-images/main/DBs/';
|
|
4
|
+
function loadJSON(path, success, error){
|
|
5
|
+
var xhr = new XMLHttpRequest();
|
|
6
|
+
xhr.onreadystatechange = function()
|
|
7
|
+
{
|
|
8
|
+
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
9
|
+
if (xhr.status === 200) {
|
|
10
|
+
if (success)
|
|
11
|
+
success(JSON.parse(xhr.responseText));
|
|
12
|
+
} else {
|
|
13
|
+
if (error)
|
|
14
|
+
error(xhr);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
xhr.open("GET", path, true);
|
|
19
|
+
xhr.send();
|
|
20
|
+
}
|
|
21
|
+
function parseRange(str){
|
|
22
|
+
if (str.split('-').length == 2) return str.split('-').map(elem => elem -1);
|
|
23
|
+
return Array(2).fill(str.split('-')[0]-1);
|
|
24
|
+
}
|
|
25
|
+
var madina_data = {"content":"Loading .."};
|
|
26
|
+
var this_script = document.querySelector('script[data-name]');
|
|
27
|
+
var doc_name = this_script.getAttribute('data-name') || "Madina";
|
|
28
|
+
var doc_font = this_script.getAttribute('data-font') || "Amiri";
|
|
29
|
+
var doc_font_sz = this_script.getAttribute('data-font-size') || 16;
|
|
30
|
+
console.log("Quran> "+doc_name+" with font:"+doc_font+" size:"+doc_font_sz);
|
|
31
|
+
const name_css = "../src/"+name+".css";
|
|
32
|
+
if (!document.getElementById(name))
|
|
33
|
+
{
|
|
34
|
+
var head = document.getElementsByTagName('head')[0];
|
|
35
|
+
var link = document.createElement('link');
|
|
36
|
+
link.id = name;
|
|
37
|
+
link.rel = 'stylesheet';
|
|
38
|
+
link.type = 'text/css';
|
|
39
|
+
link.href = name_css;
|
|
40
|
+
link.media = 'all';
|
|
41
|
+
head.appendChild(link);
|
|
42
|
+
}
|
|
43
|
+
loadJSON(cdn+doc_name+'-'+doc_font+'-'+doc_font_sz+'px.json',
|
|
44
|
+
function(data) {
|
|
45
|
+
madina_data = data;
|
|
46
|
+
const myFont = new FontFace(madina_data.font_family, 'url('+encodeURI(madina_data.font_url)+')');
|
|
47
|
+
myFont.load().then( () => {document.fonts.add(myFont);});
|
|
48
|
+
xtag.register('quran-madina-html', {
|
|
49
|
+
lifecycle: {
|
|
50
|
+
created: function() {
|
|
51
|
+
this.render(this);
|
|
52
|
+
},
|
|
53
|
+
inserted: function() {},
|
|
54
|
+
removed: function() {},
|
|
55
|
+
attributeChanged: function() {}
|
|
56
|
+
},
|
|
57
|
+
events: {},
|
|
58
|
+
accessors: {
|
|
59
|
+
aya:{
|
|
60
|
+
attribute: {},
|
|
61
|
+
set: function(value) {
|
|
62
|
+
this.xtag.data.aya = value;
|
|
63
|
+
},
|
|
64
|
+
get: function(){
|
|
65
|
+
return this.getAttribute("aya");
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
sura:{
|
|
69
|
+
attribute: {},
|
|
70
|
+
set: function(value) {
|
|
71
|
+
this.xtag.data.sura = value;
|
|
72
|
+
},
|
|
73
|
+
get: function(){
|
|
74
|
+
return this.getAttribute("sura");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
methods: {
|
|
79
|
+
render: function(tag){
|
|
80
|
+
var sura = parseRange(this.sura)[0]; // Only a single Sura
|
|
81
|
+
var multiline = false;
|
|
82
|
+
[aya_from,aya_to] = parseRange(this.aya);
|
|
83
|
+
var line_from = madina_data.suras[sura].ayas[aya_from].r[0].l;
|
|
84
|
+
var line_to = madina_data.suras[sura].ayas[aya_to].r.slice(-1)[0].l;
|
|
85
|
+
|
|
86
|
+
if(line_from!=line_to){
|
|
87
|
+
multiline = true;
|
|
88
|
+
tag.style = "display:block;";
|
|
89
|
+
}
|
|
90
|
+
if(multiline){
|
|
91
|
+
tag.style.setProperty('font-family', madina_data.font_family, '');
|
|
92
|
+
tag.style.setProperty('font-size', madina_data.font_size+"px", '');
|
|
93
|
+
}
|
|
94
|
+
var aya_current = aya_from;
|
|
95
|
+
for(let l = line_from; l <= line_to; l++) {
|
|
96
|
+
const ll = l; //Const for inner loops to refer
|
|
97
|
+
line = document.createElement("quran-madina-html-line");
|
|
98
|
+
tag.appendChild(line);
|
|
99
|
+
if(!multiline){
|
|
100
|
+
line.style.setProperty('font-family', madina_data.font_family, '');
|
|
101
|
+
line.style.setProperty('font-size', madina_data.font_size+"px", '');
|
|
102
|
+
}
|
|
103
|
+
if(multiline){
|
|
104
|
+
tag.style.width = (madina_data.line_width+10)+"px";
|
|
105
|
+
let isRightPage = madina_data.suras[sura].ayas[aya_from].p%2==1?"":"-";
|
|
106
|
+
tag.style.setProperty('box-shadow', 'inset '+isRightPage+'8px 0 7px -7px #333','');
|
|
107
|
+
line.style.setProperty('display','block','');
|
|
108
|
+
}
|
|
109
|
+
for(let a = aya_current; a < aya_current+5 && a <=aya_to ; a++) { //Look ahead
|
|
110
|
+
line_match = madina_data.suras[sura].ayas[a].r.filter(rr => rr.l == ll);
|
|
111
|
+
if (line_match.length){
|
|
112
|
+
if(line.innerHTML.trim() == ""){ // First part in the line
|
|
113
|
+
var offset = line_match[0].o;
|
|
114
|
+
line.style.setProperty('padding-right', offset+"px", '');
|
|
115
|
+
if(offset > 0) line.style.setProperty('transform-origin', "left");
|
|
116
|
+
}
|
|
117
|
+
line.style.setProperty("transform","scaleX("+line_match[0].s+")","");
|
|
118
|
+
line.innerHTML += line_match[0].t;
|
|
119
|
+
aya_current = a;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
},
|
|
128
|
+
function(xhr) { console.error(xhr); }
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
})();
|