prototype.exe 0.0.4 → 0.0.6
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/package.json +1 -1
- package/src/prototype.js +185 -9
package/package.json
CHANGED
package/src/prototype.js
CHANGED
|
@@ -61,10 +61,9 @@ Define (Object.type_of, "regex", function (input) { if (arguments.length) return
|
|
|
61
61
|
Define (Object.type_of, "string", function (input) { if (arguments.length) return Object.type_of (input) === "[object String]"; else return "[object String]"; });
|
|
62
62
|
|
|
63
63
|
Define (Object, "is", function () {});
|
|
64
|
-
Define (Object.is, "
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
64
|
+
Define (Object.is, "set", function (input) { return ! Object.un_set (input); });
|
|
65
|
+
Define (Object.is, "function", function (input) { return ["function", "object"].includes (input); });
|
|
66
|
+
Define (Object.is, "url", function (input) { if (typeof input === "string") return input.startsWith ("http://") || input.startsWith ("https://") || input.startsWith ("//"); else return false; });
|
|
68
67
|
Define (Object.is, "ip", function (input) {
|
|
69
68
|
var part = input.split (".");
|
|
70
69
|
if (part.length === 4) {
|
|
@@ -83,7 +82,6 @@ Define (Object, "clone", function (object) { return JSON.parse (JSON.stringify (
|
|
|
83
82
|
|
|
84
83
|
Define (Object, "un_define", function (input) { if (arguments.length) return input === undefined; else return undefined; });
|
|
85
84
|
Define (Object, "un_set", function (input) { return input === undefined || input === null; });
|
|
86
|
-
Define (Object.is, "set", function (input) { return ! Object.un_set (input); });
|
|
87
85
|
|
|
88
86
|
/**
|
|
89
87
|
* array
|
|
@@ -824,6 +822,7 @@ Define (Function.theme, "is_night", function () { return window.matchMedia && wi
|
|
|
824
822
|
Define (Function, "html", class {
|
|
825
823
|
constructor () {
|
|
826
824
|
this.markup = new Function.html.markup ("html");
|
|
825
|
+
this.context = {}
|
|
827
826
|
this.var = {
|
|
828
827
|
title: "Untitled",
|
|
829
828
|
viewport: "width=device-width, initial-scale=1.0, maximum-scale=3.0, user-scalable=1",
|
|
@@ -835,8 +834,8 @@ Define (Function, "html", class {
|
|
|
835
834
|
error: {},
|
|
836
835
|
}
|
|
837
836
|
}
|
|
838
|
-
title (title) { if (Object.is.set (title)) this.var.title = title; return this.var.title; }
|
|
839
|
-
description (description) { if (Object.is.set (description)) this.var.description = description; return this.var.description; }
|
|
837
|
+
title (title, context) { if (["function", "object"].includes (typeof title) && ! this.context.title && ["context", "format"].includes (title.name)) this.context.title = title; else if (arguments.length > 1 && this.context.title) return this.var.title = this.context.title (title, context); else if (Object.is.set (title)) this.var.title = title; return this.var.title; }
|
|
838
|
+
description (description, context) { if (["function", "object"].includes (typeof description) && ! this.context.description && ["context", "format"].includes (description.name)) this.context.description = description; else if (arguments.length > 1 && this.context.description) return this.var.description = this.context.description (description, context); else if (Object.is.set (description)) this.var.description = description; return this.var.description; }
|
|
840
839
|
error (error) { if (error) this.var.error = error; return this.var.error; }
|
|
841
840
|
get (key) { return this.var [key]; }
|
|
842
841
|
set (key, value) {
|
|
@@ -1039,6 +1038,182 @@ Define (Function.html, "markup", class {
|
|
|
1039
1038
|
}
|
|
1040
1039
|
});
|
|
1041
1040
|
|
|
1041
|
+
/**
|
|
1042
|
+
* sitemap
|
|
1043
|
+
*
|
|
1044
|
+
* title
|
|
1045
|
+
* description
|
|
1046
|
+
* sub description
|
|
1047
|
+
*
|
|
1048
|
+
* xxx://xxx.xxx.xxx/xxx
|
|
1049
|
+
*/
|
|
1050
|
+
|
|
1051
|
+
Define (Function, "sitemap", function () {});
|
|
1052
|
+
Define (Function.sitemap, "index", function (data, style) {
|
|
1053
|
+
var sitemap = [`<?xml version="1.0" encoding="UTF-8"?>`];
|
|
1054
|
+
if (style) sitemap.push (`<?xml-stylesheet type="text/xsl" href="${style}"?>`);
|
|
1055
|
+
sitemap.push (`<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">`);
|
|
1056
|
+
for (var i in data) {
|
|
1057
|
+
sitemap.push (("\t").repeat (1) + `<sitemap>`);
|
|
1058
|
+
sitemap.push (("\t").repeat (2) + `<loc>${data [i].url}</loc>`);
|
|
1059
|
+
sitemap.push (("\t").repeat (2) + `<lastmod>${data [i].date.modified}</lastmod>`);
|
|
1060
|
+
sitemap.push (("\t").repeat (1) + `</sitemap>`);
|
|
1061
|
+
}
|
|
1062
|
+
sitemap.push (`</sitemapindex>`);
|
|
1063
|
+
return sitemap.join ("\n");
|
|
1064
|
+
});
|
|
1065
|
+
|
|
1066
|
+
Define (Function, "sitemap.xsl", `<?xml version="1.0" encoding="UTF-8"?>
|
|
1067
|
+
<xsl:stylesheet version="2.0" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
|
1068
|
+
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
|
1069
|
+
<xsl:template match="/">
|
|
1070
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
1071
|
+
<head>
|
|
1072
|
+
<title>XML Sitemap</title>
|
|
1073
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
1074
|
+
<style type="text/css">
|
|
1075
|
+
body { font: 14px "Open Sans", Helvetica, Arial, sans-serif; margin: 0; }
|
|
1076
|
+
a { color: #3498db; text-decoration: none; }
|
|
1077
|
+
h1 { margin: 0; }
|
|
1078
|
+
#description { background-color: #f0f2eb; color: #000; padding: 30px 30px 20px; }
|
|
1079
|
+
#description a { color: #008710; }
|
|
1080
|
+
#content { padding: 10px 30px 30px; background: #fff; }
|
|
1081
|
+
a:hover { border-bottom: 1px solid; }
|
|
1082
|
+
th, td { font-size: 12px; }
|
|
1083
|
+
th { text-align: left; border-bottom: 1px solid #ccc; }
|
|
1084
|
+
th, td { padding: 10px 15px; }
|
|
1085
|
+
.odd { background: linear-gradient(159.87deg, #f6f6f4 7.24%, #f7f4ea 64.73%, #ddedd5 116.53%); }
|
|
1086
|
+
#footer { margin: 20px 30px; font-size: 12px; color: #999; }
|
|
1087
|
+
#footer a { color: inherit; }
|
|
1088
|
+
#description a, #footer a { border-bottom: 1px solid; }
|
|
1089
|
+
#description a:hover, #footer a:hover { border-bottom: none; }
|
|
1090
|
+
img { max-height: 100px; max-width: 100px; }
|
|
1091
|
+
</style>
|
|
1092
|
+
</head>
|
|
1093
|
+
<body>
|
|
1094
|
+
<div id="description">
|
|
1095
|
+
<h1>XML Sitemap</h1>
|
|
1096
|
+
<p>This is an XML Sitemap generated by <a href="{{ url }}">{{ name }}</a>, meant to be consumed by search engines like <a href="https://www.google.com">Google</a> or <a href="https://www.bing.com">Bing</a>.</p>
|
|
1097
|
+
<p>You can find more information on XML sitemaps at <a href="https://sitemaps.org">sitemaps.org</a></p>
|
|
1098
|
+
</div>
|
|
1099
|
+
<div id="content">
|
|
1100
|
+
<table>
|
|
1101
|
+
<tr>
|
|
1102
|
+
<th>#</th>
|
|
1103
|
+
<th>URL</th>
|
|
1104
|
+
<th>Last Modified</th>
|
|
1105
|
+
</tr>
|
|
1106
|
+
<xsl:for-each select="sitemap:urlset/sitemap:url">
|
|
1107
|
+
<tr>
|
|
1108
|
+
<xsl:choose>
|
|
1109
|
+
<xsl:when test="position() mod 2 != 1">
|
|
1110
|
+
<xsl:attribute name="class">odd</xsl:attribute>
|
|
1111
|
+
</xsl:when>
|
|
1112
|
+
</xsl:choose>
|
|
1113
|
+
<td>
|
|
1114
|
+
<xsl:value-of select = "position()"/>
|
|
1115
|
+
</td>
|
|
1116
|
+
<td>
|
|
1117
|
+
<xsl:variable name="itemURL">
|
|
1118
|
+
<xsl:value-of select="sitemap:loc"/>
|
|
1119
|
+
</xsl:variable>
|
|
1120
|
+
<a href="{$itemURL}">
|
|
1121
|
+
<xsl:value-of select="sitemap:loc"/>
|
|
1122
|
+
</a>
|
|
1123
|
+
</td>
|
|
1124
|
+
<td>
|
|
1125
|
+
<xsl:value-of select="sitemap:lastmod"/>
|
|
1126
|
+
</td>
|
|
1127
|
+
</tr>
|
|
1128
|
+
</xsl:for-each>
|
|
1129
|
+
</table>
|
|
1130
|
+
</div>
|
|
1131
|
+
<div id="footer">
|
|
1132
|
+
<p>Generated by <a href="{{ url }}">{{ name }} for {{ alternate:name }}</a></p>
|
|
1133
|
+
</div>
|
|
1134
|
+
</body>
|
|
1135
|
+
</html>
|
|
1136
|
+
</xsl:template>
|
|
1137
|
+
</xsl:stylesheet>`);
|
|
1138
|
+
|
|
1139
|
+
Define (Function, "sitemap.xsl:index", `<?xml version="1.0" encoding="UTF-8"?>
|
|
1140
|
+
<xsl:stylesheet version="2.0" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
|
1141
|
+
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
|
|
1142
|
+
<xsl:template match="/">
|
|
1143
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
1144
|
+
<head>
|
|
1145
|
+
<title>XML Sitemap Index</title>
|
|
1146
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
1147
|
+
<style type="text/css">
|
|
1148
|
+
body { font: 14px "Open Sans", Helvetica, Arial, sans-serif; margin: 0; }
|
|
1149
|
+
a { color: #3498db; text-decoration: none; }
|
|
1150
|
+
h1 { margin: 0; }
|
|
1151
|
+
#description { background-color: #f0f2eb; color: #000; padding: 30px 30px 20px; }
|
|
1152
|
+
#description a { color: #008710; }
|
|
1153
|
+
#content { padding: 10px 30px 30px; background: #fff; }
|
|
1154
|
+
a:hover { border-bottom: 1px solid; }
|
|
1155
|
+
th, td { font-size: 12px; }
|
|
1156
|
+
th { text-align: left; border-bottom: 1px solid #ccc; }
|
|
1157
|
+
th, td { padding: 10px 15px; }
|
|
1158
|
+
.odd { background: linear-gradient(159.87deg, #f6f6f4 7.24%, #f7f4ea 64.73%, #ddedd5 116.53%); }
|
|
1159
|
+
#footer { margin: 20px 30px; font-size: 12px; color: #999; }
|
|
1160
|
+
#footer a { color: inherit; }
|
|
1161
|
+
#description a, #footer a { border-bottom: 1px solid; }
|
|
1162
|
+
#description a:hover, #footer a:hover { border-bottom: none; }
|
|
1163
|
+
img { max-height: 100px; max-width: 100px; }
|
|
1164
|
+
</style>
|
|
1165
|
+
</head>
|
|
1166
|
+
<body>
|
|
1167
|
+
<div id="description">
|
|
1168
|
+
<h1>XML Sitemap Index</h1>
|
|
1169
|
+
<xsl:choose>
|
|
1170
|
+
<xsl:when test="not(sitemap:sitemapindex/sitemap:sitemap)">
|
|
1171
|
+
<p><strong></strong></p>
|
|
1172
|
+
</xsl:when>
|
|
1173
|
+
</xsl:choose>
|
|
1174
|
+
<p>This is an XML Sitemap Index generated by <a href="{{ url }}">{{ name }}</a>, meant to be consumed by search engines like <a href="https://www.google.com">Google</a> or <a href="https://www.bing.com">Bing</a>.</p>
|
|
1175
|
+
<p>You can find more information on XML sitemaps at <a href="https://sitemaps.org">sitemaps.org</a></p>
|
|
1176
|
+
</div>
|
|
1177
|
+
<div id="content">
|
|
1178
|
+
<table>
|
|
1179
|
+
<tr>
|
|
1180
|
+
<th>#</th>
|
|
1181
|
+
<th>Sitemap URL</th>
|
|
1182
|
+
<th>Last Modified</th>
|
|
1183
|
+
</tr>
|
|
1184
|
+
<xsl:for-each select="sitemap:sitemapindex/sitemap:sitemap">
|
|
1185
|
+
<tr>
|
|
1186
|
+
<xsl:choose>
|
|
1187
|
+
<xsl:when test="position() mod 2 != 1">
|
|
1188
|
+
<xsl:attribute name="class">odd</xsl:attribute>
|
|
1189
|
+
</xsl:when>
|
|
1190
|
+
</xsl:choose>
|
|
1191
|
+
<td>
|
|
1192
|
+
<xsl:value-of select = "position()"/>
|
|
1193
|
+
</td>
|
|
1194
|
+
<td>
|
|
1195
|
+
<xsl:variable name="itemURL">
|
|
1196
|
+
<xsl:value-of select="sitemap:loc"/>
|
|
1197
|
+
</xsl:variable>
|
|
1198
|
+
<a href="{$itemURL}">
|
|
1199
|
+
<xsl:value-of select="sitemap:loc"/>
|
|
1200
|
+
</a>
|
|
1201
|
+
</td>
|
|
1202
|
+
<td>
|
|
1203
|
+
<xsl:value-of select="sitemap:lastmod"/>
|
|
1204
|
+
</td>
|
|
1205
|
+
</tr>
|
|
1206
|
+
</xsl:for-each>
|
|
1207
|
+
</table>
|
|
1208
|
+
</div>
|
|
1209
|
+
<div id="footer">
|
|
1210
|
+
<p>Generated by <a href="{{ url }}">{{ name }} for {{ alternate:name }}</a></p>
|
|
1211
|
+
</div>
|
|
1212
|
+
</body>
|
|
1213
|
+
</html>
|
|
1214
|
+
</xsl:template>
|
|
1215
|
+
</xsl:stylesheet>`);
|
|
1216
|
+
|
|
1042
1217
|
/**
|
|
1043
1218
|
* 3rd party
|
|
1044
1219
|
*
|
|
@@ -1460,7 +1635,7 @@ Symbol.export = {
|
|
|
1460
1635
|
define: Object.define, un_define: Object.un_define, un_set: Object.un_set,
|
|
1461
1636
|
object: Object, array: Array, string: String, number: Number, function: Function,
|
|
1462
1637
|
date: Date, time: Date.time, timeout: Date.timeout, datetime: new Date.io,
|
|
1463
|
-
event: Event, promise: Promise,
|
|
1638
|
+
event: Event, promise: Promise, resolve: function () { return Promise.resolve (... arguments); }, reject: function () { return Promise.reject (... arguments); },
|
|
1464
1639
|
url: URL, path: Function.path, file: Function.file, dir: Function.dir, http: Function.http,
|
|
1465
1640
|
db: Function.db, database: Function.database,
|
|
1466
1641
|
cookie: Function.cookie, session: Function.session, ls: Function.ls,
|
|
@@ -1474,7 +1649,8 @@ Symbol.export = {
|
|
|
1474
1649
|
body: Function.body,
|
|
1475
1650
|
owl: Function.owl,
|
|
1476
1651
|
is: Object.is, parse_url: URL.parse,
|
|
1477
|
-
asset: Function.asset, theme: Function.theme,
|
|
1652
|
+
asset: Function.asset, theme: Function.theme, template: Function.template,
|
|
1653
|
+
sitemap: Function.sitemap, "sitemap.xsl": Function ["sitemap.xsl"], "sitemap.xsl:index": Function ["sitemap.xsl:index"],
|
|
1478
1654
|
zero: 0, one: 1,
|
|
1479
1655
|
}
|
|
1480
1656
|
|