Skip to content

Commit 8ba22ff

Browse files
committed
fix dependencies, fix function comments (kabukky/journey#114)
Signed-off-by: Anar Jafarov <[email protected]>
1 parent eeb8744 commit 8ba22ff

39 files changed

+161
-132
lines changed

authentication/password.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package authentication
22

33
import (
4-
"github.com/kabukky/journey/database"
4+
"journey/database"
5+
56
"golang.org/x/crypto/bcrypt"
67
)
78

9+
// LoginIsCorrect verifies if the provided username and password combination is valid.
810
func LoginIsCorrect(name string, password string) bool {
911
hashedPassword, err := database.RetrieveHashedPasswordForUser([]byte(name))
1012
if len(hashedPassword) == 0 || err != nil { // len(hashedPassword) == 0 probably not needed.
@@ -18,6 +20,7 @@ func LoginIsCorrect(name string, password string) bool {
1820
return true
1921
}
2022

23+
// EncryptPassword generates a bcrypt hash from the provided plaintext password.
2124
func EncryptPassword(password string) (string, error) {
2225
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), 10)
2326
if err != nil {

authentication/session.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package authentication
22

33
import (
4-
"github.com/gorilla/securecookie"
54
"net/http"
5+
6+
"github.com/gorilla/securecookie"
67
)
78

89
var cookieHandler = securecookie.New(
910
securecookie.GenerateRandomKey(64),
1011
securecookie.GenerateRandomKey(32))
1112

13+
// SetSession creates a secure session cookie for the authenticated user.
1214
func SetSession(userName string, response http.ResponseWriter) {
1315
value := map[string]string{
1416
"name": userName,
@@ -23,6 +25,7 @@ func SetSession(userName string, response http.ResponseWriter) {
2325
}
2426
}
2527

28+
// GetUserName extracts the username from the session cookie in the request.
2629
func GetUserName(request *http.Request) (userName string) {
2730
if cookie, err := request.Cookie("session"); err == nil {
2831
cookieValue := make(map[string]string)
@@ -33,6 +36,7 @@ func GetUserName(request *http.Request) (userName string) {
3336
return userName
3437
}
3538

39+
// ClearSession removes the session cookie by setting it to expire.
3640
func ClearSession(response http.ResponseWriter) {
3741
cookie := &http.Cookie{
3842
Name: "session",

configuration/configuration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"reflect"
99
"strings"
1010

11-
"github.com/kabukky/journey/filenames"
11+
"journey/filenames"
1212
)
1313

1414
// Configuration: settings that are neccesary for server configuration

database/initialization.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package database
33
import (
44
"database/sql"
55

6-
"github.com/kabukky/journey/database/migration"
7-
"github.com/kabukky/journey/date"
8-
"github.com/kabukky/journey/filenames"
9-
"github.com/kabukky/journey/helpers"
10-
"github.com/kabukky/journey/structure"
6+
"journey/database/migration"
7+
"journey/date"
8+
"journey/filenames"
9+
"journey/helpers"
10+
"journey/structure"
11+
12+
uuid "github.com/satori/go.uuid"
1113
_ "modernc.org/sqlite"
12-
"github.com/satori/go.uuid"
1314
)
1415

1516
// Handler for read access

database/insertion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"database/sql"
55
"time"
66

7-
"github.com/satori/go.uuid"
7+
uuid "github.com/satori/go.uuid"
88
)
99

1010
const stmtInsertPost = "INSERT INTO posts (id, uuid, title, slug, markdown, html, featured, page, status, meta_description, image, author_id, created_at, created_by, updated_at, updated_by, published_at, published_by) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"

database/migration/ghost.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package migration
33
import (
44
"database/sql"
55
"errors"
6-
"github.com/kabukky/journey/date"
7-
"github.com/kabukky/journey/filenames"
8-
"github.com/kabukky/journey/helpers"
6+
"journey/date"
7+
"journey/filenames"
8+
"journey/helpers"
99
"log"
1010
"os"
1111
"path/filepath"

database/retrieval.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package database
33
import (
44
"database/sql"
55
"encoding/json"
6-
"github.com/kabukky/journey/structure"
6+
"journey/structure"
77
"time"
88
)
99

date/date.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ import (
1010

1111
var marchMayChecker = regexp.MustCompile("M([^a]|$)")
1212

13-
// Whenever we need time.Now(), we use this function instead so that we always use UTC in journey
13+
// GetCurrentTime returns the current time in UTC timezone.
1414
func GetCurrentTime() time.Time {
1515
return time.Now().UTC()
1616
}
1717

18+
// GenerateTimeAgo returns a human-readable string representing the time elapsed since the given date.
1819
func GenerateTimeAgo(date *time.Time) []byte {
1920
timeAgo := GetCurrentTime().Sub(*date)
2021
if timeAgo.Minutes() < 1 {

filenames/filenames.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package filenames
22

33
import (
4-
"github.com/kabukky/journey/flags"
5-
"github.com/kardianos/osext"
4+
"journey/flags"
65
"log"
76
"os"
87
"path/filepath"
98
"strings"
9+
10+
"github.com/kardianos/osext"
1011
)
1112

1213
var (

go.mod

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
module github.com/kabukky/journey
1+
module journey
22

3-
go 1.23.0
4-
5-
toolchain go1.24.2
3+
go 1.24
64

75
require (
86
github.com/dimfeld/httptreemux v5.0.1+incompatible

0 commit comments

Comments
 (0)