Change default license to CC-BY-SA

Fixes #258
This commit is contained in:
Bat 2018-10-06 18:19:45 +01:00
parent 046c9a011e
commit 387efbf3e9
8 changed files with 91 additions and 5 deletions

View File

@ -20,7 +20,7 @@ plm instance new --private --domain plu.me --name 'My Plume Instance' -l 'CC-BY'
- `--domain`, `-d`: the domain name on which your instance will be available.
- `--name`, `-n`: The name of your instance. It will be displayed on the homepage.
- `--default-license`, `-l`: the license to use for articles written on this instance, if no other license is explicitely specified. Optional, defaults to CC-0.
- `--default-license`, `-l`: the license to use for articles written on this instance, if no other license is explicitely specified. Optional, defaults to CC-BY-SA.
- `--private`, `-p`: if this argument is present, registering on this instance won't be possible. Optional, off by default.
**Environment variables:**

View File

@ -0,0 +1,3 @@
-- This file should undo anything in `up.sql`
ALTER TABLE ONLY posts ALTER COLUMN license SET DEFAULT 'CC-0';
ALTER TABLE ONLY instances ALTER COLUMN default_license SET DEFAULT 'CC-0';

View File

@ -0,0 +1,3 @@
-- Your SQL goes hereALTER TABLE ONLY posts ALTER COLUMN license SET DEFAULT 'CC-BY-SA';
ALTER TABLE ONLY posts ALTER COLUMN license SET DEFAULT 'CC-BY-SA';
ALTER TABLE ONLY instances ALTER COLUMN default_license SET DEFAULT 'CC-BY-SA';

View File

@ -0,0 +1,40 @@
-- This file should undo anything in `up.sql`
-- SQLite is great, we can't just change the default value,
-- we have to clone the table with the new value.
CREATE TABLE instances2 (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
public_domain VARCHAR NOT NULL,
name VARCHAR NOT NULL,
local BOOLEAN NOT NULL DEFAULT 'f',
blocked BOOLEAN NOT NULL DEFAULT 'f',
creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
open_registrations BOOLEAN NOT NULL DEFAULT 't',
short_description TEXT NOT NULL DEFAULT '',
long_description TEXT NOT NULL DEFAULT '',
default_license TEXT NOT NULL DEFAULT 'CC-0',
long_description_html VARCHAR NOT NULL DEFAULT '',
short_description_html VARCHAR NOT NULL DEFAULT ''
);
INSERT INTO instances2 SELECT * FROM instances;
DROP TABLE instances;
ALTER TABLE instances2 RENAME TO instances;
CREATE TABLE posts2 (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
blog_id INTEGER REFERENCES blogs(id) ON DELETE CASCADE NOT NULL,
slug VARCHAR NOT NULL,
title VARCHAR NOT NULL,
content TEXT NOT NULL DEFAULT '',
published BOOLEAN NOT NULL DEFAULT 'f',
license VARCHAR NOT NULL DEFAULT 'CC-0',
creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
ap_url VARCHAR NOT NULL DEFAULT '',
subtitle TEXT NOT NULL DEFAULT '',
source TEXT NOT NULL DEFAULT ''
);
INSERT INTO SELECT * FROM posts;
DROP TABLE posts;
ALTER TABLE posts2 RENAME TO posts;

View File

@ -0,0 +1,40 @@
-- Your SQL goes here
-- SQLite is great, we can't just change the default value,
-- we have to clone the table with the new value.
CREATE TABLE instances2 (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
public_domain VARCHAR NOT NULL,
name VARCHAR NOT NULL,
local BOOLEAN NOT NULL DEFAULT 'f',
blocked BOOLEAN NOT NULL DEFAULT 'f',
creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
open_registrations BOOLEAN NOT NULL DEFAULT 't',
short_description TEXT NOT NULL DEFAULT '',
long_description TEXT NOT NULL DEFAULT '',
default_license TEXT NOT NULL DEFAULT 'CC-BY-SA',
long_description_html VARCHAR NOT NULL DEFAULT '',
short_description_html VARCHAR NOT NULL DEFAULT ''
);
INSERT INTO instances2 SELECT * FROM instances;
DROP TABLE instances;
ALTER TABLE instances2 RENAME TO instances;
CREATE TABLE posts2 (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
blog_id INTEGER REFERENCES blogs(id) ON DELETE CASCADE NOT NULL,
slug VARCHAR NOT NULL,
title VARCHAR NOT NULL,
content TEXT NOT NULL DEFAULT '',
published BOOLEAN NOT NULL DEFAULT 'f',
license VARCHAR NOT NULL DEFAULT 'CC-BY-SA',
creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
ap_url VARCHAR NOT NULL DEFAULT '',
subtitle TEXT NOT NULL DEFAULT '',
source TEXT NOT NULL DEFAULT ''
);
INSERT INTO posts2 SELECT * FROM posts;
DROP TABLE posts;
ALTER TABLE posts2 RENAME TO posts;

View File

@ -46,7 +46,7 @@ fn new<'a>(args: &ArgMatches<'a>, conn: &Connection) {
.unwrap_or_else(|| env::var("BASE_URL")
.unwrap_or_else(|_| super::ask_for("Domain name")));
let name = args.value_of("name").map(String::from).unwrap_or_else(|| super::ask_for("Instance name"));
let license = args.value_of("default-license").map(String::from).unwrap_or(String::from("CC-0"));
let license = args.value_of("default-license").map(String::from).unwrap_or(String::from("CC-BY-SA"));
let open_reg = !args.is_present("private");
Instance::insert(conn, NewInstance {

View File

@ -428,7 +428,7 @@ impl FromActivity<Article, Connection> for Post {
title: title,
content: SafeString::new(&article.object_props.content_string().expect("Post::from_activity: content error")),
published: true,
license: String::from("CC-0"), // TODO
license: String::from("CC-BY-SA"), // TODO
// FIXME: This is wrong: with this logic, we may use the display URL as the AP ID. We need two different fields
ap_url: article.object_props.url_string().unwrap_or(article.object_props.id_string().expect("Post::from_activity: url + id error")),
creation_date: Some(article.object_props.published_utctime().expect("Post::from_activity: published error").naive_utc()),

View File

@ -182,7 +182,7 @@ fn update(blog: String, slug: String, user: User, conn: DbConn, data: LenientFor
let license = if form.license.len() > 0 {
form.license.to_string()
} else {
Instance::get_local(&*conn).map(|i| i.default_license).unwrap_or(String::from("CC-0"))
Instance::get_local(&*conn).map(|i| i.default_license).unwrap_or(String::from("CC-BY-SA"))
};
// update publication date if when this article is no longer a draft
@ -292,7 +292,7 @@ fn create(blog_name: String, data: LenientForm<NewPostForm>, user: User, conn: D
license: if form.license.len() > 0 {
form.license.to_string()
} else {
Instance::get_local(&*conn).map(|i| i.default_license).unwrap_or(String::from("CC-0"))
Instance::get_local(&*conn).map(|i| i.default_license).unwrap_or(String::from("CC-BY-SA"))
},
ap_url: "".to_string(),
creation_date: None,