summaryrefslogtreecommitdiff
path: root/lib/mix/tasks/pleroma/robots_txt.ex
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2020-11-12 12:34:48 +0000
committerrinpatch <rinpatch@sdf.org>2020-11-12 12:34:48 +0000
commit1172844ed18d94d84724dc6f11c6e9f72e0ba6ec (patch)
tree7d48a259e08856ab6db0eba255f20c0c19410463 /lib/mix/tasks/pleroma/robots_txt.ex
parenta0f5e8b27edbe2224d9c2c3997ad5b8ea484244b (diff)
parentb4c6b262d6dc12362f0014a864e8aed6c727c39c (diff)
Merge branch 'release/2.2.0' into 'stable'v2.2.0
Release/2.2.0 See merge request pleroma/secteam/pleroma!19
Diffstat (limited to 'lib/mix/tasks/pleroma/robots_txt.ex')
-rw-r--r--lib/mix/tasks/pleroma/robots_txt.ex33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/mix/tasks/pleroma/robots_txt.ex b/lib/mix/tasks/pleroma/robots_txt.ex
new file mode 100644
index 000000000..24f08180e
--- /dev/null
+++ b/lib/mix/tasks/pleroma/robots_txt.ex
@@ -0,0 +1,33 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 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
+ Mix.Pleroma.start_pleroma()
+ 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