Fix clippy with one/five lines

This commit is contained in:
href 2019-01-24 16:15:13 +01:00
parent be43aa2875
commit a3ba72d978
No known key found for this signature in database
GPG Key ID: EE8296C1A152C325
2 changed files with 17 additions and 4 deletions

View File

@ -25,7 +25,7 @@ def tips() do
"Pleroma can federate to the Dark Web!\n "Pleroma can federate to the Dark Web!\n
- Tor: https://git.pleroma.social/pleroma/pleroma/wikis/Easy%20Onion%20Federation%20(Tor) - Tor: https://git.pleroma.social/pleroma/pleroma/wikis/Easy%20Onion%20Federation%20(Tor)
- i2p: https://git.pleroma.social/pleroma/pleroma/wikis/I2p%20federation", - i2p: https://git.pleroma.social/pleroma/pleroma/wikis/I2p%20federation",
"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", "Lists of Pleroma instances:\n\n- http://distsn.org/pleroma-instances.html\n- https://fediverse.network/pleroma\n- https://the-federation.info/pleroma",
"Pleroma uses the LitePub protocol - https://litepub.social", "Pleroma uses the LitePub protocol - https://litepub.social",
"To receive more federated posts, subscribe to relays!\n "To receive more federated posts, subscribe to relays!\n
- How-to: https://git.pleroma.social/pleroma/pleroma/wikis/Admin%20tasks#relay-managment - How-to: https://git.pleroma.social/pleroma/pleroma/wikis/Admin%20tasks#relay-managment
@ -90,6 +90,17 @@ def puts(text_or_lines) do
noclippy_line: noclippy_line noclippy_line: noclippy_line
} }
# surrond one/five line clippy with blank lines around to not fuck up the layout
#
# yes this fix sucks but it's good enough, have you ever seen a release of windows wihtout some butched
# features anyway?
lines =
if length(lines) == 1 or length(lines) == 5 do
[""] ++ lines ++ [""]
else
lines
end
clippy_line(lines, clippy_lines, env) clippy_line(lines, clippy_lines, env)
rescue rescue
e -> e ->

View File

@ -70,16 +70,18 @@ def change do
""" """
end end
flush()
stop_clippy_heartbeats(clippy) stop_clippy_heartbeats(clippy)
end end
defp start_clippy_heartbeats() do defp start_clippy_heartbeats() do
count = from(a in "activities", select: count(a.id)) |> Repo.one! count = from(a in "activities", select: count(a.id)) |> Repo.one!
pid = if count > 5000 do if count > 5000 do
heartbeat_interval = :timer.minutes(2) + :timer.seconds(30) heartbeat_interval = :timer.minutes(2) + :timer.seconds(30)
all_tips = Clippy.tips() ++ [ all_tips = Clippy.tips() ++ [
"The migration is still running, maybe it's time for another tea?", "The migration is still running, maybe it's time for another tea?",
"Happy rabbits practice a cute behavior known as a\n“binky:” they jump up in the air\nand twist\nand spin around!", "Happy rabbits practice a cute behavior known as a\n“binky:” they jump up in the air\nand twist\nand spin around!",
"Nothing and everything.\n\nI still work.", "Nothing and everything.\n\nI still work.",
"Pleroma runs on a Raspberry Pi!\n\n … but this migration will take forever if you\nactually run on a raspberry pi", "Pleroma runs on a Raspberry Pi!\n\n … but this migration will take forever if you\nactually run on a raspberry pi",
@ -104,7 +106,7 @@ defp start_clippy_heartbeats() do
[:red, :bright, "It looks like you are running an older instance!"], [:red, :bright, "It looks like you are running an older instance!"],
[""], [""],
[:bright, "This migration may take a long time", :reset, " -- so you probably should"], [:bright, "This migration may take a long time", :reset, " -- so you probably should"],
["go drink a coffee, or a tea, or a beer, a whiskey, a vodka,"], ["go drink a cofe, or a tea, or a beer, a whiskey, a vodka,"],
["while it runs to deal with your temporary fediverse pause!"] ["while it runs to deal with your temporary fediverse pause!"]
] ]
:timer.sleep(heartbeat_interval) :timer.sleep(heartbeat_interval)