Misc

Commit
5c054a561a07da8a75a539d2542bde1b1c2ae072
Author
Marius Peter <marius.peter@tutanota.com>
Author date
Committer
Marius Peter <marius.peter@tutanota.com>
Committer date
Changed files
src/MyFitnessTracker/MFTDatabase.class.st
index c6d809fa..00000000 100644..000000
@@ -1,52 +0,0 @@
1 Removed: Class {
2 Removed: #name : #MFTDatabase,
3 Removed: #superclass : #Object,
4 Removed: #instVars : [
5 Removed: 'connection'
6 Removed: ],
7 Removed: #classInstVars : [
8 Removed: 'connection'
9 Removed: ],
10 Removed: #category : #'MyFitnessTracker-Model'
11 Removed: }
12 Removed:
13 Removed: { #category : #'as yet unclassified' }
14 Removed: MFTDatabase class >> checkCredentialsForUsername: aUsername password: aPassword [
15 Removed:
16 Removed: | statement |
17 Removed: connection execute: 'CREATE TABLE IF NOT EXISTS user(
18 Removed: id INTEGER PRIMARY KEY AUTOINCREMENT,
19 Removed: username TEXT NOT NULL,
20 Removed: password TEXT NOT NULL,
21 Removed: );'
22 Removed: ]
23 Removed:
24 Removed: { #category : #'instance creation' }
25 Removed: MFTDatabase class >> newConnectionToSQLite3 [
26 Removed:
27 Removed: connection := SQLite3Connection on:
28 Removed: (Smalltalk imageDirectory / 'mft.db') fullName.
29 Removed: connection open
30 Removed: "TODO: MFTRoot is responsible for opening the connection?"
31 Removed: "^ self new
32 Removed: connection: connection;
33 Removed: yourself"
34 Removed: ]
35 Removed:
36 Removed: { #category : #accessing }
37 Removed: MFTDatabase >> connection [
38 Removed:
39 Removed: ^ connection
40 Removed: ]
41 Removed:
42 Removed: { #category : #accessing }
43 Removed: MFTDatabase >> connection: anObject [
44 Removed:
45 Removed: connection := anObject
46 Removed: ]
47 Removed:
48 Removed: { #category : #initialization }
49 Removed: MFTDatabase >> initialize [
50 Removed:
51 Removed: super initialize
52 Removed: ]
src/MyFitnessTracker/MFTDescriptorSystem.class.st
index 0b0d8817..00000000 100644..000000
@@ -1,58 +0,0 @@
1 Removed: Class {
2 Removed: #name : #MFTDescriptorSystem,
3 Removed: #superclass : #DescriptorSystem,
4 Removed: #category : #'MyFitnessTracker-Model'
5 Removed: }
6 Removed:
7 Removed: { #category : #accessing }
8 Removed: MFTDescriptorSystem >> allTableNames [
9 Removed: "Return a list of all the table names that this system uses."
10 Removed:
11 Removed: ^ #( 'Users' )
12 Removed: ]
13 Removed:
14 Removed: { #category : #'class membership' }
15 Removed: MFTDescriptorSystem >> classModelForUser: aClassModel [
16 Removed:
17 Removed: aClassModel newAttributeNamed: #id.
18 Removed: aClassModel newAttributeNamed: #username.
19 Removed: aClassModel newAttributeNamed: #passwordHash.
20 Removed: aClassModel newAttributeNamed: #dateOfBirth.
21 Removed: aClassModel newAttributeNamed: #realFirstName.
22 Removed: aClassModel newAttributeNamed: #realLastName
23 Removed: ]
24 Removed:
25 Removed: { #category : #'as yet unclassified' }
26 Removed: MFTDescriptorSystem >> descriptorForUser: aDescriptor [
27 Removed:
28 Removed: | table |
29 Removed: table := self tableNamed: 'User'.
30 Removed: aDescriptor table: table.
31 Removed: aDescriptor directMappingFor: #id.
32 Removed: (aDescriptor newMapping: DirectMapping)
33 Removed: from: #username
34 Removed: to: (table fieldNamed: 'username').
35 Removed: (aDescriptor newMapping: DirectMapping)
36 Removed: from: #passwordHash
37 Removed: to: (table fieldNamed: 'passwordHash').
38 Removed: (aDescriptor newMapping: DirectMapping)
39 Removed: from: #firstName
40 Removed: to: (table fieldNamed: 'firstName').
41 Removed: (aDescriptor newMapping: DirectMapping)
42 Removed: from: #lastName
43 Removed: to: (table fieldNamed: 'lastName').
44 Removed: (aDescriptor newMapping: DirectMapping)
45 Removed: from: #dateOfBirth
46 Removed: to: (table fieldNamed: 'dateOfBirth')
47 Removed: ]
48 Removed:
49 Removed: { #category : #tables }
50 Removed: MFTDescriptorSystem >> tableForUser: aTable [
51 Removed:
52 Removed: (aTable createFieldNamed: 'id' type: platform serial) bePrimaryKey.
53 Removed: aTable createFieldNamed: 'username' type: (platform varChar: 20).
54 Removed: aTable createFieldNamed: 'passwordHash' type: (platform varChar: 100).
55 Removed: aTable createFieldNamed: 'realFirstName' type: (platform varChar: 20).
56 Removed: aTable createFieldNamed: 'realLastName' type: (platform varChar: 20).
57 Removed: aTable createFieldNamed: 'dateOfBirth' type: platform date
58 Removed: ]
src/MyFitnessTracker/MFTHeaderComponent.class.st
index fc87dd03..7fb719bf 100644..100644
@@ -19,12 +19,14 @@
19 19 (emailToCheck isNil or: [ (emailPattern matches: emailToCheck) not ])
20 20 ifTrue: [ ^ nil ].
21 21 email := emailToCheck.
22 Removed: self storeEmail: emailToCheck
22 Added: MFTSQLite3Database storeProspectEmail: email
23 23 ]
24 24
25 25 { #category : #rendering }
26 26 MFTHeaderComponent >> renderContentOn: html [
27 27
28 Added: self session user isLoggedIn ifTrue: [ "If a user is logged in, the CTA banner is not displayed."
29 Added: ^ nil ].
28 30 email
29 31 ifNil: [
30 32 html alert
@@ -40,12 +42,12 @@
40 42 'My Fitness Tracker is still under heavy development, with improvements being made daily.';
41 43 space;
42 44 text: 'I can''t wait to share the finished product with you!' ].
43 Removed: html
44 Removed: strong: 'Want to know when version 1.0 is out?';
45 Removed: break.
46 Removed: html form: [
45 Added: html form with: [
46 Added: html label
47 Added: style: 'margin-right: 1em';
48 Added: with: [ html strong: 'Want to know when version 1.0 is out?' ].
47 49 html formButton
48 Removed: bePrimary;
50 Added: beInfo;
49 51 callback: [ self addUserEmail ];
50 52 with: 'E-mail me!' ] ] ]
51 53 ifNotNil: [
@@ -106,13 +108,4 @@
106 108 beSubmit;
107 109 callback: [ email := localPart , '@' , domain ];
108 110 with: 'Confirm' ] ] ] ] ]
109 Removed: ]
110 Removed:
111 Removed: { #category : #'as yet unclassified' }
112 Removed: MFTHeaderComponent >> storeEmail: anEmail [
113 Removed:
114 Removed: self session dbConnection
115 Removed: execute: 'INSERT INTO prospects(email,date_time) VALUES (?, ?);'
116 Removed: value: anEmail
117 Removed: value: DateAndTime now asUTC rounded asString
118 111 ]
src/MyFitnessTracker/MFTSQLite3Database.class.st
index 00000000..2cdc1e49 000000..100644
@@ -0,0 +1,52 @@
1 Added: Class {
2 Added: #name : #MFTSQLite3Database,
3 Added: #superclass : #SQLite3Database,
4 Added: #category : #'MyFitnessTracker-Model'
5 Added: }
6 Added:
7 Added: { #category : #'as yet unclassified' }
8 Added: MFTSQLite3Database class >> ensureTablesExist [
9 Added:
10 Added: | aMFTDatabase |
11 Added: aMFTDatabase := self new.
12 Added:
13 Added: aMFTDatabase connection execute:
14 Added: 'CREATE TABLE IF NOT EXISTS "prospects" (
15 Added: "id" INTEGER,
16 Added: "email" TEXT NOT NULL,
17 Added: "date_time" TEXT NOT NULL,
18 Added: PRIMARY KEY("id" AUTOINCREMENT)
19 Added: )'.
20 Added: aMFTDatabase connection execute:
21 Added: 'CREATE TABLE IF NOT EXISTS "users" (
22 Added: "id" INTEGER UNIQUE,
23 Added: "username" TEXT,
24 Added: "password_hash" BLOB,
25 Added: "real_first_name" TEXT,
26 Added: "real_last_name" TEXT,
27 Added: "date_of_birth" TEXT,
28 Added: PRIMARY KEY("id" AUTOINCREMENT)
29 Added: )'
30 Added: ]
31 Added:
32 Added: { #category : #'as yet unclassified' }
33 Added: MFTSQLite3Database >> select: attributes from: aTable [
34 Added:
35 Added: ^ connection execute:
36 Added: 'SELECT ' , attributes , ' FROM ' , aTable asString
37 Added: ]
38 Added:
39 Added: { #category : #'as yet unclassified' }
40 Added: MFTSQLite3Database >> selectAll: aTable [
41 Added:
42 Added: ^ self select: '*' from: aTable
43 Added: ]
44 Added:
45 Added: { #category : #setting }
46 Added: MFTSQLite3Database >> storeProspectEmail: anEmail [
47 Added:
48 Added: connection
49 Added: execute: 'INSERT INTO prospects(email,date_time) VALUES (?, ?);'
50 Added: value: anEmail
51 Added: value: DateAndTime now asUTC rounded asString
52 Added: ]
src/MyFitnessTracker/MFTScreenComponent.class.st
index c3513931..66b75b2f 100644..100644
@@ -24,7 +24,7 @@
24 24
25 25 super initialize.
26 26 header := MFTHeaderComponent new.
27 Removed: mainTabs := MFTMainNavigationbarComponent new.
27 Added: mainTabs := MFTMainNavigationBarComponent new.
28 28 footer := MFTFooterComponent new
29 29 ]
30 30