2
0

view_user_watch_list.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package route
  2. import (
  3. "opennamu/route/tool"
  4. )
  5. func View_user_watch_list(config tool.Config, num string, do_type string) string {
  6. db := tool.DB_connect()
  7. defer tool.DB_close(db)
  8. other_set := map[string]string{}
  9. json.Unmarshal([]byte(config.Other_set), &other_set)
  10. api_data := Api_user_watch_list(config, config.IP, num, do_type)
  11. data_html := ""
  12. if api_data["response"] != "ok" {
  13. return tool.Get_error_page(db, config, "auth")
  14. } else {
  15. data_html += "<ul>"
  16. for _, title := range api_data["data"].([]string) {
  17. data_html += "<li><a href=\"/w/" + tool.Url_parser(title) + "\">" + tool.HTML_escape(title) + "</a></li>"
  18. }
  19. data_html += "</ul>"
  20. }
  21. title := tool.Get_language(db, "watchlist", true)
  22. if do_type == "star_doc" {
  23. title = tool.Get_language(db, "star_doc", true)
  24. }
  25. out := tool.Get_template(
  26. db,
  27. config,
  28. title,
  29. data_html,
  30. []any{},
  31. [][]any{
  32. { "user/" + tool.Url_parser(config.IP), tool.Get_language(db, "return", false) },
  33. { "watch_list", tool.Get_language(db, "watchlist", false) },
  34. { "star_doc", tool.Get_language(db, "star_doc", false) },
  35. },
  36. map[string]string{},
  37. )
  38. return out
  39. }