-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2023 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package asciicast | ||
|
||
import ( | ||
"fmt" | ||
|
||
"code.gitea.io/gitea/modules/json" | ||
) | ||
|
||
type header struct { | ||
// Required header attributes: | ||
Version int `json:"version"` | ||
Width int `json:"width"` | ||
Height int `json:"height"` | ||
|
||
// Optional header attributes: | ||
Timestamp int `json:"timestamp"` | ||
Duration float64 `json:"duration"` | ||
IdleTimeLimit float64 `json:"idle_time_limit"` | ||
Command string `json:"command"` | ||
Title string `json:"title"` | ||
Env map[string]string `json:"env"` | ||
Theme string `json:"theme"` | ||
} | ||
|
||
func extractHeader(data []byte) (*header, error) { | ||
h := &header{} | ||
if err := json.Unmarshal(data, h); err != nil { | ||
return nil, fmt.Errorf("json unmarshal: %w", err) | ||
} | ||
if h.Version != 2 { | ||
return nil, fmt.Errorf("unknown version: %v", h.Version) | ||
} | ||
if h.Width <= 0 { | ||
return nil, fmt.Errorf("invalid width: %v", h.Width) | ||
} | ||
if h.Height <= 0 { | ||
return nil, fmt.Errorf("invalid height: %v", h.Height) | ||
} | ||
return h, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
.asciinema-player-container { | ||
width: 100%; | ||
height: 600px; | ||
} | ||
|
||
.asciinema-terminal { | ||
|