forked from ITwrxOrg/Forget-Me-Not
update copyright and clean up comments
This commit is contained in:
@@ -1,16 +1,14 @@
|
||||
#[Copyright 2025 ITwrx.
|
||||
This file is part of Simple Site Manager.
|
||||
Simple Site Manager is released under the GNU Affero General Public License 3.0.
|
||||
This file is part of Forget-Me-Not.
|
||||
Forget-Me-Not is released under the GNU Affero General Public License 3.0.
|
||||
See COPYING or <https://www.gnu.org/licenses/> for details.]#
|
||||
|
||||
#TODO: remove code not being used in this application. Some of this is only needed in Simple Site Manager.
|
||||
|
||||
import std/[cgi, strtabs, cookies, sysrand, base64]
|
||||
import guildenstern/[httpserver], sqliteral
|
||||
import "../models/session", "db", "global"
|
||||
|
||||
#[type
|
||||
Session* = object
|
||||
sessionId*, csrfToken*: string
|
||||
id*, userId*: int]#
|
||||
type
|
||||
User* = object
|
||||
email*, password*: string
|
||||
@@ -54,9 +52,6 @@ proc setVisitorCsrfToken*(): string =
|
||||
#create csrf token.
|
||||
var csrfToken = $urandom(32)
|
||||
csrfToken = base64.encode(csrfToken)
|
||||
#delete old VisitorSessions, as they are just the one time use CSRF Tokens.
|
||||
#may need to be redesigned for better multiuser robustness if it's deleting other users' unused tokens.
|
||||
#deleteVisitorSessions()
|
||||
#create session in db.
|
||||
var visitorSession: Session
|
||||
visitorSession.csrfToken = csrfToken
|
||||
@@ -77,12 +72,6 @@ proc newCsrfToken*(): string =
|
||||
var csrfToken = $urandom(32)
|
||||
csrfToken = base64.encode(csrfToken)
|
||||
return csrfToken
|
||||
|
||||
#[proc fCsrfToken*(): string =
|
||||
{.gcsafe.}:
|
||||
let sessionId = getSessionIdFromCookies()
|
||||
let userSession = getUserSessionBySessionId(sessionId)
|
||||
result = userSession.csrfToken]#
|
||||
|
||||
proc isValidVisitorCsrfToken*(csrfToken: string): bool =
|
||||
#our previoulsy self-generated, valid csrfToken from the DB.
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
#[Copyright 2025 ITwrx.
|
||||
This file is part of Forget-Me-Not.
|
||||
Forget-Me-Not is released under the GNU Affero General Public License 3.0.
|
||||
See COPYING or <https://www.gnu.org/licenses/> for details.]#
|
||||
|
||||
import std/[times, strutils]
|
||||
|
||||
proc weekdayFromString(dayStr: string): Weekday =
|
||||
@@ -41,7 +46,6 @@ proc nextWeekday*(targetWeekdayString: string): DateTime =
|
||||
|
||||
proc nthWeekdayInMonth*(year: int, month: Month, weekdayString: string, nth: range[1..3]): DateTime =
|
||||
# Start from the first day of the month
|
||||
#var currentDate = dateTime(year, month, 1, 0, 0, 0, 0)
|
||||
var currentDate = dateTime(year, month, 1)
|
||||
let weekday = weekdayFromString(weekdayString)
|
||||
# Find the first occurrence of the specified weekday
|
||||
@@ -53,7 +57,6 @@ proc nthWeekdayInMonth*(year: int, month: Month, weekdayString: string, nth: ran
|
||||
|
||||
proc lastWeekdayInMonth(year: int, month: Month, weekdayString: string): DateTime =
|
||||
# Create a DateTime for the last day of the given month
|
||||
#var lastDay = dateTime(year, month, getDaysInMonth(month, year), 0, 0, 0, 0)
|
||||
var lastDay = dateTime(year, month, getDaysInMonth(month, year))
|
||||
let weekday = weekdayFromString(weekdayString)
|
||||
# Work backwards until we find the last occurrence of the specified weekday
|
||||
@@ -100,53 +103,19 @@ proc nextYearlyOnWeekdayOfWeekOfMonth*(weekdayString, ocurrence, monthString: st
|
||||
nextSendDate = lastWeekdayInMonth(year(startingDate), month(startingDate), weekdayString)
|
||||
return nextSendDate
|
||||
|
||||
#[proc nextYearDate*(monthString: string, day: int): DateTime =
|
||||
## Aalways returns a date in the next year,
|
||||
## regardless of whether the target date has passed in the current year
|
||||
#var nextSendDate = dateTime(year(now()) + 1, monthFromString(monthString), day, 0, 0, 0, 0)
|
||||
#var nextSendDate = dateTime(year(now()) + 1, monthFromString(monthString), day)
|
||||
#let nextSendDateString =
|
||||
#echo nextSendDate
|
||||
#return parse($nextSendDate, "yyyy-MM-dd")
|
||||
var
|
||||
let nextYear = year(now()) + 1
|
||||
let dt = dateTime(nextYear, monthFromString(monthString), day, 00, 00, 00, 00)
|
||||
#echo dt
|
||||
let nextSendDateString = format(dt, "yyyy-MM-dd")
|
||||
#echo nextSendDateString
|
||||
#let nextSendDateString = $nextYear & "-" & formattedMonthString & "-" & $day
|
||||
let nextSendDate = parse(nextSendDateString, "yyyy-MM-dd")
|
||||
#echo nextSendDateString
|
||||
return nextSendDate]#
|
||||
|
||||
proc nextYearlyDate*(monthString: string, targetDay: int): DateTime =
|
||||
## Calculates a date for the next occurrence of a specific month and day
|
||||
##
|
||||
## Parameters:
|
||||
## - baseDate: The starting date to calculate from
|
||||
## - targetMonth: The month (Month enum) for the target date
|
||||
## - targetDay: The day of month for the target date
|
||||
##
|
||||
## Returns the next occurrence of the specified month and day, which could be:
|
||||
## - Later this year if the target date hasn't occurred yet
|
||||
## - Next year if the target date has already passed this year
|
||||
|
||||
#[ Returns the next occurrence of the specified month and day, which could be:
|
||||
- Later this year if the target date hasn't occurred yet
|
||||
- Next year if the target date has already passed this year]#
|
||||
proc nextYearlyDate*(monthString: string, targetDay: int): DateTime =
|
||||
let baseDate = now()
|
||||
let targetMonth = monthFromString(monthString)
|
||||
|
||||
let targetMonth = monthFromString(monthString)
|
||||
# Get the current year
|
||||
let currentYear = baseDate.year
|
||||
|
||||
let currentYear = baseDate.year
|
||||
# Create a DateTime for the target date in the current year
|
||||
var nextSendDate = dateTime(currentYear, targetMonth, targetDay, 00, 00, 00, 00)
|
||||
|
||||
var nextSendDate = dateTime(currentYear, targetMonth, targetDay, 00, 00, 00, 00)
|
||||
# If the target date has already passed this year, move to next year
|
||||
if nextSendDate <= baseDate:
|
||||
nextSendDate = dateTime(currentYear + 1, targetMonth, targetDay, 00, 00, 00, 00)
|
||||
|
||||
nextSendDate = dateTime(currentYear + 1, targetMonth, targetDay, 00, 00, 00, 00)
|
||||
let nextSendDateString = format(nextSendDate, "yyyy-MM-dd")
|
||||
#echo nextSendDateString
|
||||
#let nextSendDateString = $nextYear & "-" & formattedMonthString & "-" & $day
|
||||
nextSendDate = parse(nextSendDateString, "yyyy-MM-dd")
|
||||
|
||||
nextSendDate = parse(nextSendDateString, "yyyy-MM-dd")
|
||||
return nextSendDate
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#[Copyright 2024 ITwrx.
|
||||
This file is part of Simple Site Manager.
|
||||
Simple Site Manager is released under the GNU Affero General Public License 3.0.
|
||||
This file is part of Forget-Me-Not.
|
||||
Forget-Me-Not is released under the GNU Affero General Public License 3.0.
|
||||
See COPYING or <https://www.gnu.org/licenses/> for details.]#
|
||||
|
||||
import sqliteral
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#[Copyright 2025 ITwrx.
|
||||
This file is part of Simple Site Manager.
|
||||
Simple Site Manager is released under the GNU Affero General Public License 3.0.
|
||||
This file is part of Forget-Me-Not.
|
||||
Forget-Me-Not is released under the GNU Affero General Public License 3.0.
|
||||
See COPYING or <https://www.gnu.org/licenses/> for details.]#
|
||||
|
||||
#TODO: remove anything not being used by Forget-Me-Not.
|
||||
|
||||
import std/[cgi, strtabs, strutils, cookies, uri, tables]
|
||||
import jsony, guildenstern/httpserver, sqliteral
|
||||
import "auth", "global"
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
#import std/[times, logging]
|
||||
#[Copyright 2025 ITwrx.
|
||||
This file is part of Forget-Me-Not.
|
||||
Forget-Me-Not is released under the GNU Affero General Public License 3.0.
|
||||
See COPYING or <https://www.gnu.org/licenses/> for details.]#
|
||||
|
||||
import std/[times, strutils, re, uri, paths, random, strtabs]
|
||||
|
||||
#universal
|
||||
const APP_PATH* = "/var/www/forget-me-not-gs"
|
||||
const ASSETS_PATH* = "/var/www/forget-me-not-gs/app/assets"
|
||||
const APP_NAME* = "Forget-Me-Not"
|
||||
#set to 'dev' or 'prod'
|
||||
const APP_MODE* = "dev"
|
||||
#dev
|
||||
const APP_URL* = "http://fmn-gs"
|
||||
@@ -17,6 +22,8 @@ const ASSETS_URL* = "http://assets.fmn-gs"
|
||||
|
||||
var frStrTab* = newStringTable()
|
||||
|
||||
#TODO: implement logging or remove logging code.
|
||||
|
||||
#Guildensterns logger is conflicting with my, evidently incorrect, usage of the std lib logger so i'll just write some lines to a file for now.
|
||||
#var logger* = newFileLogger("errors.log")
|
||||
|
||||
@@ -29,7 +36,6 @@ proc writeLogLine*(errorMsg: string) =
|
||||
defer: logFile.close()
|
||||
logFile.writeLine(errorMsg)
|
||||
|
||||
#template location*(slug: string, csrfToken: string, fr: FormResult): untyped =
|
||||
template location*(slug: string): untyped =
|
||||
"location: " & APP_URL & slug
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
#[Copyright 2025 ITwrx.
|
||||
This file is part of Forget-Me-Not.
|
||||
Forget-Me-Not is released under the GNU Affero General Public License 3.0.
|
||||
See COPYING or <https://www.gnu.org/licenses/> for details.]#
|
||||
|
||||
import std/[times, osproc], smtp
|
||||
import ../models/reminder, ../models/user, datetime
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#[Copyright 2024 ITwrx.
|
||||
This file is part of ITwrxorg-SiteUpdata.
|
||||
ITwrxorg-SiteUpdata is released under the GNU Affero General Public License 3.0.
|
||||
#[Copyright 2025 ITwrx.
|
||||
This file is part of Forget-Me-Not.
|
||||
Forget-Me-Not is released under the GNU Affero General Public License 3.0.
|
||||
See COPYING or <https://www.gnu.org/licenses/> for details.]#
|
||||
|
||||
import std/[strutils, re, typetraits, times, tables]
|
||||
|
||||
Reference in New Issue
Block a user