1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Clippy do
7 # No software is complete until they have a Clippy implementation.
8 # A ballmer peak _may_ be required to change this module.
17 host = Pleroma.Config.get([Pleroma.Web.Endpoint, :url, :host])
20 "“πλήρωμα” is “pleroma” in greek",
21 "For an extended Pleroma Clippy Experience, use the “Redmond” themes in Pleroma FE settings",
22 "Staff accounts and MRF policies of Pleroma instances are disclosed on the NodeInfo endpoints for easy transparency!\n
23 - https://catgirl.science/misc/nodeinfo.lua?#{host}
24 - https://fediverse.network/#{host}/federation",
25 "Pleroma can federate to the Dark Web!\n
26 - Tor: https://git.pleroma.social/pleroma/pleroma/wikis/Easy%20Onion%20Federation%20(Tor)
27 - i2p: https://git.pleroma.social/pleroma/pleroma/wikis/I2p%20federation",
28 "Lists of Pleroma instances are available at:\n\n- http://distsn.org/pleroma-instances.html\n- https://fediverse.network/pleroma\n- https://the-federation.info/pleroma",
29 "Pleroma uses the LitePub protocol - https://litepub.social",
30 "To receive more federated posts, subscribe to relays!\n
31 - How-to: https://git.pleroma.social/pleroma/pleroma/wikis/Admin%20tasks#relay-managment
32 - Relays: https://fediverse.network/activityrelay"
36 @spec puts(String.t() | [[IO.ANSI.ansicode() | String.t(), ...], ...]) :: nil
37 def puts(text_or_lines) do
41 if is_binary(text_or_lines) do
42 String.split(text_or_lines, ~r/\n/)
49 |> Enum.map(&charlist_count_text/1)
53 pad_text = longest_line_size
56 for(_ <- 1..pad_text, do: "_")
60 for(_ <- 1..pad_text, do: " ")
66 " / \\#{spaces} _#{pad}___",
67 " | |#{spaces} / #{pad_spaces} \\"
75 " #{bright()}@ @#{reset()}#{spaces} ",
87 pad_spaces: pad_spaces,
90 noclippy_line: noclippy_line
93 clippy_line(lines, clippy_lines, env)
96 IO.puts("(Clippy crashed, sorry: #{inspect(e)})")
97 IO.puts(text_or_lines)
100 defp clippy_line([line | lines], [prefix | clippy_lines], env) do
101 IO.puts([prefix <> "| ", rpad_line(line, env.max_size)])
102 clippy_line(lines, clippy_lines, env)
105 # more text lines but clippy's complete
106 defp clippy_line([line | lines], [], env) do
107 IO.puts([env.noclippy_line, "| ", rpad_line(line, env.max_size)])
110 IO.puts(env.noclippy_line <> "\\_#{env.pad}___/")
113 clippy_line(lines, [], env)
116 # no more text lines but clippy's not complete
117 defp clippy_line([], [clippy | clippy_lines], env) do
119 IO.puts(clippy <> "\\_#{env.pad}___/")
120 clippy_line([], clippy_lines, %{env | pad: nil})
123 clippy_line([], clippy_lines, env)
127 defp clippy_line(_, _, _) do
130 defp rpad_line(line, max) do
131 pad = max - (charlist_count_text(line) - 2)
132 pads = Enum.join(for(_ <- 1..pad, do: " "))
133 [IO.ANSI.format(line), pads <> " |"]
136 defp charlist_count_text(line) do
138 text = Enum.join(Enum.filter(line, &is_binary/1))