summary refs log tree commit diff stats
path: root/summarize/wikipedia.go
diff options
context:
space:
mode:
Diffstat (limited to 'summarize/wikipedia.go')
-rw-r--r--summarize/wikipedia.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/summarize/wikipedia.go b/summarize/wikipedia.go
new file mode 100644
index 0000000..c4a5050
--- /dev/null
+++ b/summarize/wikipedia.go
@@ -0,0 +1,27 @@
+package summarize
+
+import (
+	"fmt"
+
+	"framagit.org/andinus/indus/fetch"
+	"framagit.org/andinus/indus/notification"
+)
+
+// Wikipedia returns struct notification.Notif with notification info
+// from the wikipedia summary.
+func Wikipedia(w fetch.Wiki) (notification.Notif, error) {
+	n := notification.Notif{}
+	var err error
+
+	// Continue only if the page's type is standard. TODO: Work
+	// with other page types to get summary.
+	switch w.Type {
+	case "standard":
+		n.Title = fmt.Sprintf("%s - Wikipedia", w.Title)
+		n.Message = w.Description
+	default:
+		err = fmt.Errorf("Summarizing wikipedia response failed")
+	}
+
+	return n, err
+}