diff options
author | kaniini <nenolod@gmail.com> | 2019-03-15 02:50:27 +0000 |
---|---|---|
committer | kaniini <nenolod@gmail.com> | 2019-03-15 02:50:27 +0000 |
commit | c708656b5e4dd0a7c7f9ec5fb0116f542a85e309 (patch) | |
tree | 7e67da76a93f3eb77f48dfe28ef6a51606b64665 /lib/mix/tasks | |
parent | 7ecc201029a8c90cf5dc3313ff78d56eb0a2445c (diff) | |
parent | 3dadaa4432b442d75b0ac0425aa05527d52f0e7a (diff) | |
download | pleroma-c708656b5e4dd0a7c7f9ec5fb0116f542a85e309.tar.gz |
Merge branch 'robotstxt' into 'develop'
Add robots.txt
Closes #723
See merge request pleroma/pleroma!929
Diffstat (limited to 'lib/mix/tasks')
-rw-r--r-- | lib/mix/tasks/pleroma/robotstxt.ex | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/mix/tasks/pleroma/robotstxt.ex b/lib/mix/tasks/pleroma/robotstxt.ex new file mode 100644 index 000000000..2128e1cd6 --- /dev/null +++ b/lib/mix/tasks/pleroma/robotstxt.ex @@ -0,0 +1,32 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2019 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Mix.Tasks.Pleroma.RobotsTxt do + use Mix.Task + + @shortdoc "Generate robots.txt" + @moduledoc """ + Generates robots.txt + + ## Overwrite robots.txt to disallow all + + mix pleroma.robots_txt disallow_all + + This will write a robots.txt that will hide all paths on your instance + from search engines and other robots that obey robots.txt + + """ + def run(["disallow_all"]) do + static_dir = Pleroma.Config.get([:instance, :static_dir], "instance/static/") + + if !File.exists?(static_dir) do + File.mkdir_p!(static_dir) + end + + robots_txt_path = Path.join(static_dir, "robots.txt") + robots_txt_content = "User-Agent: *\nDisallow: /\n" + + File.write!(robots_txt_path, robots_txt_content, [:write]) + end +end |