Skip to content

Commit

Permalink
fix: prefer highlight_language over language
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Clemens committed Jul 9, 2018
1 parent ffdf79e commit 90f1135
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion webserver/src/backend/pastes/logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl<'a> PastePayload<'a> {

let mut files = Vec::with_capacity(self.files.len());
for file in self.files {
let f = paste.create_file(conn, file.name, file.language, file.content)
let f = paste.create_file(conn, file.name, file.highlight_language, file.content)
.map_err(|e| CreateError::Internal(e.into()))?;
files.push(f);
}
Expand Down
2 changes: 1 addition & 1 deletion webserver/src/backend/pastes/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct PastePayload<'u> {

pub struct FilePayload {
pub name: Option<String>,
pub language: Option<Language>,
pub highlight_language: Option<Language>,
pub content: Content,
}

Expand Down
2 changes: 1 addition & 1 deletion webserver/src/models/paste/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl<'v> FromFormValue<'v> for Visibility {
#[derive(Debug, Serialize, Deserialize)]
pub struct PasteFile {
pub name: Option<CountedText>,
pub language: Option<Language>,
pub highlight_language: Option<Language>,
pub content: Content,
}

Expand Down
4 changes: 2 additions & 2 deletions webserver/src/models/paste/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Output {
pub struct OutputFile {
pub id: FileId,
pub name: Option<String>,
pub language: Option<&'static str>,
pub highlight_language: Option<&'static str>,
#[serde(skip_serializing_if = "Option::is_none")]
pub content: Option<Content>,
}
Expand All @@ -54,7 +54,7 @@ impl OutputFile {
OutputFile {
id,
name: name.map(Into::into),
language: language.map(|x| x.hljs()),
highlight_language: language.map(|x| x.hljs()),
content,
}
}
Expand Down
7 changes: 6 additions & 1 deletion webserver/src/routes/api/pastes/files/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ pub fn post(paste_id: PasteId, file: UpdateResult, user: RequiredUser, conn: DbC
return Ok(Status::show_error(status, kind));
}

let created = paste.create_file(&conn, file.name.map(|x| x.to_string()), file.language, file.content)?;
let created = paste.create_file(
&conn,
file.name.map(|x| x.to_string()),
file.highlight_language,
file.content
)?;

// commit
// TODO: more descriptive commit message
Expand Down
2 changes: 1 addition & 1 deletion webserver/src/routes/api/pastes/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn post(info: InfoResult, user: OptionalUser, conn: DbConn) -> RouteResult<Outpu
.into_iter()
.map(|f| FilePayload {
name: f.name.map(|x| x.into_inner()),
language: f.language,
highlight_language: f.highlight_language,
content: f.content,
})
.collect();
Expand Down
2 changes: 1 addition & 1 deletion webserver/src/routes/web/pastes/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn post(paste: Form<PasteUpload>, user: OptionalWebUser, mut sess: Session, conn
.into_iter()
.map(|f| FilePayload {
name: if f.name.is_empty() { None } else { Some(f.name) },
language: f.language,
highlight_language: f.language,
content: Content::Text(f.content),
})
.collect();
Expand Down

0 comments on commit 90f1135

Please sign in to comment.