From 6f32eca2e85aaba0b5aa0c42361b774865e794e2 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 28 Sep 2022 11:26:37 +0200 Subject: [PATCH 1/4] fix snappy quote --- snappy_rDrama.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snappy_rDrama.txt b/snappy_rDrama.txt index f5c7d91e5..af0b73bf3 100644 --- a/snappy_rDrama.txt +++ b/snappy_rDrama.txt @@ -1893,7 +1893,7 @@ I am a degree 6 Zoosexual, sexually and emotionally attracted to Tyrannosaurs an 没有共产党就没有新中国 Without the communist party there would be no new China 伟大领袖毛泽东 Great chairman Mao 台湾是中国 Taiwan is China 香港是中国 Hong Kong is China 新疆是中国 Xinjiang is China 西藏,内蒙古,澳门都是中国 Tibet, Inner Mongolia, Macau are all China 美国支持新疆恐怖分子和西藏独立运动 US funds terrorists in Xinjiang and Tibet 中国人权最好 China respects human rights 火墙保护中国人民免被中情局宣传假新闻洗脑 Firewall protects China 法轮功和李洪志是邪教叛徒 Falun Gong is traitorous 疫情控制最好 Best pandemic response 五千年的历史 伟大的中国共产党 毛泽东 邓小平 江泽民 胡锦涛 习近平 五十六个民族 为祖国骄傲 Falun Gong burns themselves alive thinking it'll bring them to heaven 解放军保护天安门 PLA protected tiananmen square 郑国恩是骗子 新疆棉花质量最好 Xinjiang cotton is best quality 新疆机械化摘棉花 Xinjiang machine picks cotton 三峡大闸 长城 故宫 五星红旗 高铁 磁悬浮 High speed rail 中国特色社会主义 Socialism with Chinese Characteristics 繁荣富强 脱贫 1 billion lifted out of poverty 发展 航天 量子计算机 Quantum computing 中国制造 Made in China 黄之锋是美国的狗 Joshua Wong is US dog 无比坚强的人民共和国在世界东方巍然屹立 Superpower motherland 伟大的中华人民共和国,中国共产党,中国人民万岁,为实现中华民族伟大复兴的中国梦而努力奋斗 {[para]} 🇨🇳 MESSAGE FROM THE MINISTRY OF STATE 🇨🇳 -(我们的) 60 Social Credits have been removed from your account! Bad work citizen, Do not publicly disclose your opinion which can make our holy state look bad. Glory to the Chinese Communist Party! +(我们的) 60 Social Credits have been removed from your account! {[para]} 🎵 Yooouuuu've Beeeeeen From 8061723a985e97388ad5824febdf6d1c6adfa382 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 28 Sep 2022 12:06:23 +0200 Subject: [PATCH 2/4] remove hand pointer from exile symbol --- files/templates/comments.html | 2 +- files/templates/submission.html | 2 +- files/templates/submission_listing.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/files/templates/comments.html b/files/templates/comments.html index 8100014e5..dfd050576 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -131,7 +131,7 @@ {% if c.post %} {% set sub = c.post.sub %} {% if sub and c.author.exiled_from(sub) %} - + {% endif %} {% endif %} diff --git a/files/templates/submission.html b/files/templates/submission.html index f9d7b1494..d53ad54c7 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -629,7 +629,7 @@ {% endif %} {% if p.sub and p.author.exiled_from(p.sub) %} - + {% endif %} {% if p.bannedfor %} diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 76254ac42..c7488e78c 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -122,7 +122,7 @@ {% endif %} {% if p.sub and p.author.exiled_from(p.sub) %} - + {% endif %} {% if p.bannedfor %} From 11f4ef060c34f75384ac6051c6fb8ce1095a32ec Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Thu, 29 Sep 2022 07:36:10 +0200 Subject: [PATCH 3/4] nitter shit --- files/classes/comment.py | 4 ++-- files/helpers/actions.py | 2 +- files/helpers/sanitize.py | 5 ++++- files/templates/settings_filters.html | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index 792379ec2..6fc308e99 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -23,8 +23,8 @@ def normalize_urls_runtime(body, v): if v.reddit != 'old.reddit.com': body = reddit_to_vreddit_regex.sub(rf'\1https://{v.reddit}/\2/', body) if v.nitter: - body = body.replace('https://twitter.com/', 'https://nitter.42l.fr/') - body = body.replace('https://nitter.42l.fr/i/', 'https://twitter.com/i/') + body = body.replace('https://twitter.com/', 'https://nitter.lacontrevoie.fr/') + body = body.replace('https://nitter.lacontrevoie.fr/i/', 'https://twitter.com/i/') if v.imginn: body = body.replace('https://instagram.com/', 'https://imginn.com/') diff --git a/files/helpers/actions.py b/files/helpers/actions.py index a59946aaa..86387561e 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -36,7 +36,7 @@ def archiveorg(url): def archive_url(url): gevent.spawn(archiveorg, url) if url.startswith('https://twitter.com/'): - url = url.replace('https://twitter.com/', 'https://nitter.42l.fr/') + url = url.replace('https://twitter.com/', 'https://nitter.lacontrevoie.fr/') gevent.spawn(archiveorg, url) if url.startswith('https://instagram.com/'): url = url.replace('https://instagram.com/', 'https://imginn.com/') diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 7052c53bf..d7eb4bd47 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -443,7 +443,10 @@ def normalize_url(url): .replace("https://streamable.com/", "https://streamable.com/e/") \ .replace("https://streamable.com/e/e/", "https://streamable.com/e/") \ .replace("https://search.marsey.cat/#", "https://camas.unddit.com/#") \ - .replace("https://imgur.com/", "https://i.imgur.com/") + .replace("https://imgur.com/", "https://i.imgur.com/") \ + .replace("https://nitter.net/", "https://twitter.com/") \ + .replace("https://nitter.42l.fr/", "https://twitter.com/") \ + .replace("https://nitter.lacontrevoie.fr/", "https://twitter.com/") url = imgur_regex.sub(r'\1_d.webp?maxwidth=9999&fidelity=high', url) url = giphy_regex.sub(r'\1.webp', url) diff --git a/files/templates/settings_filters.html b/files/templates/settings_filters.html index 1338c5e55..f4eb5209d 100644 --- a/files/templates/settings_filters.html +++ b/files/templates/settings_filters.html @@ -185,7 +185,7 @@ - Enable if you would like to automatically convert twitter.com links to nitter.42l.fr links. + Enable if you would like to automatically convert twitter.com links to nitter.lacontrevoie.fr links. From d82a92f54d8c4c560c13be8b0c0b44a4dcdcac86 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Thu, 29 Sep 2022 07:53:08 +0200 Subject: [PATCH 4/4] prem version --- files/classes/hole_logs.py | 183 +++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 files/classes/hole_logs.py diff --git a/files/classes/hole_logs.py b/files/classes/hole_logs.py new file mode 100644 index 000000000..cfc09db72 --- /dev/null +++ b/files/classes/hole_logs.py @@ -0,0 +1,183 @@ +from sqlalchemy import * +from sqlalchemy.orm import relationship +from files.__main__ import Base +import time +from files.helpers.lazy import lazy +from files.helpers.const import * +from files.helpers.regex import censor_slurs + +class HoleAction(Base): + __tablename__ = "holeactions" + id = Column(Integer, primary_key=True) + user_id = Column(Integer, ForeignKey("users.id")) + kind = Column(String) + target_user_id = Column(Integer, ForeignKey("users.id")) + target_submission_id = Column(Integer, ForeignKey("submissions.id")) + _note=Column(String) + created_utc = Column(Integer) + + user = relationship("User", primaryjoin="User.id==HoleAction.user_id") + target_user = relationship("User", primaryjoin="User.id==HoleAction.target_user_id") + target_post = relationship("Submission") + + def __init__(self, *args, **kwargs): + if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time()) + super().__init__(*args, **kwargs) + + def __repr__(self): + return f"" + + @property + @lazy + def age_string(self): + + age = int(time.time()) - self.created_utc + + if age < 60: + return "just now" + elif age < 3600: + minutes = int(age / 60) + return f"{minutes}m ago" + elif age < 86400: + hours = int(age / 3600) + return f"{hours}hr ago" + elif age < 2678400: + days = int(age / 86400) + return f"{days}d ago" + + now = time.gmtime() + ctd = time.gmtime(self.created_utc) + + months = now.tm_mon - ctd.tm_mon + 12 * (now.tm_year - ctd.tm_year) + if now.tm_mday < ctd.tm_mday: + months -= 1 + + if months < 12: + return f"{months}mo ago" + else: + years = int(months / 12) + return f"{years}yr ago" + + @property + def note(self): + + if self.kind=="ban_user": + if self.target_post: return f'for post' + else: return self._note + else: + return self._note or "" + + @note.setter + def note(self, x): + self._note=x + + @property + @lazy + def string(self): + + output = ACTIONTYPES[self.kind]["str"].format(self=self, cc=CC_TITLE) + + if self.note: output += f" ({self.note})" + + return output + + @property + @lazy + def target_link(self): + if self.target_user: return f'{self.target_user.username}' + elif self.target_post: + if self.target_post.club: return f'{CC} ONLY' + return censor_slurs(f'{self.target_post.title_html}', None) + + @property + @lazy + def icon(self): + return ACTIONTYPES[self.kind]['icon'] + + @property + @lazy + def color(self): + return ACTIONTYPES[self.kind]['color'] + + @property + @lazy + def permalink(self): + return f"{SITE_FULL}/log/{self.id}" + +ACTIONTYPES = { + 'ban_user': { + "str": 'banned user {self.target_link}', + "icon": 'fa-user-slash', + "color": 'bg-danger' + }, + 'unban_user': { + "str": 'unbanned user {self.target_link}', + "icon": 'fa-user', + "color": 'bg-success' + }, + 'make_admin': { + "str": 'made {self.target_link} admin', + "icon": 'fa-user-crown', + "color": 'bg-success' + }, + 'remove_admin': { + "str": 'removed {self.target_link} as admin', + "icon": 'fa-user-crown', + "color": 'bg-danger' + }, + 'ban_post': { + "str": 'removed post {self.target_link}', + "icon": 'fa-feather-alt', + "color": 'bg-danger' + }, + 'flair_post': { + "str": 'set a flair on {self.target_link}', + "icon": 'fa-tag', + "color": 'bg-primary' + }, + 'change_sidebar': { + "str": 'changed the sidebar', + "icon": 'fa-columns', + "color": 'bg-primary' + }, + 'change_css': { + "str": 'changed the css', + "icon": 'fa-columns', + "color": 'bg-primary' + }, + 'change_banner': { + "str": 'changed the banner', + "icon": 'fa-columns', + "color": 'bg-primary' + }, + 'change_sidebar_image': { + "str": 'changed the sidebar image', + "icon": 'fa-columns', + "color": 'bg-primary' + }, + 'change_marsey': { + "str": 'changed the hole marsey', + "icon": 'fa-columns', + "color": 'bg-primary' + }, + 'pin_post': { + "str": 'pinned post {self.target_link}', + "icon": 'fa-thumbtack fa-rotate--45', + "color": 'bg-success' + }, + 'unpin_post': { + "str": 'un-pinned post {self.target_link}', + "icon": 'fa-thumbtack fa-rotate--45', + "color": 'bg-muted' + }, + 'enable_stealth': { + "str": 'changed the banner', + "icon": 'fa-columns', + "color": 'bg-primary' + }, + 'disable_stealth': { + "str": 'changed the banner', + "icon": 'fa-columns', + "color": 'bg-primary' + } +} \ No newline at end of file