Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

Add new `description` field to lists. Closes #925.

Kailash Nadhef1f84ee7c5c
diff --git a/cmd/install.go b/cmd/install.go
index 3056d837..42883a32 100644
--- a/cmd/install.go
+++ b/cmd/install.go
@@ -74,6 +74,7 @@ func install(lastVer string, db *sqlx.DB, fs stuffbin.FileSystem, prompt, idempo
models.ListTypePrivate,
models.ListOptinSingle,
pq.StringArray{"test"},
+ "",
); err != nil {
lo.Fatalf("error creating list: %v", err)
}
@@ -83,6 +84,7 @@ func install(lastVer string, db *sqlx.DB, fs stuffbin.FileSystem, prompt, idempo
models.ListTypePublic,
models.ListOptinDouble,
pq.StringArray{"test"},
+ "",
); err != nil {
lo.Fatalf("error creating list: %v", err)
}
diff --git a/frontend/cypress/e2e/lists.cy.js b/frontend/cypress/e2e/lists.cy.js
index 7a5b3c57..5e47b672 100644
--- a/frontend/cypress/e2e/lists.cy.js
+++ b/frontend/cypress/e2e/lists.cy.js
@@ -51,6 +51,7 @@ describe('Lists', () => {
cy.get('select[name=type]').select('public');
cy.get('select[name=optin]').select('double');
cy.get('input[name=tags]').clear().type(`tag${n}{enter}`);
+ cy.get('textarea[name=description]').clear().type(`desc${n}`);
cy.get('[data-cy=btn-save]').click();
cy.wait(100);
});
@@ -94,6 +95,7 @@ describe('Lists', () => {
cy.get('select[name=type]').select(t);
cy.get('select[name=optin]').select(o);
cy.get('input[name=tags]').type(`tag${n}{enter}${t}{enter}${o}{enter}`);
+ cy.get('textarea[name=description]').clear().type(`desc-${t}-${n}`);
cy.get('[data-cy=btn-save]').click();
cy.wait(200);
@@ -133,4 +135,22 @@ describe('Lists', () => {
cy.sortTable('thead th.cy-updated_at', [3, 4, 5, 6]);
cy.sortTable('thead th.cy-updated_at', [6, 5, 4, 3]);
});
+
+ it('Opens forms page', () => {
+ const apiUrl = Cypress.env('apiUrl');
+ cy.loginAndVisit(`${apiUrl}/subscription/form`);
+ cy.get('ul li').its('length').should('eq', 2);
+
+ const cases = [
+ { 'name': 'list-public-single-2', 'description': 'desc-public-2' },
+ { 'name': 'list-public-double-3', 'description': 'desc-public-3' }
+ ];
+
+ cases.forEach((c, n) => {
+ cy.get('ul li').eq(n).then(($el) => {
+ cy.wrap($el).get('label').contains(c.name);
+ cy.wrap($el).get('.description').contains(c.description);
+ });
+ });
+ });
});
diff --git a/frontend/src/views/Forms.vue b/frontend/src/views/Forms.vue
index b032a651..c9452fea 100644
--- a/frontend/src/views/Forms.vue
+++ b/frontend/src/views/Forms.vue
@@ -47,7 +47,7 @@
<template v-for="l in publicLists"><span v-if="l.uuid in selected" :key="l.id" :set="id = l.uuid.substr(0, 5)">
&lt;p&gt;
&lt;input id=&quot;{{ id }}&quot; type=&quot;checkbox&quot; name=&quot;l&quot; checked value=&quot;{{ l.uuid }}&quot; /&gt;
- &lt;label for=&quot;{{ id }}&quot;&gt;{{ l.name }}&lt;/label&gt;
+ &lt;label for=&quot;{{ id }}&quot;&gt;{{ l.name }}&lt;/label&gt;<template v-if="l.description">&lt;br /&gt;&lt;span&gt;{{ l.description }}&lt;/span&gt;</template>
&lt;/p&gt;</span></template>
&lt;p&gt;&lt;input type=&quot;submit&quot; value=&quot;{{ $t('public.sub') }}&quot; /&gt;&lt;/p&gt;
diff --git a/frontend/src/views/ListForm.vue b/frontend/src/views/ListForm.vue
index 0a0a912d..e233b83d 100644
--- a/frontend/src/views/ListForm.vue
+++ b/frontend/src/views/ListForm.vue
@@ -38,6 +38,11 @@
<b-taginput v-model="form.tags" name="tags" ellipsis
icon="tag-outline" :placeholder="$t('globals.terms.tags')"></b-taginput>
</b-field>
+
+ <b-field :label="$t('globals.fields.description')" label-position="on-border">
+ <b-input :maxlength="2000" v-model="form.description" name="description" type="textarea"
+ :placeholder="$t('globals.fields.description')"></b-input>
+ </b-field>
</section>
<footer class="modal-card-foot has-text-right">
<b-button @click="$parent.close()">{{ $t('globals.buttons.close') }}</b-button>
diff --git a/i18n/ca.json b/i18n/ca.json
index b0146919..a2c29f7c 100644
--- a/i18n/ca.json
+++ b/i18n/ca.json
@@ -143,6 +143,7 @@
"globals.days.6": "dv.",
"globals.days.7": "ds.",
"globals.fields.createdAt": "Creat",
+ "globals.fields.description": "Description",
"globals.fields.id": "ID",
"globals.fields.name": "Nom",
"globals.fields.status": "Estat",
diff --git a/i18n/cs-cz.json b/i18n/cs-cz.json
index c76c39c8..89c03f6e 100644
--- a/i18n/cs-cz.json
+++ b/i18n/cs-cz.json
@@ -144,6 +144,7 @@
"globals.days.6": "So",
"globals.days.7": "Sat",
"globals.fields.createdAt": "Vytvořeno",
+ "globals.fields.description": "Description",
"globals.fields.id": "ID",
"globals.fields.name": "Jméno",
"globals.fields.status": "Stav",
diff --git a/i18n/de.json b/i18n/de.json
index af0decbe..242197f0 100644
--- a/i18n/de.json
+++ b/i18n/de.json
@@ -144,6 +144,7 @@
"globals.days.6": "Sa",
"globals.days.7": "Sat",
"globals.fields.createdAt": "Erstellt",
+ "globals.fields.description": "Description",
"globals.fields.id": "ID",
"globals.fields.name": "Name",
"globals.fields.status": "Status",
diff --git a/i18n/en.json b/i18n/en.json
index 76d118a2..79f582e9 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -143,6 +143,7 @@
"globals.days.6": "Fri",
"globals.days.7": "Sat",
"globals.fields.createdAt": "Created",
+ "globals.fields.description": "Description",
"globals.fields.id": "ID",
"globals.fields.name": "Name",
"globals.fields.status": "Status",
diff --git a/i18n/es.json b/i18n/es.json
index 120473aa..7249398c 100644
--- a/i18n/es.json
+++ b/i18n/es.json
@@ -144,6 +144,7 @@
"globals.days.6": "Vie",
"globals.days.7": "Sáb",
"globals.fields.createdAt": "Creado",
+ "globals.fields.description": "Description",
"globals.fields.id": "ID",
"globals.fields.name": "Nombre",
"globals.fields.status": "Estado",
diff --git a/i18n/fi.json b/i18n/fi.json
index f7bbb9c7..b6a0e8cc 100644
--- a/i18n/fi.json
+++ b/i18n/fi.json
@@ -144,6 +144,7 @@
"globals.days.6": "Fri",
"globals.days.7": "Sat",
"globals.fields.createdAt": "Created",
+ "globals.fields.description": "Description",
"globals.fields.id": "ID",
"globals.fields.name": "Nimi",
"globals.fields.status": "Tila",
diff --git a/i18n/fr.json b/i18n/fr.json
index 145cb9bd..582bd664 100644
--- a/i18n/fr.json
+++ b/i18n/fr.json
@@ -144,6 +144,7 @@
"globals.days.6": "sam.",
"globals.days.7": "Dim",
"globals.fields.createdAt": "Créé·e le",
+ "globals.fields.description": "Description",
"globals.fields.id": "ID",
"globals.fields.name": "Nom",
"globals.fields.status": "Statut",
diff --git a/i18n/hu.json b/i18n/hu.json
index 867b442a..8d0845ca 100644
--- a/i18n/hu.json
+++ b/i18n/hu.json
@@ -144,6 +144,7 @@
"globals.days.6": "Szombat",
"globals.days.7": "Sat",
"globals.fields.createdAt": "Létrehozva",
+ "globals.fields.description": "Description",
"globals.fields.id": "ID",
"globals.fields.name": "Név",
"globals.fields.status": "Státusz",
diff --git a/i18n/it.json b/i18n/it.json
index 128be587..ca109c1c 100644
--- a/i18n/it.json
+++ b/i18n/it.json
@@ -144,6 +144,7 @@
"globals.days.6": "sab",
"globals.days.7": "Sat",
"globals.fields.createdAt": "Creato il ",
+ "globals.fields.description": "Description",
"globals.fields.id": "ID",
"globals.fields.name": "Nome",
"globals.fields.status": "Stato",
diff --git a/i18n/jp.json b/i18n/jp.json
index 1620fa62..ca32e732 100644
--- a/i18n/jp.json
+++ b/i18n/jp.json
@@ -144,6 +144,7 @@
"globals.days.6": "金",
"globals.days.7": "土",
"globals.fields.createdAt": "作成済み",
+ "globals.fields.description": "Description",
"globals.fields.id": "ID",
"globals.fields.name": "名前",
"globals.fields.status": "ステータス",
diff --git a/i18n/ml.json b/i18n/ml.json
index 9caa794c..787c1f50 100644
--- a/i18n/ml.json
+++ b/i18n/ml.json
@@ -144,6 +144,7 @@
"globals.days.6": "ശനി",
"globals.days.7": "Sat",
"globals.fields.createdAt": "നിർമ്മിച്ചത്",
+ "globals.fields.description": "Description",
"globals.fields.id": "ഐഡി",
"globals.fields.name": "പേര്",
"globals.fields.status": "സ്ഥിതി",
diff --git a/i18n/nl.json b/i18n/nl.json
index 913e6539..ffa4a130 100644
--- a/i18n/nl.json
+++ b/i18n/nl.json
@@ -144,6 +144,7 @@
"globals.days.6": "Za",
"globals.days.7": "Zat",
"globals.fields.createdAt": "Aangemaakt",
+ "globals.fields.description": "Description",
"globals.fields.id": "ID",
"globals.fields.name": "Naam",
"globals.fields.status": "Status",
diff --git a/i18n/pl.json b/i18n/pl.json
index 96a9343a..a90b3a8e 100644
--- a/i18n/pl.json
+++ b/i18n/pl.json
@@ -144,6 +144,7 @@
"globals.days.6": "Sob",
"globals.days.7": "Sat",
"globals.fields.createdAt": "Utworzone",
+ "globals.fields.description": "Description",
"globals.fields.id": "ID",
"globals.fields.name": "Nazwa",
"globals.fields.status": "Status",
diff --git a/i18n/pt-BR.json b/i18n/pt-BR.json
index f30afda6..8215e7c5 100644
--- a/i18n/pt-BR.json
+++ b/i18n/pt-BR.json
@@ -144,6 +144,7 @@
"globals.days.6": "Sex",
"globals.days.7": "Sáb",
"globals.fields.createdAt": "Criado",
+ "globals.fields.description": "Description",
"globals.fields.id": "ID",
"globals.fields.name": "Nome",
"globals.fields.status": "Status",
diff --git a/i18n/pt.json b/i18n/pt.json
index ceb9159b..67dfe5eb 100644
--- a/i18n/pt.json
+++ b/i18n/pt.json
@@ -144,6 +144,7 @@
"globals.days.6": "Sáb",
"globals.days.7": "Sat",
"globals.fields.createdAt": "Criado a",
+ "globals.fields.description": "Description",
"globals.fields.id": "ID",
"globals.fields.name": "Nome",
"globals.fields.status": "Estado",
diff --git a/i18n/ro.json b/i18n/ro.json
index 93a8894b..a47af861 100644
--- a/i18n/ro.json
+++ b/i18n/ro.json
@@ -144,6 +144,7 @@
"globals.days.6": "Sa",
"globals.days.7": "Sat",
"globals.fields.createdAt": "Creat",
+ "globals.fields.description": "Description",
"globals.fields.id": "ID",
"globals.fields.name": "Nume",
"globals.fields.status": "Stare",
diff --git a/i18n/ru.json b/i18n/ru.json
index 938c55fb..6479bccf 100644
--- a/i18n/ru.json
+++ b/i18n/ru.json
@@ -144,6 +144,7 @@
"globals.days.6": "Сб",
"globals.days.7": "Sat",
"globals.fields.createdAt": "Создано",
+ "globals.fields.description": "Description",
"globals.fields.id": "ID",
"globals.fields.name": "Имя",
"globals.fields.status": "Статус",
diff --git a/i18n/tr.json b/i18n/tr.json
index 05ae3a94..e1be41dd 100644
--- a/i18n/tr.json
+++ b/i18n/tr.json
@@ -144,6 +144,7 @@
"globals.days.6": "Cts",
"globals.days.7": "Sat",
"globals.fields.createdAt": "Yaratılma",
+ "globals.fields.description": "Description",
"globals.fields.id": "ID",
"globals.fields.name": "İsim",
"globals.fields.status": "Durum",
diff --git a/i18n/vi.json b/i18n/vi.json
index 42e0e8a3..4501e32d 100644
--- a/i18n/vi.json
+++ b/i18n/vi.json
@@ -144,6 +144,7 @@
"globals.days.6": "Thứ 7",
"globals.days.7": "Sat",
"globals.fields.createdAt": "Đã tạo",
+ "globals.fields.description": "Description",
"globals.fields.id": "ID",
"globals.fields.name": "Tên",
"globals.fields.status": "Trạng thái",
diff --git a/i18n/zh-CN.json b/i18n/zh-CN.json
index d47d59fc..b9ab46f9 100644
--- a/i18n/zh-CN.json
+++ b/i18n/zh-CN.json
@@ -144,6 +144,7 @@
"globals.days.6": "星期五",
"globals.days.7": "星期六",
"globals.fields.createdAt": "已创建",
+ "globals.fields.description": "Description",
"globals.fields.id": "身份标识",
"globals.fields.name": "姓名",
"globals.fields.status": "状态",
diff --git a/i18n/zh-TW.json b/i18n/zh-TW.json
index 2d2f0fd4..869b58b1 100644
--- a/i18n/zh-TW.json
+++ b/i18n/zh-TW.json
@@ -144,6 +144,7 @@
"globals.days.6": "星期五",
"globals.days.7": "星期六",
"globals.fields.createdAt": "已創建",
+ "globals.fields.description": "Description",
"globals.fields.id": "身份標識",
"globals.fields.name": "姓名",
"globals.fields.status": "狀態",
diff --git a/internal/core/lists.go b/internal/core/lists.go
index 1425dde0..9a5f4bb4 100644
--- a/internal/core/lists.go
+++ b/internal/core/lists.go
@@ -120,7 +120,7 @@ func (c *Core) CreateList(l models.List) (models.List, error) {
// Insert and read ID.
var newID int
l.UUID = uu.String()
- if err := c.q.CreateList.Get(&newID, l.UUID, l.Name, l.Type, l.Optin, pq.StringArray(normalizeTags(l.Tags))); err != nil {
+ if err := c.q.CreateList.Get(&newID, l.UUID, l.Name, l.Type, l.Optin, pq.StringArray(normalizeTags(l.Tags)), l.Description); err != nil {
c.log.Printf("error creating list: %v", err)
return models.List{}, echo.NewHTTPError(http.StatusInternalServerError,
c.i18n.Ts("globals.messages.errorCreating", "name", "{globals.terms.list}", "error", pqErrMsg(err)))
@@ -131,7 +131,7 @@ func (c *Core) CreateList(l models.List) (models.List, error) {
// UpdateList updates a given list.
func (c *Core) UpdateList(id int, l models.List) (models.List, error) {
- res, err := c.q.UpdateList.Exec(id, l.Name, l.Type, l.Optin, pq.StringArray(normalizeTags(l.Tags)))
+ res, err := c.q.UpdateList.Exec(id, l.Name, l.Type, l.Optin, pq.StringArray(normalizeTags(l.Tags)), l.Description)
if err != nil {
c.log.Printf("error updating list: %v", err)
return models.List{}, echo.NewHTTPError(http.StatusInternalServerError,
diff --git a/internal/migrations/v2.3.0.go b/internal/migrations/v2.3.0.go
index 56d6261c..9c950c55 100644
--- a/internal/migrations/v2.3.0.go
+++ b/internal/migrations/v2.3.0.go
@@ -12,7 +12,12 @@ func V2_3_0(db *sqlx.DB, fs stuffbin.FileSystem, ko *koanf.Koanf) error {
return err
}
- // Insert appearance related settings.
+ // Add `description` field to lists.
+ if _, err := db.Exec(`ALTER TABLE lists ADD COLUMN IF NOT EXISTS "description" TEXT NOT NULL DEFAULT ''`); err != nil {
+ return err
+ }
+
+ // Insert new preference settings.
if _, err := db.Exec(`
INSERT INTO settings (key, value) VALUES
('privacy.allow_preferences', 'false')
diff --git a/models/models.go b/models/models.go
index 30e6ced0..832b061d 100644
--- a/models/models.go
+++ b/models/models.go
@@ -214,6 +214,7 @@ type List struct {
Type string `db:"type" json:"type"`
Optin string `db:"optin" json:"optin"`
Tags pq.StringArray `db:"tags" json:"tags"`
+ Description string `db:"description" json:"description"`
SubscriberCount int `db:"-" json:"subscriber_count"`
SubscriberCounts StringIntMap `db:"subscriber_statuses" json:"subscriber_statuses"`
SubscriberID int `db:"subscriber_id" json:"-"`
diff --git a/queries.sql b/queries.sql
index f0e4eddb..685e6102 100644
--- a/queries.sql
+++ b/queries.sql
@@ -418,7 +418,7 @@ SELECT * FROM lists WHERE (CASE WHEN $1 != '' THEN optin=$1::list_optin ELSE TRU
END) ORDER BY name;
-- name: create-list
-INSERT INTO lists (uuid, name, type, optin, tags) VALUES($1, $2, $3, $4, $5) RETURNING id;
+INSERT INTO lists (uuid, name, type, optin, tags, description) VALUES($1, $2, $3, $4, $5, $6) RETURNING id;
-- name: update-list
UPDATE lists SET
@@ -426,6 +426,7 @@ UPDATE lists SET
type=(CASE WHEN $3 != '' THEN $3::list_type ELSE type END),
optin=(CASE WHEN $4 != '' THEN $4::list_optin ELSE optin END),
tags=$5::VARCHAR(100)[],
+ description=(CASE WHEN $6 != '' THEN $6 ELSE description END),
updated_at=NOW()
WHERE id = $1;
diff --git a/schema.sql b/schema.sql
index d16e7e0f..70fb1ee3 100644
--- a/schema.sql
+++ b/schema.sql
@@ -33,6 +33,7 @@ CREATE TABLE lists (
type list_type NOT NULL,
optin list_optin NOT NULL DEFAULT 'single',
tags VARCHAR(100)[],
+ description TEXT NOT NULL DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
diff --git a/static/public/static/style.css b/static/public/static/style.css
index 7256ca40..a99adb1c 100644
--- a/static/public/static/style.css
+++ b/static/public/static/style.css
@@ -21,7 +21,7 @@ a:hover {
}
label {
cursor: pointer;
- color: #666;
+ color: #444;
}
h1,
h2,
@@ -118,7 +118,18 @@ input[disabled] {
.lists {
list-style-type: none;
padding: 0;
+ margin-bottom: 30px;
}
+ .lists li {
+ margin: 0 0 5px 0;
+ }
+ .lists .description {
+ margin: 0 0 15px 0;
+ font-size: 0.875em;
+ line-height: 1.3rem;
+ color: #888;
+ margin-left: 25px;
+ }
.form .nonce {
display: none;
}
diff --git a/static/public/templates/subscription-form.html b/static/public/templates/subscription-form.html
index 152425f4..e45c2239 100644
--- a/static/public/templates/subscription-form.html
+++ b/static/public/templates/subscription-form.html
@@ -22,6 +22,9 @@
<li>
<input checked="true" id="l-{{ $l.UUID}}" type="checkbox" name="l" value="{{ $l.UUID }}" >
<label for="l-{{ $l.UUID}}">{{ $l.Name }}</label>
+ {{ if ne $l.Description "" }}
+ <p class="description">{{ $l.Description }}</p>
+ {{ end }}
</li>
{{ end }}
</ul>