Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
a0514459
Commit
a0514459
authored
May 03, 2010
by
Andrew Gerrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
codelab/wiki: switch edit/view, as they were backwards
Fixes #757. R=rsc CC=golang-dev
https://golang.org/cl/1064041
parent
26078c39
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
10 deletions
+13
-10
final-template.go
doc/codelab/wiki/final-template.go
+2
-2
index.html
doc/codelab/wiki/index.html
+2
-2
wiki.html
doc/codelab/wiki/wiki.html
+9
-6
No files found.
doc/codelab/wiki/final-template.go
View file @
a0514459
...
...
@@ -34,13 +34,13 @@ func editHandler(c *http.Conn, r *http.Request) {
if
err
!=
nil
{
p
=
&
page
{
title
:
title
}
}
renderTemplate
(
c
,
"
view
"
,
p
)
renderTemplate
(
c
,
"
edit
"
,
p
)
}
func
viewHandler
(
c
*
http
.
Conn
,
r
*
http
.
Request
)
{
title
:=
r
.
URL
.
Path
[
lenPath
:
]
p
,
_
:=
loadPage
(
title
)
renderTemplate
(
c
,
"
edit
"
,
p
)
renderTemplate
(
c
,
"
view
"
,
p
)
}
func
saveHandler
(
c
*
http
.
Conn
,
r
*
http
.
Request
)
{
...
...
doc/codelab/wiki/index.html
View file @
a0514459
...
...
@@ -544,7 +544,7 @@ to its own function:
func viewHandler(c *http.Conn, r *http.Request) {
title := r.URL.Path[lenPath:]
p, _ := loadPage(title)
renderTemplate(c,
"
edit
"
, p)
renderTemplate(c,
"
view
"
, p)
}
func editHandler(c *http.Conn, r *http.Request) {
...
...
@@ -553,7 +553,7 @@ func editHandler(c *http.Conn, r *http.Request) {
if err != nil {
p =
&
page{title: title}
}
renderTemplate(c,
"
view
"
, p)
renderTemplate(c,
"
edit
"
, p)
}
func renderTemplate(c *http.Conn, tmpl string, p *page) {
...
...
doc/codelab/wiki/wiki.html
View file @
a0514459
...
...
@@ -58,13 +58,15 @@ package main
import (
"fmt"
"io/ioutil"
"os"
)
</pre>
<p>
Both
<code>
fmt
</code>
and
<code>
ioutil
</code>
are built-in packages that
we'll be using. Later, as we implement additional functionality, we will add
more packages to this
<code>
import
</code>
declaration.
We import the
<code>
fmt
</code>
,
<code>
ioutil
</code>
and
<code>
os
</code>
packages from the Go standard library. Later, as we implement additional
functionality, we will add more packages to this
<code>
import
</code>
declaration.
</p>
<h2>
Data Structures
</h2>
...
...
@@ -161,7 +163,7 @@ function to return <code>*page</code> and <code>os.Error</code>.
<p>
Callers of this function can now check the second parameter; if it is
<code>
nil
</code>
then it has succesfully loaded a page. If not, it will be an
<code>
nil
</code>
then it has succes
s
fully loaded a page. If not, it will be an
<code>
os.Error
</code>
that can be handled by the caller (see the
<a
href=
"http://golang.org/pkg/os/#Error"
>
os package documentation
</a>
for
details).
...
...
@@ -198,7 +200,7 @@ This is a sample page.
<p>
(The
<code>
8g
</code>
and
<code>
8l
</code>
commands are applicable to
<code>
GOARCH=386
</code>
. If you're on an
<code>
amd64
</code>
system,
subtitute 6's for the 8's.)
sub
s
titute 6's for the 8's.)
</p>
<p>
...
...
@@ -268,6 +270,7 @@ import (
"fmt"
<b>
"http"
</b>
"io/ioutil"
"os"
)
</pre>
...
...
@@ -389,7 +392,7 @@ import (
</pre>
<p>
Let's create a template file containg the HTML form.
Let's create a template file contain
in
g the HTML form.
Open a new file named
<code>
edit.html
</code>
, and add the following lines:
</p>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment