Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed Apr 6, 2022
1 parent 697d93a commit 6e4f871
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions main.v
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ pub fn (mut app App) create_module(name string, description string, vcs string)
pub fn (mut app App) mod(name string) vweb.Result {
// name := app.get_mod_name()
println('mod name=$name')
mymod := app.mods_repo.retrieve(name) or { return app.redirect('/') }
mymod := app.retrieve(name) or { return app.redirect('/') }
xx := mymod // TODO weird tmpl bug
// comments := app.find_comments(id)
// show_form := true
return $vweb.html()
Expand All @@ -133,7 +134,7 @@ pub fn (mut app App) jsmod() {
name := app.req.url.replace('jsmod/', '')[1..]
println('MOD name=$name')
app.mods_repo.inc_nr_downloads(name)
mod := app.mods_repo.retrieve(name) or {
mod := app.retrieve(name) or {
app.json('404')
return
}
Expand Down
9 changes: 6 additions & 3 deletions mod.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
@include 'header.html'

<h2>mymod.name</h2>

<img width=30 src='//vlang.io/img/github.png'>
<a href='mymod.url'>mymod.url</a>
<h2>@xx.name</h2>

<img width=30 src='https://vlang.io/img/github.png'>
<a href='@xx.url'>@xx.url</a>

<b></b>
5 changes: 3 additions & 2 deletions mod.v
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ fn (mut app App) find_all_mods() []Mod {
return mods
}

fn (repo ModsRepo) retrieve(name string) ?Mod {
rows := repo.db.exec_param('select name, url, nr_downloads, vcs, description from "Mod" where name=$1',
// fn (repo ModsRepo) retrieve(name string) ?Mod {
fn (app &App) retrieve(name string) ?Mod {
rows := app.db.exec_param('select name, url, nr_downloads, vcs, description from "Mod" where name=$1',
name) or { return err }
if rows.len == 0 {
return error('Found no module with name "$name"')
Expand Down

0 comments on commit 6e4f871

Please sign in to comment.