diff --git a/docs/CLI.md b/docs/CLI.md index 3c41c79..1bc495e 100644 --- a/docs/CLI.md +++ b/docs/CLI.md @@ -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:** diff --git a/migrations/postgres/2018-10-06-161151_change_default_license/down.sql b/migrations/postgres/2018-10-06-161151_change_default_license/down.sql new file mode 100644 index 0000000..5643a2a --- /dev/null +++ b/migrations/postgres/2018-10-06-161151_change_default_license/down.sql @@ -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'; diff --git a/migrations/postgres/2018-10-06-161151_change_default_license/up.sql b/migrations/postgres/2018-10-06-161151_change_default_license/up.sql new file mode 100644 index 0000000..376beea --- /dev/null +++ b/migrations/postgres/2018-10-06-161151_change_default_license/up.sql @@ -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'; diff --git a/migrations/sqlite/2018-10-06-161156_change_default_license/down.sql b/migrations/sqlite/2018-10-06-161156_change_default_license/down.sql new file mode 100644 index 0000000..9e6bc48 --- /dev/null +++ b/migrations/sqlite/2018-10-06-161156_change_default_license/down.sql @@ -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; diff --git a/migrations/sqlite/2018-10-06-161156_change_default_license/up.sql b/migrations/sqlite/2018-10-06-161156_change_default_license/up.sql new file mode 100644 index 0000000..df1dc87 --- /dev/null +++ b/migrations/sqlite/2018-10-06-161156_change_default_license/up.sql @@ -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; diff --git a/plume-cli/src/instance.rs b/plume-cli/src/instance.rs index 80aea30..7872ada 100644 --- a/plume-cli/src/instance.rs +++ b/plume-cli/src/instance.rs @@ -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 { diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index 727db41..e4adf89 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -428,7 +428,7 @@ impl FromActivity 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()), diff --git a/src/routes/posts.rs b/src/routes/posts.rs index 20ad1bc..6cd4652 100644 --- a/src/routes/posts.rs +++ b/src/routes/posts.rs @@ -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, 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,