logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

robots_txt.ex (928B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Mix.Tasks.Pleroma.RobotsTxt do
  5. use Mix.Task
  6. @shortdoc "Generate robots.txt"
  7. @moduledoc """
  8. Generates robots.txt
  9. ## Overwrite robots.txt to disallow all
  10. mix pleroma.robots_txt disallow_all
  11. This will write a robots.txt that will hide all paths on your instance
  12. from search engines and other robots that obey robots.txt
  13. """
  14. def run(["disallow_all"]) do
  15. Mix.Pleroma.start_pleroma()
  16. static_dir = Pleroma.Config.get([:instance, :static_dir], "instance/static/")
  17. if !File.exists?(static_dir) do
  18. File.mkdir_p!(static_dir)
  19. end
  20. robots_txt_path = Path.join(static_dir, "robots.txt")
  21. robots_txt_content = "User-Agent: *\nDisallow: /\n"
  22. File.write!(robots_txt_path, robots_txt_content, [:write])
  23. end
  24. end