|
@@ -119,14 +119,24 @@ func getType(myvar interface{}) (res string) {
|
|
|
}
|
|
|
|
|
|
func query(values ...string) template.URL {
|
|
|
- var urlValues url.Values
|
|
|
+ var (
|
|
|
+ urlValues url.Values
|
|
|
+ format bool
|
|
|
+ )
|
|
|
|
|
|
urlValues = make(url.Values)
|
|
|
- urlValues.Set("format", "html")
|
|
|
|
|
|
for i := 0; i < len(values); i += 2 {
|
|
|
+ if values[i] == "format" {
|
|
|
+ format = true
|
|
|
+ }
|
|
|
urlValues.Add(values[i], values[i+1])
|
|
|
}
|
|
|
+
|
|
|
+ if !format {
|
|
|
+ urlValues.Set("format", "html")
|
|
|
+ }
|
|
|
+
|
|
|
return template.URL(urlValues.Encode())
|
|
|
}
|
|
|
|
|
@@ -179,10 +189,14 @@ func create(model string) string {
|
|
|
return fmt.Sprintf("/%s/%s/?%s", plural, action, q)
|
|
|
}
|
|
|
|
|
|
-func show(model string, id uint) string {
|
|
|
+func show(model string, id uint, format ...string) string {
|
|
|
action := "show"
|
|
|
plural := inflection.Plural(strings.ToLower(model))
|
|
|
- q := query("tpl_layout", "base", "tpl_content", fmt.Sprintf("%s_%s", plural, action))
|
|
|
+
|
|
|
+ args := []string{"tpl_layout", "base", "tpl_content", fmt.Sprintf("%s_%s", plural, action)}
|
|
|
+ args = append(args, format...)
|
|
|
+ // q := query("tpl_layout", "base", "tpl_content", fmt.Sprintf("%s_%s", plural, action))
|
|
|
+ q := query(args...)
|
|
|
|
|
|
return fmt.Sprintf("/%s/%d?%s", plural, id, q)
|
|
|
}
|