Skip to content

Commit 629cb24

Browse files
committed
first commit
0 parents  commit 629cb24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+6168
-0
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.buildlog
2+
.DS_Store
3+
.idea
4+
.packages
5+
.pub/
6+
build/
7+
packages
8+
pubspec.lock
9+
app/config.go

app/app.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
application: k07-me
2+
version: 1
3+
runtime: go
4+
api_version: go1
5+
6+
handlers:
7+
8+
- url: .*
9+
script: _go_app

app/index.yaml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
indexes:
2+
3+
# AUTOGENERATED
4+
5+
# This index.yaml is automatically updated whenever the dev_appserver
6+
# detects that a new type of query is run. If you want to manage the
7+
# index.yaml file manually, remove the above marker line (the line
8+
# saying "# AUTOGENERATED"). If you want to manage some indexes
9+
# manually, move them above the marker line. The index.yaml file is
10+
# automatically uploaded to the admin console when you next deploy
11+
# your application using appcfg.py.
12+
13+
- kind: FFArt
14+
properties:
15+
- name: ArticleId
16+
- name: Updated
17+
direction: desc
18+
19+
- kind: FFArt-blob
20+
properties:
21+
- name: Name
22+
- name: Parent
23+
- name: RootGroup
24+
- name: Updated
25+
direction: desc
26+
27+
- kind: FFArt-blob
28+
properties:
29+
- name: Parent
30+
- name: RootGroup
31+
- name: Updated
32+
direction: desc
33+
34+
- kind: FFUser-blob
35+
properties:
36+
- name: Name
37+
- name: Parent
38+
- name: RootGroup
39+
- name: Updated
40+
direction: desc
41+
42+
- kind: fu-blob
43+
properties:
44+
- name: Name
45+
- name: Parent
46+
- name: RootGroup
47+
- name: Updated
48+
direction: desc

app/main.go

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package app
2+
3+
import (
4+
"bytes"
5+
"net/http"
6+
7+
arTm "github.com/firefirestyle/engine-v01/article/template"
8+
usTm "github.com/firefirestyle/engine-v01/user/template"
9+
)
10+
11+
var userTemplate = usTm.NewUserTemplate(userConfig)
12+
var userCommentsTemp *arTm.ArtTemplate = arTm.NewArtTemplate(
13+
arTm.ArtTemplateConfig{
14+
GroupName: "Main",
15+
KindBaseName: "FFArt",
16+
MemcachedOnlyInBlobPointer: true,
17+
}, userTemplate.GetUserHundlerObj)
18+
19+
func init() {
20+
var buffer *bytes.Buffer = bytes.NewBufferString("")
21+
buffer.WriteString("<html><title>K07ME</title><body>")
22+
buffer.WriteString("<div>")
23+
buffer.WriteString("<a href=\"/api/v1/twitter/tokenurl/redirect\">redirect</a>")
24+
buffer.WriteString("</div>")
25+
buffer.WriteString("</body></html>")
26+
27+
userTemplate.InitUserApi()
28+
userCommentsTemp.InitArtApi()
29+
http.Handle("/", http.FileServer(http.Dir("web")))
30+
31+
}

article/.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.buildlog
2+
.DS_Store
3+
.idea
4+
.packages
5+
.pub/
6+
build/
7+
packages
8+
pubspec.lock

article/article/article.go

