Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
imghost
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Janne Mareike Koschinski
imghost
Commits
90f0dd60
Commit
90f0dd60
authored
7 years ago
by
Janne Mareike Koschinski
Browse files
Options
Downloads
Patches
Plain Diff
Switched to dark theme
parent
a3cf9101
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.go
+86
-0
86 additions, 0 deletions
main.go
with
86 additions
and
0 deletions
main.go
+
86
−
0
View file @
90f0dd60
...
...
@@ -346,6 +346,92 @@ func main() {
fmt
.
Fprint
(
w
,
"Image not found"
)
})))
http
.
Handle
(
"/a/"
,
http
.
StripPrefix
(
"/a/"
,
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
user
:=
parseUser
(
r
)
type
AlbumImage
struct
{
Id
string
Title
string
Description
string
Position
int
}
type
Album
struct
{
Id
string
Title
string
Description
string
CreatedAt
time
.
Time
Images
[]
AlbumImage
}
type
AlbumDetailData
struct
{
User
UserInfo
Album
Album
IsMine
bool
}
_
,
albumId
:=
path
.
Split
(
r
.
URL
.
Path
)
result
,
err
:=
db
.
Query
(
`
SELECT
id,
owner,
coalesce(title, ''),
coalesce(description, ''),
coalesce(created_at, to_timestamp(0))
FROM albums
WHERE id = $1
`
,
albumId
)
if
err
!=
nil
{
panic
(
err
)
}
var
info
Album
if
result
.
Next
()
{
var
owner
string
err
:=
result
.
Scan
(
&
info
.
Id
,
&
owner
,
&
info
.
Title
,
&
info
.
Description
,
&
info
.
CreatedAt
)
if
err
!=
nil
{
panic
(
err
)
}
result
,
err
:=
db
.
Query
(
`
SELECT
image,
title,
description,
position
FROM album_images
WHERE album = $1
ORDER BY position ASC
`
,
albumId
)
if
err
!=
nil
{
panic
(
err
)
}
for
result
.
Next
()
{
var
image
AlbumImage
err
:=
result
.
Scan
(
&
image
.
Id
,
&
owner
,
&
image
.
Title
,
&
image
.
Description
,
&
image
.
Position
)
if
err
!=
nil
{
panic
(
err
)
}
info
.
Images
=
append
(
info
.
Images
,
image
)
}
if
err
=
returnResult
(
w
,
"album_detail.html"
,
AlbumDetailData
{
user
,
info
,
owner
==
user
.
Id
,
});
err
!=
nil
{
panic
(
err
)
}
return
}
w
.
WriteHeader
(
http
.
StatusNotFound
)
fmt
.
Fprint
(
w
,
"Image not found"
)
})))
http
.
HandleFunc
(
"/me/images/"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
user
:=
parseUser
(
r
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment