Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/target
public/
oranda-debug.log
# banish macos to the depths of hell
.DS_Store
.idea/
.oranda-cache

# oranda-css
oranda-css/dist
Expand All @@ -13,4 +13,4 @@ oranda-css/.pnp*
node_modules

# nix
result/
result/
1 change: 1 addition & 0 deletions oranda-css/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
@import "themes/axo.css";
@import "themes/hacker.css";
@import "themes/cupcake.css";
@import "themes/tui.css";
154 changes: 154 additions & 0 deletions oranda-css/css/themes/tui.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
@import url('https://unpkg.com/fixedsys-css/css/fixedsys.css');
@import url('https://fonts.googleapis.com/css2?family=Cutive+Mono&display=swap');

html.tui main {
max-width: 82%;
}

html.tui ::selection {
@apply text-axo-black;
background-color: white;

-webkit-text-fill-color: var(--color-axo-black);
}

html.tui body {
@apply bg-axo-black text-zinc-100;
font-family: "fixedsys", monospace;
}

html.tui strong,
html.tui code,
html.tui ul,
html.tui ul li,
html.tui pre {
@apply text-zinc-300;
font-family: "fixedsys", monospace;
}

html.tui ul li {
list-style-type: square;
}

html.tui .button {
@apply rounded-none;
box-shadow: 10px 10px 10px #000;
}

html.tui blockquote {
@apply bg-zinc-100 p-2 border-double border-axo-black border-8 mb-4;
box-shadow: 0 0 0 8px #f4f4f5;
}

html.tui blockquote p {
@apply text-axo-black p-0 m-0;
}

html.tui h2,
html.tui h3,
html.tui h4,
html.tui h5,
html.tui h6 {
@apply text-zinc-100;
text-transform: uppercase;
}

html.tui .repo_banner > a,
html.tui footer {
@apply text-zinc-100;
}

html.tui p,
html.tui table {
@apply text-zinc-100;
font-family: 'Cutive Mono', monospace;
}

html.tui p {
@apply pl-8;
}

html.tui .title {
@apply text-left text-zinc-100 relative inline-block ml-8;
}

@keyframes blink-animation {
to {
visibility: hidden;
}
}

html.tui .title:after {
content: "";
height: 70px;
animation: blink-animation 1s steps(5, start) infinite;
@apply block absolute left-full ml-3 w-4 top-3 bg-cyan-700;
}

html.tui .title::before {
content: "> ";
@apply block text-zinc-800 text-5xl absolute top-1/2 -translate-y-1/2 -left-8 mt-2;
}

html.tui div.table .th,
html.tui h1 {
@apply text-cyan-700;
}

html.tui a {
@apply text-cyan-700 hover:decoration-cyan-700 p-2;
}

html.tui a:focus,
html.tui .button.primary:focus {
@apply text-axo-black bg-zinc-100 p-2;
}

html.tui .detect {
@apply p-2;
}

html.tui .axo-gradient {
background: none;
}

html.tui .nav ul {
@apply justify-start;
}

html.tui .nav ul li {
list-style-type: none;
}

html.tui li.list-none {
list-style-type: none;
}

html.tui .button.primary {
@apply text-zinc-100 bg-cyan-700 hover:bg-zinc-100 hover:text-axo-black;
}

html.tui .artifact-header > h4,
html.tui .artifact-header>div:not(.install-code-wrapper) {
@apply text-left items-start justify-start;
}

html.tui .releases-nav ul li a {
@apply text-cyan-700;
}

html.hacker .releases-nav ul li:before {
@apply bg-gray-600;
}

html.hacker .releases-nav ul {
@apply border-l-gray-600;
}

html.hacker .prereleases-toggle input:checked {
@apply bg-orange-500;
}

html.hacker .releases-nav ul li a {
@apply hover:decoration-orange-500;
}
11 changes: 9 additions & 2 deletions src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,28 @@ pub struct Build {
project_root: Utf8PathBuf,
#[arg(long, default_value = "./oranda.json")]
config_path: Utf8PathBuf,
#[arg(long, short)]
cached: bool,
}

impl Build {
pub fn new(project_root: Option<Utf8PathBuf>, config_path: Option<Utf8PathBuf>) -> Self {
pub fn new(
project_root: Option<Utf8PathBuf>,
config_path: Option<Utf8PathBuf>,
cached: bool,
) -> Self {
Build {
project_root: project_root.unwrap_or(Utf8PathBuf::from("./")),
config_path: config_path.unwrap_or(Utf8PathBuf::from("./oranda.json")),
cached,
}
}

pub fn run(&self) -> Result<()> {
Message::new(MessageType::Info, "Running build...").print();
tracing::info!("Running build...");
let config = Config::build(&self.config_path)?;
Site::build(&config)?.write(&config)?;
Site::build(&config, self.cached)?.write(&config)?;
let msg = format!(
"Successfully built your site in the `{}` directory. To view, run `oranda serve`.",
{ config.dist_dir }
Expand Down
19 changes: 15 additions & 4 deletions src/commands/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ pub struct Dev {
/// List of extra paths to watch
#[arg(short, long)]
include_paths: Option<Vec<Utf8PathBuf>>,
#[arg(short, long)]
cached: bool,
}

impl Dev {
Expand Down Expand Up @@ -148,7 +150,12 @@ impl Dev {
.print();

if !self.no_first_build {
Build::new(self.project_root.clone(), self.config_path.clone()).run()?;
Build::new(
self.project_root.clone(),
self.config_path.clone(),
self.cached,
)
.run()?;
}

// Spawn the serve process out into a separate thread so that we can loop through received events on this thread
Expand Down Expand Up @@ -187,9 +194,13 @@ impl Dev {
)
.print();

Build::new(self.project_root.clone(), self.config_path.clone())
.run()
.unwrap();
Build::new(
self.project_root.clone(),
self.config_path.clone(),
self.cached,
)
.run()
.unwrap();
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/config/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ pub enum Theme {
AxoDark,
Hacker,
Cupcake,
Tui,
}

pub fn css_class(theme: &Theme) -> &'static str {
match theme {
Theme::Dark => "dark",
Theme::AxoLight => "axo",
Theme::AxoDark => "dark axo",
Theme::Tui => "tui",
Theme::Hacker => "hacker",
Theme::Cupcake => "cupcake",
_ => "light",
Expand Down
3 changes: 2 additions & 1 deletion src/data/cargo_dist.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use axoasset::{Asset, LocalAsset};
use camino::Utf8PathBuf;
pub use cargo_dist_schema::{Artifact, ArtifactKind, DistManifest, Release};
use serde::{Deserialize, Serialize};

use crate::config::Config;
use crate::data::github::GithubRelease;
use crate::errors::*;

pub const MANIFEST_FILENAME: &str = "dist-manifest.json";

#[derive(Clone, Debug)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct DistRelease {
pub manifest: DistManifest,
pub source: GithubRelease,
Expand Down
3 changes: 2 additions & 1 deletion src/data/github/repo.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::errors::*;

use miette::{miette, IntoDiagnostic};
use serde::{Deserialize, Serialize};
use url::Url;

/// Represents a GitHub repository that we can query things about.
#[derive(Debug, Clone)]
#[derive(Debug, Deserialize, Clone, Serialize)]
pub struct GithubRepo {
/// The repository owner.
pub owner: String,
Expand Down
22 changes: 20 additions & 2 deletions src/data/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use axoasset::LocalAsset;
use serde::{Deserialize, Serialize};

use crate::data::github::{GithubRelease, GithubRepo};
use crate::errors::*;
use crate::message::{Message, MessageType};
Expand All @@ -10,6 +13,7 @@ mod release;

pub use release::Release;

#[derive(Deserialize, Serialize)]
pub struct Context {
pub repo: GithubRepo,
pub releases: Vec<Release>,
Expand All @@ -22,12 +26,26 @@ impl Context {
let repo = GithubRepo::from_url(repo_url)?;
let (releases, has_prereleases, latest_dist_release) =
Self::fetch_all_releases(&repo, cargo_dist)?;
Ok(Self {
let context = Self {
repo,
releases,
has_prereleases,
latest_dist_release,
})
};
context.write_cache()?;
Ok(context)
}

fn write_cache(&self) -> Result<()> {
let context_cache = serde_json::to_string(self)?;
LocalAsset::write_new_all(&context_cache, "./.oranda-cache/context.json")?;
Ok(())
}

pub fn read_cache() -> Result<Self> {
let json = LocalAsset::load_string("./.oranda-cache/context.json")?;
let context: Context = serde_json::from_str(&json)?;
Ok(context)
}

#[allow(clippy::unnecessary_unwrap)]
Expand Down
3 changes: 2 additions & 1 deletion src/data/release.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use axoasset::SourceFile;
use cargo_dist_schema::DistManifest;
use serde::{Deserialize, Serialize};

use crate::data::{cargo_dist, github::GithubRelease, GithubRepo};
use crate::errors::*;

#[derive(Clone, Debug)]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Release {
pub manifest: Option<DistManifest>,
pub source: GithubRelease,
Expand Down
6 changes: 6 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ pub enum OrandaError {
#[diagnostic(help("Please make sure you give a valid path pointing to a css file."))]
InvalidOrandaCSSOverride { path: String },

#[error("Failed to read cached context.")]
CachedContextReadError {
#[source]
details: Box<OrandaError>,
},

#[error("Failed fetching releases from Github.")]
GithubReleasesFetchError {
#[source]
Expand Down
Loading