Ukůízečtext
Tento commit je obsažen v:
rodič
ec141bc69e
revize
72fd48d11e
@ -24,6 +24,7 @@ lazy_static! {
|
||||
pub static ref SPOILER_REGEX: Regex = Regex::new(r"\|\|([\s\S]+?)\|\|").unwrap();
|
||||
pub static ref URL_REGEX: Regex =
|
||||
Regex::new(r"https?\://[^\s<>\[\]{}|\\^]+").unwrap();
|
||||
pub static ref JANNYTEXT_REGEX: Regex = Regex::new(r"##(.+?)##").unwrap();
|
||||
}
|
||||
|
||||
pub fn parse_name(
|
||||
@ -106,6 +107,7 @@ fn capcode_fallback(owner: bool) -> String {
|
||||
|
||||
pub async fn markup(
|
||||
ctx: &Ctx,
|
||||
perms: &PermissionWrapper,
|
||||
board: Option<String>,
|
||||
op: Option<i64>,
|
||||
text: &str,
|
||||
@ -165,6 +167,12 @@ pub async fn markup(
|
||||
format!("<a rel=\"nofollow\" href=\"{url}\">{url}</a>")
|
||||
});
|
||||
|
||||
let text = if perms.owner() || perms.jannytext() {
|
||||
JANNYTEXT_REGEX.replace_all(&text, "<span class=\"jannytext\">$1</span>")
|
||||
} else {
|
||||
text
|
||||
};
|
||||
|
||||
Ok(text.to_string())
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ pub enum Permissions {
|
||||
BoardBanners,
|
||||
BoardConfig,
|
||||
News,
|
||||
Jannytext,
|
||||
BypassBans,
|
||||
BypassBoardLock,
|
||||
BypassThreadLock,
|
||||
@ -78,6 +79,10 @@ impl PermissionWrapper {
|
||||
self.0.contains(Permissions::News)
|
||||
}
|
||||
|
||||
pub fn jannytext(&self) -> bool {
|
||||
self.0.contains(Permissions::Jannytext)
|
||||
}
|
||||
|
||||
pub fn bypass_bans(&self) -> bool {
|
||||
self.0.contains(Permissions::BypassBans)
|
||||
}
|
||||
|
@ -174,6 +174,7 @@ pub async fn create_post(
|
||||
|
||||
let content = markup(
|
||||
&ctx,
|
||||
&perms,
|
||||
Some(board.id.clone()),
|
||||
thread.as_ref().map(|t| t.id),
|
||||
&content_nomarkup,
|
||||
|
@ -40,6 +40,7 @@ pub async fn edit_posts(
|
||||
let content_nomarkup = content_nomarkup.trim();
|
||||
let content = markup(
|
||||
&ctx,
|
||||
&tcx.perms,
|
||||
Some(post.board.clone()),
|
||||
post.thread,
|
||||
content_nomarkup,
|
||||
|
@ -17,7 +17,7 @@ use crate::{
|
||||
};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct JannyPostActionsForm {
|
||||
pub struct StaffPostActionsForm {
|
||||
#[serde(default)]
|
||||
pub posts: Vec<String>,
|
||||
#[serde(rename = "staff_remove_posts")]
|
||||
@ -40,7 +40,7 @@ pub struct JannyPostActionsForm {
|
||||
pub async fn staff_post_actions(
|
||||
ctx: Data<Ctx>,
|
||||
req: HttpRequest,
|
||||
QsForm(form): QsForm<JannyPostActionsForm>,
|
||||
QsForm(form): QsForm<StaffPostActionsForm>,
|
||||
) -> Result<HttpResponse, NekrochanError> {
|
||||
let tcx = TemplateCtx::new(&ctx, &req).await?;
|
||||
let account = account_from_auth(&ctx, &req).await?;
|
||||
@ -156,12 +156,12 @@ pub async fn staff_post_actions(
|
||||
Ban::create(&ctx, account, board, ip_range, reason, appealable, expires).await?;
|
||||
|
||||
let content_nomarkup = format!(
|
||||
"{}\n\n==(UŽIVATEL BYL ZA TENTO PŘÍSPĚVEK ZABANOVÁN)==",
|
||||
"{}\n\n##(UŽIVATEL BYL ZA TENTO PŘÍSPĚVEK ZABANOVÁN)##",
|
||||
post.content_nomarkup
|
||||
);
|
||||
|
||||
let content = format!(
|
||||
"{}\n\n<span class=\"redtext\">(UŽIVATEL BYL ZA TENTO PŘÍSPĚVEK ZABANOVÁN)</span>",
|
||||
"{}\n\n<span class=\"jannytext\">(UŽIVATEL BYL ZA TENTO PŘÍSPĚVEK ZABANOVÁN)</span>",
|
||||
post.content
|
||||
);
|
||||
|
||||
|
@ -36,7 +36,7 @@ pub async fn create_news(
|
||||
}
|
||||
|
||||
let content_nomarkup = content;
|
||||
let content = markup(&ctx, None, None, &content_nomarkup).await?;
|
||||
let content = markup(&ctx, &account.perms(), None, None, &content_nomarkup).await?;
|
||||
|
||||
NewsPost::create(&ctx, title, content, content_nomarkup, account.username).await?;
|
||||
|
||||
|
@ -52,7 +52,7 @@ pub async fn edit_news(
|
||||
}
|
||||
|
||||
let content_nomarkup = content_nomarkup.trim();
|
||||
let content = markup(&ctx, None, None, content_nomarkup).await?;
|
||||
let content = markup(&ctx, &tcx.perms, None, None, content_nomarkup).await?;
|
||||
|
||||
newspost
|
||||
.update(&ctx, content, content_nomarkup.into())
|
||||
|
@ -19,6 +19,7 @@ pub struct UpdatePermissionsForm {
|
||||
bans: Option<String>,
|
||||
banners: Option<String>,
|
||||
news: Option<String>,
|
||||
jannytext: Option<String>,
|
||||
board_config: Option<String>,
|
||||
bypass_bans: Option<String>,
|
||||
bypass_board_lock: Option<String>,
|
||||
@ -86,6 +87,10 @@ pub async fn update_permissions(
|
||||
permissions |= Permissions::News;
|
||||
}
|
||||
|
||||
if form.jannytext.is_some() {
|
||||
permissions |= Permissions::Jannytext;
|
||||
}
|
||||
|
||||
if form.bypass_bans.is_some() {
|
||||
permissions |= Permissions::BypassBans;
|
||||
}
|
||||
|
@ -426,6 +426,11 @@ summary {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.jannytext {
|
||||
color: var(--jannytext-color);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.icon {
|
||||
height: 1em;
|
||||
vertical-align: text-top;
|
||||
|
@ -36,4 +36,5 @@
|
||||
--bluetext-color: #0000ff;
|
||||
--uh-oh-color: #ffffff;
|
||||
--uh-oh-text: #0038b8;
|
||||
--jannytext-color: #ff0000;
|
||||
}
|
||||
|
@ -36,4 +36,5 @@
|
||||
--bluetext-color: #0000ff;
|
||||
--uh-oh-color: #ffffff;
|
||||
--uh-oh-text: #0038b8;
|
||||
--jannytext-color: #ff0000;
|
||||
}
|
||||
|
@ -106,6 +106,15 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="label">Uklízečtext (pravý redtext)</td>
|
||||
<td>
|
||||
<div class="input-wrapper">
|
||||
<input name="jannytext" type="checkbox"{% if account.perms().jannytext() %} checked="checked"{% endif %}{% if !tcx.perms.owner() %} disabled=""{% endif %}>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="label">Obejít ban</td>
|
||||
<td>
|
||||
|
Načítá se…
Odkázat v novém úkolu
Zablokovat Uživatele