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 SPOILER_REGEX: Regex = Regex::new(r"\|\|([\s\S]+?)\|\|").unwrap();
|
||||||
pub static ref URL_REGEX: Regex =
|
pub static ref URL_REGEX: Regex =
|
||||||
Regex::new(r"https?\://[^\s<>\[\]{}|\\^]+").unwrap();
|
Regex::new(r"https?\://[^\s<>\[\]{}|\\^]+").unwrap();
|
||||||
|
pub static ref JANNYTEXT_REGEX: Regex = Regex::new(r"##(.+?)##").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_name(
|
pub fn parse_name(
|
||||||
@ -106,6 +107,7 @@ fn capcode_fallback(owner: bool) -> String {
|
|||||||
|
|
||||||
pub async fn markup(
|
pub async fn markup(
|
||||||
ctx: &Ctx,
|
ctx: &Ctx,
|
||||||
|
perms: &PermissionWrapper,
|
||||||
board: Option<String>,
|
board: Option<String>,
|
||||||
op: Option<i64>,
|
op: Option<i64>,
|
||||||
text: &str,
|
text: &str,
|
||||||
@ -165,6 +167,12 @@ pub async fn markup(
|
|||||||
format!("<a rel=\"nofollow\" href=\"{url}\">{url}</a>")
|
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())
|
Ok(text.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ pub enum Permissions {
|
|||||||
BoardBanners,
|
BoardBanners,
|
||||||
BoardConfig,
|
BoardConfig,
|
||||||
News,
|
News,
|
||||||
|
Jannytext,
|
||||||
BypassBans,
|
BypassBans,
|
||||||
BypassBoardLock,
|
BypassBoardLock,
|
||||||
BypassThreadLock,
|
BypassThreadLock,
|
||||||
@ -78,6 +79,10 @@ impl PermissionWrapper {
|
|||||||
self.0.contains(Permissions::News)
|
self.0.contains(Permissions::News)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn jannytext(&self) -> bool {
|
||||||
|
self.0.contains(Permissions::Jannytext)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn bypass_bans(&self) -> bool {
|
pub fn bypass_bans(&self) -> bool {
|
||||||
self.0.contains(Permissions::BypassBans)
|
self.0.contains(Permissions::BypassBans)
|
||||||
}
|
}
|
||||||
|
@ -174,6 +174,7 @@ pub async fn create_post(
|
|||||||
|
|
||||||
let content = markup(
|
let content = markup(
|
||||||
&ctx,
|
&ctx,
|
||||||
|
&perms,
|
||||||
Some(board.id.clone()),
|
Some(board.id.clone()),
|
||||||
thread.as_ref().map(|t| t.id),
|
thread.as_ref().map(|t| t.id),
|
||||||
&content_nomarkup,
|
&content_nomarkup,
|
||||||
|
@ -40,6 +40,7 @@ pub async fn edit_posts(
|
|||||||
let content_nomarkup = content_nomarkup.trim();
|
let content_nomarkup = content_nomarkup.trim();
|
||||||
let content = markup(
|
let content = markup(
|
||||||
&ctx,
|
&ctx,
|
||||||
|
&tcx.perms,
|
||||||
Some(post.board.clone()),
|
Some(post.board.clone()),
|
||||||
post.thread,
|
post.thread,
|
||||||
content_nomarkup,
|
content_nomarkup,
|
||||||
|
@ -17,7 +17,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct JannyPostActionsForm {
|
pub struct StaffPostActionsForm {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub posts: Vec<String>,
|
pub posts: Vec<String>,
|
||||||
#[serde(rename = "staff_remove_posts")]
|
#[serde(rename = "staff_remove_posts")]
|
||||||
@ -40,7 +40,7 @@ pub struct JannyPostActionsForm {
|
|||||||
pub async fn staff_post_actions(
|
pub async fn staff_post_actions(
|
||||||
ctx: Data<Ctx>,
|
ctx: Data<Ctx>,
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
QsForm(form): QsForm<JannyPostActionsForm>,
|
QsForm(form): QsForm<StaffPostActionsForm>,
|
||||||
) -> Result<HttpResponse, NekrochanError> {
|
) -> Result<HttpResponse, NekrochanError> {
|
||||||
let tcx = TemplateCtx::new(&ctx, &req).await?;
|
let tcx = TemplateCtx::new(&ctx, &req).await?;
|
||||||
let account = account_from_auth(&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?;
|
Ban::create(&ctx, account, board, ip_range, reason, appealable, expires).await?;
|
||||||
|
|
||||||
let content_nomarkup = format!(
|
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
|
post.content_nomarkup
|
||||||
);
|
);
|
||||||
|
|
||||||
let content = format!(
|
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
|
post.content
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ pub async fn create_news(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let content_nomarkup = content;
|
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?;
|
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_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
|
newspost
|
||||||
.update(&ctx, content, content_nomarkup.into())
|
.update(&ctx, content, content_nomarkup.into())
|
||||||
|
@ -19,6 +19,7 @@ pub struct UpdatePermissionsForm {
|
|||||||
bans: Option<String>,
|
bans: Option<String>,
|
||||||
banners: Option<String>,
|
banners: Option<String>,
|
||||||
news: Option<String>,
|
news: Option<String>,
|
||||||
|
jannytext: Option<String>,
|
||||||
board_config: Option<String>,
|
board_config: Option<String>,
|
||||||
bypass_bans: Option<String>,
|
bypass_bans: Option<String>,
|
||||||
bypass_board_lock: Option<String>,
|
bypass_board_lock: Option<String>,
|
||||||
@ -86,6 +87,10 @@ pub async fn update_permissions(
|
|||||||
permissions |= Permissions::News;
|
permissions |= Permissions::News;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if form.jannytext.is_some() {
|
||||||
|
permissions |= Permissions::Jannytext;
|
||||||
|
}
|
||||||
|
|
||||||
if form.bypass_bans.is_some() {
|
if form.bypass_bans.is_some() {
|
||||||
permissions |= Permissions::BypassBans;
|
permissions |= Permissions::BypassBans;
|
||||||
}
|
}
|
||||||
|
@ -426,6 +426,11 @@ summary {
|
|||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.jannytext {
|
||||||
|
color: var(--jannytext-color);
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
height: 1em;
|
height: 1em;
|
||||||
vertical-align: text-top;
|
vertical-align: text-top;
|
||||||
|
@ -36,4 +36,5 @@
|
|||||||
--bluetext-color: #0000ff;
|
--bluetext-color: #0000ff;
|
||||||
--uh-oh-color: #ffffff;
|
--uh-oh-color: #ffffff;
|
||||||
--uh-oh-text: #0038b8;
|
--uh-oh-text: #0038b8;
|
||||||
|
--jannytext-color: #ff0000;
|
||||||
}
|
}
|
||||||
|
@ -36,4 +36,5 @@
|
|||||||
--bluetext-color: #0000ff;
|
--bluetext-color: #0000ff;
|
||||||
--uh-oh-color: #ffffff;
|
--uh-oh-color: #ffffff;
|
||||||
--uh-oh-text: #0038b8;
|
--uh-oh-text: #0038b8;
|
||||||
|
--jannytext-color: #ff0000;
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,15 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</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>
|
<tr>
|
||||||
<td class="label">Obejít ban</td>
|
<td class="label">Obejít ban</td>
|
||||||
<td>
|
<td>
|
||||||
|
Načítá se…
Odkázat v novém úkolu
Zablokovat Uživatele