Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gallery demo #575

Merged
merged 1 commit into from
Aug 8, 2023
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: swatinem/rust-cache@v1
- name: Run cargo test
run: |
cargo test --workspace
28 changes: 28 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ oranda-generate-css = { version = "0.3.0-prerelease.4", path = "generate-css" }
[dev-dependencies]
assert_cmd = "2"
assert_fs = "1.0.7"
insta = { version = "1.31.0", features = ["filters"] }
glob = "0.3.1"

[build-dependencies]
oranda-generate-css = { version = "0.3.0-prerelease.4", path = "generate-css" }
Expand Down
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use oranda_generate_css::DEFAULT_CSS_OUTPUT_DIR;
use oranda_generate_css::default_css_output_dir;

fn main() {
// Build the CSS on-demand if we're running a release-ish build here (as determined by Cargo)
Expand All @@ -10,6 +10,6 @@ fn main() {
.build()
.expect("Initializing tokio runtime failed");
let _guard = runtime.enter();
oranda_generate_css::build_css(DEFAULT_CSS_OUTPUT_DIR).unwrap();
oranda_generate_css::build_css(&default_css_output_dir()).unwrap();
}
}
29 changes: 19 additions & 10 deletions generate-css/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,26 @@ extern crate thiserror;

use crate::errors::Result;
use axoasset::LocalAsset;
use camino::Utf8PathBuf;
use camino::{Utf8Path, Utf8PathBuf};
use directories::ProjectDirs;
use std::env;
use std::io::Write;
use std::process::Command;

const CSS_SRC_PATH: &str = "oranda-css/css/main.css";
pub const DEFAULT_CSS_OUTPUT_DIR: &str = "oranda-css/dist";
const MANIFEST_PATH: &str = env!("CARGO_MANIFEST_DIR");
const CSS_SRC_PATH: &str = "../oranda-css/css/main.css";
const TAILWIND_SRC_PATH: &str = "../oranda-css/tailwind.config.js";
const DEFAULT_CSS_OUTPUT_DIR: &str = "../oranda-css/dist";

pub fn build_css(dist_dir: &str) -> Result<()> {
fn manifest_dir() -> &'static Utf8Path {
Utf8Path::new(MANIFEST_PATH)
}

pub fn default_css_output_dir() -> Utf8PathBuf {
manifest_dir().join(DEFAULT_CSS_OUTPUT_DIR)
}

pub fn build_css(dist_dir: &Utf8Path) -> Result<()> {
// Fetch our cache dir
let project_dir = ProjectDirs::from("dev", "axo", "oranda")
.expect("Unable to create cache dir for downloading Tailwind!");
Expand Down Expand Up @@ -62,18 +72,17 @@ pub fn build_css(dist_dir: &str) -> Result<()> {
}

tracing::info!("Building oranda CSS using Tailwind...");
let manifest_path =
std::env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is not set!");
let mut css_src_path = Utf8PathBuf::from(manifest_path);
css_src_path.push(CSS_SRC_PATH);
let css_src_path = manifest_dir().join(CSS_SRC_PATH);
let tailwind_config_path = manifest_dir().join(TAILWIND_SRC_PATH);
let output_path = dist_dir.join("oranda.css");
let output = Command::new(binary_path)
.args([
"-c",
"oranda-css/tailwind.config.js",
tailwind_config_path.as_str(),
"-i",
css_src_path.as_str(),
"-o",
&format!("{dist_dir}/oranda.css"),
output_path.as_str(),
"--minify",
])
.output()?;
Expand Down
7 changes: 4 additions & 3 deletions src/commands/print.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::Parser;
use oranda::errors::*;
use oranda_generate_css::DEFAULT_CSS_OUTPUT_DIR;
use oranda_generate_css::default_css_output_dir;

#[derive(Debug, Parser)]
pub struct ConfigSchema {}
Expand All @@ -20,8 +20,9 @@ pub struct GenerateCss {}

impl GenerateCss {
pub fn run(&self) -> Result<()> {
oranda_generate_css::build_css(DEFAULT_CSS_OUTPUT_DIR)?;
tracing::info!("CSS placed in {DEFAULT_CSS_OUTPUT_DIR}/oranda.css");
let out_dir = default_css_output_dir();
oranda_generate_css::build_css(&out_dir)?;
tracing::info!("CSS placed in {out_dir}/oranda.css");
Ok(())
}
}
4 changes: 2 additions & 2 deletions src/config/builds.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use indexmap::IndexMap;
use schemars::JsonSchema;
use serde::Deserialize;
use serde::{Deserialize, Serialize};

use super::{ApplyLayer, ApplyOptExt, ApplyValExt};

Expand All @@ -22,7 +22,7 @@ pub struct BuildConfig {
/// We use IndexMap to respect the order the user provided.
pub additional_pages: IndexMap<String, String>,
}
#[derive(Debug, Deserialize, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
/// Information about how the pages of your site should be built
pub struct BuildLayer {
Expand Down
4 changes: 2 additions & 2 deletions src/config/components/artifacts/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use schemars::JsonSchema;
use serde::Deserialize;
use serde::{Deserialize, Serialize};

use crate::config::{ApplyLayer, ApplyValExt};

Expand Down Expand Up @@ -43,7 +43,7 @@ pub struct ArtifactsConfig {
}

/// Setting for downloadable artifacts, installers, and package-managers
#[derive(Debug, Default, Deserialize, JsonSchema)]
#[derive(Debug, Default, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct ArtifactsLayer {
/// Whether to enable auto-detection of artifacts/installers in your Github Releases
Expand Down
4 changes: 2 additions & 2 deletions src/config/components/artifacts/package_managers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use indexmap::IndexMap;
use schemars::JsonSchema;
use serde::Deserialize;
use serde::{Deserialize, Serialize};

use crate::config::{ApplyLayer, ApplyValExt};

Expand All @@ -11,7 +11,7 @@ pub struct PackageManagersConfig {
pub additional: IndexMap<String, String>,
}
/// Package managers to display
#[derive(Debug, Deserialize, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct PackageManagersLayer {
/// Packages to display in both the install widget and install page
Expand Down
4 changes: 2 additions & 2 deletions src/config/components/funding.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use camino::Utf8PathBuf;
use schemars::JsonSchema;
use serde::Deserialize;
use serde::{Deserialize, Serialize};
use std::path::Path;

use crate::config::{ApplyLayer, ApplyOptExt};
Expand All @@ -15,7 +15,7 @@ pub struct FundingConfig {
pub md_path: Option<String>,
}
/// Settings for displaying funding information on your page
#[derive(Debug, Deserialize, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct FundingLayer {
/// A funding method to make larger/focused to encourage over all others
Expand Down
4 changes: 2 additions & 2 deletions src/config/components/mdbooks.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use schemars::JsonSchema;
use serde::Deserialize;
use serde::{Deserialize, Serialize};
use std::path::Path;

use crate::config::{ApplyLayer, ApplyOptExt, ApplyValExt};
Expand All @@ -17,7 +17,7 @@ pub struct MdBookConfig {
}

/// The config for building and embedding an mdbook on your site
#[derive(Debug, Default, Deserialize, JsonSchema)]
#[derive(Debug, Default, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct MdBookLayer {
/// Path to the mdbook (the directory containing book.toml)
Expand Down
4 changes: 2 additions & 2 deletions src/config/components/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use schemars::JsonSchema;
use serde::Deserialize;
use serde::{Deserialize, Serialize};

mod artifacts;
mod funding;
Expand Down Expand Up @@ -38,7 +38,7 @@ pub struct ComponentConfig {
pub artifacts: Option<ArtifactsConfig>,
}
/// Extra components
#[derive(Debug, Deserialize, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct ComponentLayer {
/// Whether to enable the changelog page
Expand Down
4 changes: 2 additions & 2 deletions src/config/marketing/analytics.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use schemars::JsonSchema;
use serde::Deserialize;
use serde::{Deserialize, Serialize};

use crate::site::layout::javascript::analytics::{Fathom, Google, Plausible, Umami};

/// Settings for Analytics
///
/// Analytics providers are currently mututally exclusive -- you can pick at most one.
#[derive(Debug, Deserialize, JsonSchema, Clone)]
#[derive(Debug, Serialize, Deserialize, JsonSchema, Clone)]
#[serde(rename_all = "lowercase")]
pub enum AnalyticsConfig {
/// Use Google Analytics
Expand Down
4 changes: 2 additions & 2 deletions src/config/marketing/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub use analytics::AnalyticsConfig;
use schemars::JsonSchema;
use serde::Deserialize;
use serde::{Deserialize, Serialize};
pub use social::{SocialConfig, SocialLayer};

use super::ApplyLayer;
Expand All @@ -17,7 +17,7 @@ pub struct MarketingConfig {
pub social: SocialConfig,
}
/// Settings for marketing/social/analytics
#[derive(Debug, Deserialize, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct MarketingLayer {
/// Settings for analytics
Expand Down
2 changes: 1 addition & 1 deletion src/config/marketing/social.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct SocialConfig {
pub twitter_account: Option<String>,
}
// Settings for social media integrations
#[derive(Debug, Deserialize, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct SocialLayer {
/// Image to show in link previews
Expand Down
7 changes: 3 additions & 4 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ use std::convert::identity;

use camino::Utf8PathBuf;
use schemars::JsonSchema;
use serde::Deserialize;
use serde::{Deserialize, Serialize};
use tracing::instrument;

use crate::errors::*;
Expand All @@ -103,9 +103,8 @@ pub use components::{
MdBookConfig, MdBookLayer, PackageManagersConfig, PackageManagersLayer,
};
pub use marketing::{AnalyticsConfig, MarketingConfig, MarketingLayer, SocialConfig, SocialLayer};
pub use workspace::{WorkspaceConfig, WorkspaceLayer};
pub use workspace::{WorkspaceConfig, WorkspaceLayer, WorkspaceMember};

use crate::config::workspace::WorkspaceMember;
pub use project::{ProjectConfig, ProjectLayer};
pub use style::{StyleConfig, StyleLayer};

Expand Down Expand Up @@ -393,7 +392,7 @@ impl<T> ApplyOptExt for Option<T> {
///
/// This allows us to have a simple yes/no version of a config while still
/// allowing for a more advanced version to exist.
#[derive(Deserialize, Debug, JsonSchema)]
#[derive(Serialize, Deserialize, Debug, JsonSchema)]
#[serde(untagged)]
pub enum BoolOr<T> {
/// They gave the simple bool
Expand Down
4 changes: 2 additions & 2 deletions src/config/oranda_config.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use axoasset::SourceFile;
use camino::Utf8PathBuf;
use schemars::JsonSchema;
use serde::Deserialize;
use serde::{Deserialize, Serialize};

use crate::errors::*;

use super::{BuildLayer, ComponentLayer, MarketingLayer, ProjectLayer, StyleLayer, WorkspaceLayer};

/// Configuration for `oranda` (typically stored in oranda.json)
#[derive(Debug, Deserialize, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct OrandaLayer {
/// Info about the project/application you're making a site for
Expand Down
4 changes: 2 additions & 2 deletions src/config/project.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use schemars::JsonSchema;
use serde::Deserialize;
use serde::{Deserialize, Serialize};

use super::{ApplyLayer, ApplyOptExt, ApplyValExt};

Expand Down Expand Up @@ -31,7 +31,7 @@ pub struct ProjectConfig {
///
/// All of these values should automatically be sourced from your Cargo.toml or package.json
/// whenever possible. You should only need to set these if you want to override the value.
#[derive(Debug, Deserialize, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct ProjectLayer {
/// Name of the project
Expand Down
4 changes: 2 additions & 2 deletions src/config/style.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use schemars::JsonSchema;
use serde::Deserialize;
use serde::{Deserialize, Serialize};

use crate::config::{ApplyLayer, ApplyOptExt};
use crate::site::{markdown::SyntaxTheme, oranda_theme::OrandaTheme};
Expand All @@ -19,7 +19,7 @@ pub struct StyleConfig {
pub favicon: Option<String>,
}
/// Settings for styling your page
#[derive(Debug, Deserialize, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct StyleLayer {
/// The builtin oranda theme to use for all your pages
Expand Down
2 changes: 1 addition & 1 deletion src/config/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;

#[derive(Debug, Deserialize, JsonSchema)]
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)]
/// Configuration regarding multi-project "workspaces".
pub struct WorkspaceLayer {
Expand Down
Loading
Loading