diff --git a/a4.nimble b/a4.nimble index 958127e..7917590 100644 --- a/a4.nimble +++ b/a4.nimble @@ -1,7 +1,7 @@ # Package -version = "0.1.0" -author = "cereci5049" +version = "0.1.1" +author = "fitel22348-molyg" description = "School Management System" license = "GPL-2.0-or-later" srcDir = "src" @@ -11,3 +11,6 @@ bin = @["a4"] # Dependencies requires "nim >= 2.0.2" +requires "https://github.com/ire4ever1190/mike" +requires "db_connector" +requires "nimja" diff --git a/db5.sqlite3 b/db5.sqlite3 new file mode 100644 index 0000000..345c9c8 Binary files /dev/null and b/db5.sqlite3 differ diff --git a/src/a4 b/src/a4 new file mode 100755 index 0000000..57c9138 Binary files /dev/null and b/src/a4 differ diff --git a/src/a4.nim b/src/a4.nim index e69de29..7ce370a 100644 --- a/src/a4.nim +++ b/src/a4.nim @@ -0,0 +1,16 @@ +import + mike, + segfaults, + ./controllers/[student, faculty, index] + +"/" -> get: ctx.index() + +"/studentattendence" -> get: ctx.studentAttendance() + +"/faculty" -> get: ctx.faculty() + +"/faculty/login" -> get: ctx.facultyLogin() + +servePublic("src/public", "/static") + +run() \ No newline at end of file diff --git a/src/controllers/faculty.nim b/src/controllers/faculty.nim new file mode 100644 index 0000000..e85a84f --- /dev/null +++ b/src/controllers/faculty.nim @@ -0,0 +1,23 @@ +import + mike, + nimja/parser, + segfaults + +proc faculty*(ctx: Context): string = + compileTemplateFile(getScriptDir() / "view" / "faculty_admin.html") + +proc facultyLogin*(ctx: Context): string = + compileTemplateFile(getScriptDir() / "view" / "faculty_login.html") + +proc facultySignUp*(ctx: Context): string = + compileTemplateFile(getScriptDir() / "view" / "faculty_signup.html") + +proc postFacultyLogin*(ctx: Context)= + var + form = ctx.urlForm + + username = form["username"] + password = form["password"] + + ctx &= initCookie("username", username) + ctx &= initCookie("password", password) diff --git a/src/controllers/index.nim b/src/controllers/index.nim new file mode 100644 index 0000000..2113a50 --- /dev/null +++ b/src/controllers/index.nim @@ -0,0 +1,7 @@ +import + mike, + nimja/parser, + segfaults + +proc index*(ctx: Context): string = + compileTemplateFile(getScriptDir() / "view" / "index.html") \ No newline at end of file diff --git a/src/controllers/student.nim b/src/controllers/student.nim new file mode 100644 index 0000000..f3fe197 --- /dev/null +++ b/src/controllers/student.nim @@ -0,0 +1,7 @@ +import + mike, + nimja/parser, + segfaults + +proc studentAttendance*(ctx: Context): string = + compileTemplateFile(getScriptDir() / "view" / "student_attendance.html") \ No newline at end of file diff --git a/src/database/db_up b/src/database/db_up new file mode 100755 index 0000000..c9d8f66 Binary files /dev/null and b/src/database/db_up differ diff --git a/src/database/db_up.nim b/src/database/db_up.nim new file mode 100644 index 0000000..8dd3492 --- /dev/null +++ b/src/database/db_up.nim @@ -0,0 +1,7 @@ +import + ./faculty, + ../lib/mics + +var db = newDatabase() + +db.setUpFaculty() diff --git a/src/database/faculty.nim b/src/database/faculty.nim new file mode 100644 index 0000000..726f8d9 --- /dev/null +++ b/src/database/faculty.nim @@ -0,0 +1,22 @@ +import + db_connector/db_sqlite, + strutils, + ../models/models + +proc close*(db: DbConn)= + db.close() + +proc setUpFaculty*(db: DbConn) = + ## setupOrders creates the orders table if it does not exist + db.exec(sql""" + CREATE TABLE IF NOT EXISTS orders ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + first_name VARCHAR(255) NOT NULL, + last_name VARCHAR(255) NOT NULL, + user_name VARCHAR(255) NOT NULL, + password VARCHAR(255) NOT NULL, + created_at TEXT DEFAULT CURRENT_TIMESTAMP NOT NULL, + updated_at TEXT DEFAULT CURRENT_TIMESTAMP NOT NULL, + access_level VARCHAR(255) NOT NULL + ); + """) diff --git a/src/lib/mics.nim b/src/lib/mics.nim new file mode 100644 index 0000000..149db47 --- /dev/null +++ b/src/lib/mics.nim @@ -0,0 +1,6 @@ +import + db_connector/db_sqlite, + ../models/models + +proc newDatabase*(filename = "db5.sqlite3"): DbConn = + result = open(filename, "", "", "") diff --git a/src/models/models.nim b/src/models/models.nim new file mode 100644 index 0000000..8aef2f8 --- /dev/null +++ b/src/models/models.nim @@ -0,0 +1,19 @@ +type + Faculty* = object + id*: int + firstName*: string + lastName*: string + userName*: string + password*: string + createdAt*: string + updatedAt*: string + accessLevel*: int + + Student* = object + id*: int + firstName*: string + lastName*: string + userName*: string + attendance*: float + createdAt*: string + updatedAt*: string diff --git a/src/public/faculty.jpg b/src/public/faculty.jpg new file mode 100644 index 0000000..bf79494 Binary files /dev/null and b/src/public/faculty.jpg differ diff --git a/src/public/index_styles.css b/src/public/index_styles.css new file mode 100644 index 0000000..4f2103b --- /dev/null +++ b/src/public/index_styles.css @@ -0,0 +1,76 @@ +body { + font-family: Arial, sans-serif; + margin: 0; + padding: 0; + background-color: #f4f4f4; +} + +header { + background-color: #333; + color: white; + padding: 10px; + display: flex; + justify-content: space-between; + align-items: center; +} + +header h1 { + margin: 0; +} + +header nav ul { + list-style: none; + margin: 0; + padding: 0; + display: flex; +} + +header nav li { + margin-left: 10px; +} + +header nav a { + color: white; + text-decoration: none; +} + +main { + max-width: 1000px; + margin: 0 auto; + padding: 20px; +} + +.hero { + text-align: center; + padding: 40px; + background-color: #007bff; + color: white; +} + +.features { + display: flex; + justify-content: space-around; + padding: 20px; + background-color: #fff; +} + +.feature { + text-align: center; + flex: 1; +} + +.feature img { + max-width: 150px; +} + +.about { + padding: 20px; + background-color: #f9f9f9; +} + +footer { + text-align: center; + background-color: #333; + color: white; + padding: 10px; +} \ No newline at end of file diff --git a/src/public/student.jpg b/src/public/student.jpg new file mode 100644 index 0000000..8e30a03 Binary files /dev/null and b/src/public/student.jpg differ diff --git a/src/static/styles.css b/src/public/styles.css similarity index 100% rename from src/static/styles.css rename to src/public/styles.css diff --git a/src/view/faculty_admin.html b/src/view/faculty_admin.html index 5c34a02..1867815 100644 --- a/src/view/faculty_admin.html +++ b/src/view/faculty_admin.html @@ -3,7 +3,7 @@
- +