mirror of
https://github.com/kjanat/articulate-parser.git
synced 2026-01-16 12:22:08 +01:00
refactor: Align with Go conventions and improve maintainability
Renames the `OriginalUrl` field to `OriginalURL` across media models to adhere to Go's common initialisms convention. The `json` tag is unchanged to maintain API compatibility. Introduces constants for exporter formats (e.g., `FormatMarkdown`, `FormatDocx`) to eliminate the use of magic strings, enhancing type safety and making the code easier to maintain. Additionally, this commit includes several minor code quality improvements: - Wraps file-writing errors in exporters to provide more context. - Removes redundant package-level comments from test files. - Applies various minor linting fixes throughout the codebase.
This commit is contained in:
@ -1,5 +1,3 @@
|
||||
// Package models defines the data structures representing Articulate Rise courses.
|
||||
// These structures closely match the JSON format used by Articulate Rise.
|
||||
package models
|
||||
|
||||
// Lesson represents a single lesson or section within an Articulate Rise course.
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
// Package models defines the data structures representing Articulate Rise courses.
|
||||
// These structures closely match the JSON format used by Articulate Rise.
|
||||
package models
|
||||
|
||||
// Media represents a media element that can be either an image or a video.
|
||||
@ -23,8 +21,8 @@ type ImageMedia struct {
|
||||
Height int `json:"height,omitempty"`
|
||||
// CrushedKey is the identifier for a compressed version of the image
|
||||
CrushedKey string `json:"crushedKey,omitempty"`
|
||||
// OriginalUrl is the URL to the full-resolution image
|
||||
OriginalUrl string `json:"originalUrl"`
|
||||
// OriginalURL is the URL to the full-resolution image
|
||||
OriginalURL string `json:"originalUrl"`
|
||||
// UseCrushedKey indicates whether to use the compressed version
|
||||
UseCrushedKey bool `json:"useCrushedKey,omitempty"`
|
||||
}
|
||||
@ -45,6 +43,6 @@ type VideoMedia struct {
|
||||
InputKey string `json:"inputKey,omitempty"`
|
||||
// Thumbnail is the URL to a smaller preview image
|
||||
Thumbnail string `json:"thumbnail,omitempty"`
|
||||
// OriginalUrl is the URL to the source video file
|
||||
OriginalUrl string `json:"originalUrl"`
|
||||
// OriginalURL is the URL to the source video file
|
||||
OriginalURL string `json:"originalUrl"`
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// Package models_test provides tests for the data models.
|
||||
package models
|
||||
|
||||
import (
|
||||
@ -98,7 +97,7 @@ func TestCourseInfo_JSONMarshalUnmarshal(t *testing.T) {
|
||||
Type: "jpg",
|
||||
Width: 800,
|
||||
Height: 600,
|
||||
OriginalUrl: "https://example.com/image.jpg",
|
||||
OriginalURL: "https://example.com/image.jpg",
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -149,7 +148,7 @@ func TestLesson_JSONMarshalUnmarshal(t *testing.T) {
|
||||
URL: "https://example.com/video.mp4",
|
||||
Type: "mp4",
|
||||
Duration: 120,
|
||||
OriginalUrl: "https://example.com/video.mp4",
|
||||
OriginalURL: "https://example.com/video.mp4",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -244,7 +243,7 @@ func TestSubItem_JSONMarshalUnmarshal(t *testing.T) {
|
||||
Type: "png",
|
||||
Width: 400,
|
||||
Height: 300,
|
||||
OriginalUrl: "https://example.com/subitem.png",
|
||||
OriginalURL: "https://example.com/subitem.png",
|
||||
CrushedKey: "crushed-123",
|
||||
UseCrushedKey: true,
|
||||
},
|
||||
@ -305,7 +304,7 @@ func TestMedia_JSONMarshalUnmarshal(t *testing.T) {
|
||||
Type: "jpeg",
|
||||
Width: 1200,
|
||||
Height: 800,
|
||||
OriginalUrl: "https://example.com/media.jpg",
|
||||
OriginalURL: "https://example.com/media.jpg",
|
||||
CrushedKey: "crushed-media",
|
||||
UseCrushedKey: false,
|
||||
},
|
||||
@ -336,7 +335,7 @@ func TestMedia_JSONMarshalUnmarshal(t *testing.T) {
|
||||
Poster: "https://example.com/poster.jpg",
|
||||
Thumbnail: "https://example.com/thumb.jpg",
|
||||
InputKey: "input-123",
|
||||
OriginalUrl: "https://example.com/original.mp4",
|
||||
OriginalURL: "https://example.com/original.mp4",
|
||||
},
|
||||
}
|
||||
|
||||
@ -363,7 +362,7 @@ func TestImageMedia_JSONMarshalUnmarshal(t *testing.T) {
|
||||
Type: "gif",
|
||||
Width: 640,
|
||||
Height: 480,
|
||||
OriginalUrl: "https://example.com/image.gif",
|
||||
OriginalURL: "https://example.com/image.gif",
|
||||
CrushedKey: "crushed-gif",
|
||||
UseCrushedKey: true,
|
||||
}
|
||||
@ -397,7 +396,7 @@ func TestVideoMedia_JSONMarshalUnmarshal(t *testing.T) {
|
||||
Poster: "https://example.com/poster.jpg",
|
||||
Thumbnail: "https://example.com/thumbnail.jpg",
|
||||
InputKey: "upload-456",
|
||||
OriginalUrl: "https://example.com/original.webm",
|
||||
OriginalURL: "https://example.com/original.webm",
|
||||
}
|
||||
|
||||
// Marshal to JSON
|
||||
|
||||
Reference in New Issue
Block a user