+224
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
package article
2+
3+
import (
4+
"time"
5+
6+
"golang.org/x/net/context"
7+
"google.golang.org/appengine/datastore"
8+
9+
miniprop "github.com/firefirestyle/engine-v01/prop"
10+
"google.golang.org/appengine/memcache"
11+
)
12+
13+
type GaeObjectArticle struct {
14+
UserName string
15+
Title string `datastore:",noindex"`
16+
Tags []string `datastore:"Tags.Tag"`
17+
Point float64
18+
Lat float64
19+
Lng float64
20+
PropNames []string `datastore:"Props.Name"`
21+
PropValues []string `datastore:"Props.Value"`
22+
Cont string `datastore:",noindex"`
23+
Info string `datastore:",noindex"`
24+
Sign string `datastore:",noindex"`
25+
ArticleId string
26+
Created time.Time
27+
Updated time.Time
28+
SecretKey string `datastore:",noindex"`
29+
IconUrl string `datastore:",noindex"`
30+
}
31+
32+
type Article struct {
33+
gaeObjectKey *datastore.Key
34+
gaeObject *GaeObjectArticle
35+
kind string
36+
}
37+
38+
const (
39+
TypeUserName = "UserName"
40+
TypeTitle = "Title"
41+
TypeTag = "Tag"
42+
TypePoint = "Point"
43+
TypePropNames = "PropNames"
44+
TypePropValues = "PropValues"
45+
TypeCont = "Cont"
46+
TypeInfo = "Info"
47+
TypeType = "Type"
48+
TypeSign = "Sign"
49+
TypeArticleId = "ArticleId"
50+
TypeCreated = "Created"
51+
TypeUpdated = "Updated"
52+
TypeSecretKey = "SecretKey"
53+
TypeTarget = "Target"
54+
TypeLat = "Lat"
55+
TypeLng = "Lng"
56+
TypeIconUrl = "IconUrl"
57+
)
58+
59+
func (obj *Article) updateMemcache(ctx context.Context) error {
60+
userObjMemSource := obj.ToJson()
61+
userObjMem := &memcache.Item{
62+
Key: obj.gaeObjectKey.StringID(),
63+
Value: []byte(userObjMemSource), //
64+
}
65+
memcache.Set(ctx, userObjMem)
66+
return nil
67+
}
68+
69+
//
70+
//
71+
//
72+
func (obj *Article) GetGaeObjectKind() string {
73+
return obj.kind
74+
}
75+
76+
func (obj *Article) GetGaeObjectKey() *datastore.Key {
77+
return obj.gaeObjectKey
78+
}
79+
80+
func (obj *Article) GetUserName() string {
81+
return obj.gaeObject.UserName
82+
}
83+
84+
func (obj *Article) GetSign() string {
85+
return obj.gaeObject.Sign
86+
}
87+
88+
func (obj *Article) GetIconUrl() string {
89+
return obj.gaeObject.IconUrl
90+
}
91+
92+
func (obj *Article) SetIconUrl(v string) {
93+
obj.gaeObject.IconUrl = v
94+
}
95+
96+
func (obj *Article) GetInfo() string {
97+
return obj.gaeObject.Info
98+
}
99+
100+
func (obj *Article) SetInfo(v string) {
101+
obj.gaeObject.Info = v
102+
}
103+
104+
func (obj *Article) SetUserName(v string) {
105+
obj.gaeObject.UserName = v
106+
}
107+
108+
func (obj *Article) GetTitle() string {
109+
return obj.gaeObject.Title
110+
}
111+
112+
func (obj *Article) SetTitle(v string) {
113+
obj.gaeObject.Title = v
114+
}
115+
116+
func (obj *Article) GetTags() []string {
117+
ret := make([]string, 0)
118+
for _, v := range obj.gaeObject.Tags {
119+
ret = append(ret, v)
120+
}
121+
return ret
122+
}
123+
124+
func (obj *Article) SetTags(vs []string) {
125+
obj.gaeObject.Tags = make([]string, 0)
126+
for _, v := range vs {
127+
obj.gaeObject.Tags = append(obj.gaeObject.Tags, v)
128+
}
129+
}
130+
131+
func (obj *Article) GetCont() string {
132+
return obj.gaeObject.Cont
133+
}
134+
135+
func (obj *Article) SetCont(v string) {
136+
obj.gaeObject.Cont = v
137+
}
138+
139+
func (obj *Article) GetParentId() string {
140+
return obj.gaeObject.Sign
141+
}
142+
143+
func (obj *Article) SetParentId(v string) {
144+
obj.gaeObject.Sign = v
145+
}
146+
147+
func (obj *Article) GetArticleId() string {
148+
return obj.gaeObject.ArticleId
149+
}
150+
151+
func (obj *Article) GetCreated() time.Time {
152+
return obj.gaeObject.Created
153+
}
154+
155+
func (obj *Article) GetUpdated() time.Time {
156+
return obj.gaeObject.Updated
157+
}
158+
159+
func (obj *Article) SetUpdated(v time.Time) {
160+
obj.gaeObject.Updated = v
161+
}
162+
163+
func (obj *Article) GetPoint() float64 {
164+
return obj.gaeObject.Point
165+
}
166+
167+
func (obj *Article) SetPoint(v float64) {
168+
obj.gaeObject.Point = v
169+
}
170+
171+
func (obj *Article) GetLat() float64 {
172+
return obj.gaeObject.Lat
173+
}
174+
175+
func (obj *Article) SetLat(v float64) {
176+
obj.gaeObject.Lat = v
177+
}
178+
179+
func (obj *Article) GetLng() float64 {
180+
return obj.gaeObject.Lng
181+
}
182+
183+
func (obj *Article) SetLng(v float64) {
184+
obj.gaeObject.Lng = v
185+
}
186+
187+
func (obj *Article) ClearProp() {
188+
obj.gaeObject.PropNames = nil
189+
obj.gaeObject.PropValues = nil
190+
}
191+
192+
func (obj *Article) GetProp(name string) string {
193+
index := -1
194+
for i, v := range obj.gaeObject.PropNames {
195+
if v == name {
196+
index = i
197+
break
198+
}
199+
}
200+
if index < 0 {
201+
return ""
202+
}
203+
p := miniprop.NewMiniPropFromJson([]byte(obj.gaeObject.PropValues[index]))
204+
return p.GetString(name, "")
205+
}
206+
207+
func (obj *Article) SetProp(name, v string) {
208+
index := -1
209+
p := miniprop.NewMiniProp()
210+
p.SetString(name, v)
211+
v = string(p.ToJson())
212+
for i, iv := range obj.gaeObject.PropNames {
213+
if iv == name {
214+
index = i
215+
break
216+
}
217+
}
218+
if index == -1 {
219+
obj.gaeObject.PropValues = append(obj.gaeObject.PropValues, v)
220+
obj.gaeObject.PropNames = append(obj.gaeObject.PropNames, name)
221+
} else {
222+
obj.gaeObject.PropValues[index] = v
223+
}
224+
}

0 commit comments

Comments
 (0)