diff --git a/html/apps.ejs b/html/apps.ejs index 2fdf74af..91836077 100644 --- a/html/apps.ejs +++ b/html/apps.ejs @@ -125,10 +125,12 @@ Games - Web Search + Search Translate Maps - PokeTube + Fediverse + Calendar + Watch Settings diff --git a/html/calendar.ejs b/html/calendar.ejs new file mode 100644 index 00000000..d4c48c7f --- /dev/null +++ b/html/calendar.ejs @@ -0,0 +1,188 @@ + + + + + + + + Poke! Calendar + + + + + + + + + + + + +
+

<%= queryDate.toLocaleString('default', { month: 'long' }) %> <%= year %>

+ + + + + + + + + + + + + + + <% for (let i = 0; i < 6; i++) { %> + + <% for (let j = 0; j < 7; j++) { %> + + <% } %> + + <% } %> + +
SundayMondayTuesdayWednesdayThursdayFridaySaturday
+ <% const day = days[i * 7 + j]; %> + <%= day ? day.getDate() : '' %> +
+ + +
+ + diff --git a/html/translate.ejs b/html/translate.ejs index b6200b0d..ab41069c 100644 --- a/html/translate.ejs +++ b/html/translate.ejs @@ -16,23 +16,22 @@ You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/. --> - - + - - PokeTranslate - - - - - - - - - - - - - input:focus, - select:focus, - textarea:focus, - button:focus { - border-color: #478061; - outline: 1px solid #478061; - } - - + <% if (isMobile) { %> + + <% } %> + <% if (!isMobile) { %> + + <% } %> + - #could_not_switch_languages_text { - color: #F13333; - } - - a:visited { - color: #9759f6; - text-decoration: none; - } - - a { - color: #599bf6; - text-decoration: none; - } - - input, - select, - button, - textarea { - background-color: #131618; - border-color: #495057; - color: #f8f9fa; - } - - .def_type { - color: cyan; - text-transform: capitalize; - } - - .syn { - color: burlywood; - } - - .syn_type { - color: cyan; - } - - .use_in_sentence { - color: yellow; - } - - - - <% if (isMobile) { %> - - <% } %> - - <% if (!isMobile) { %> - - <% } %> - - - -
- -

PokeTranslate

- -
- - -
-
- + +
+
+

PokeTranslate

+
+ <% const languageOptions = [ { code: 'autodetect', name: 'Autodetect' }, { code: 'af', name: 'Afrikaans' }, @@ -307,7 +246,7 @@ { code: 'km', name: 'Khmer' }, { code: 'rw', name: 'Kinyarwanda' }, { code: 'kok', name: 'Konkani' }, - { code: 'ko', name: 'Korean' }, + { code: 'ko', name: 'Korean (PROK)' }, { code: 'kri', name: 'Krio' }, { code: 'ku', name: 'Kurdish (Kurmanji)' }, { code: 'sd', name: 'Sindhi' }, @@ -339,93 +278,71 @@ { code: 'yi', name: 'Yiddish' }, { code: 'yo', name: 'Yoruba' }, { code: 'zu', name: 'Zulu' } -]; %> +]; %> + + +
+
+ - - - - - - - - - +
- -
- -
- - + +
- -
+ +
-
-
- - +
- -
- - - -
- - - - -
-
-
+ + + + + + + + - - - - - \ No newline at end of file diff --git a/src/libpoketube/init/pages-channel-and-download.js b/src/libpoketube/init/pages-channel-and-download.js index 19be20dd..2f91a2cf 100644 --- a/src/libpoketube/init/pages-channel-and-download.js +++ b/src/libpoketube/init/pages-channel-and-download.js @@ -88,7 +88,7 @@ module.exports = function (app, config, renderTemplate) { }); app.get("/search", async (req, res) => { - const query = req.query.query.replace("ohio", "things to do in ohio"); + const query = req.query.query ? req.query.query.replace("ohio", "things to do in ohio") : ''; const tab = req.query.tab; const { fetch } = await import("undici"); diff --git a/src/libpoketube/init/pages-static.js b/src/libpoketube/init/pages-static.js index 76ea6a66..6be7abd3 100644 --- a/src/libpoketube/init/pages-static.js +++ b/src/libpoketube/init/pages-static.js @@ -153,6 +153,56 @@ module.exports = function (app, config, renderTemplate) { renderTemplate(res, req, "content-settings.ejs"); }); + + function gregorianToIslamic(gDate) { + const jd = Math.floor((gDate - new Date(1970, 0, 1)) / (24 * 60 * 60 * 1000)) + 2440588; + const islamicYear = Math.floor((30 * (jd - 1948440) + 10646) / 10631); + return islamicYear; +} + + function gregorianToPersian(gDate) { + const persianEpoch = 226895; // Julian Day of Persian Epoch + const jd = Math.floor((gDate - new Date(1970, 0, 1)) / (24 * 60 * 60 * 1000)) + 2440588; + const persianYear = Math.floor((jd - persianEpoch) / 365.2421985) + 1; + return persianYear; +} + +app.get('/calendar', (req, res) => { + // Get the date from query or default to today + const queryDate = req.query.date ? new Date(req.query.date) : new Date(); + + // Extract the year and month from the date + const year = queryDate.getFullYear(); + const month = queryDate.getMonth(); // 0 (January) to 11 (December) + + const monthOffset = parseInt(req.query.month) || 0; + const newDate = new Date(year, month + monthOffset, 1); + const newYear = newDate.getFullYear(); + const newMonth = newDate.getMonth(); + + const firstDay = new Date(newYear, newMonth, 1); + const firstDayWeekday = firstDay.getDay(); // Day of the week (0-6) + + const days = Array.from({ length: 42 }, (_, i) => { + const day = new Date(newYear, newMonth, i - firstDayWeekday + 1); + return (day.getMonth() === newMonth) ? day : null; + }); + + const islamicYear = gregorianToIslamic(newDate); + const persianYear = gregorianToPersian(newDate); + + renderTemplate(res, req, "calendar.ejs", { + year: newYear, + islamicYear, + persianYear, + currentDate: newDate, + days, + month: newMonth, + queryDate, + }); +}); + + app.get("/offline", function (req, res) { res.sendFile("offline.html", { root: location_pwa }); });