Skip to content

Commit

Permalink
Initial version (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger authored Feb 12, 2024
1 parent 42552fc commit c234e33
Show file tree
Hide file tree
Showing 37 changed files with 1,013 additions and 3 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"cake.tool": {
"version": "1.3.0",
"commands": [
"dotnet-cake"
]
}
}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.png filter=lfs diff=lfs merge=lfs -text
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These owners will be the default owners for everything in the repo and
# will be requested for review when someone opens a pull request.
* @swissgrc/development
6 changes: 6 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"github>swissgrc/renovate-presets:cake-recipe"
]
}
66 changes: 66 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build

on:
push:
branches:
- main
- develop
- "release/**"
- "hotfix/**"
tags:
- "*"
paths-ignore:
- "README.md"
pull_request:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ windows-2022, ubuntu-22.04, macos-12 ]

env:
GITHUB_PAT: ${{ secrets.GH_TOKEN }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
NUGET_SOURCE: "https://api.nuget.org/v3/index.json"

steps:
- name: Checkout the repository
uses: actions/[email protected]
- name: Fetch all tags and branches
run: git fetch --prune --unshallow
- uses: actions/[email protected]
with:
# GitVersion needs 5.0
dotnet-version: |
5.0
6.0
7.0
8.0
- name: Cache Tools
uses: actions/[email protected]
with:
path: tools
key: ${{ runner.os }}-tools-${{ hashFiles('recipe.cake') }}
- name: Build project
uses: cake-build/[email protected]
with:
script-path: recipe.cake
target: CI
cake-version: 1.3.0
- name: Upload Issues
uses: actions/[email protected]
with:
if-no-files-found: warn
name: ${{ matrix.os }} Issues
path: |
BuildArtifacts/report.html
BuildArtifacts/**/coverlet/*.xml
- name: Upload Packages
uses: actions/[email protected]
if: runner.os == 'Windows'
with:
if-no-files-found: warn
name: package
path: BuildArtifacts/Packages/**/*
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ __pycache__/
*.pyc

# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
tools/**
!tools/packages.config

# Tabs Studio
*.tss
Expand Down Expand Up @@ -396,3 +396,7 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml

# Project specific

BuildArtifacts/
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dotnet.defaultSolution": "src\\Statiq.Alerts.sln"
}
174 changes: 173 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,174 @@
# Statiq.Alerts
📙 Extension for Statiq site generator to add annotations

[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/swissgrc/Statiq.Alerts/blob/main/LICENSE)
[![Build](https://img.shields.io/github/actions/workflow/status/swissgrc/Statiq.Alerts/build.yml?branch=develop&style=flat-square)](https://github.com/swissgrc/Statiq.Alerts/actions/workflows/build.yml)
[![Downloads](https://img.shields.io/nuget/dt/Statiq.Alerts?style=flat-square)](https://www.nuget.org/packages/Statiq.Alerts)

Extension for [Statiq site generator] to add alerts.

## Table of Contents

<!-- - [Security](#security)
- [Background](#background) -->
- [Install](#install)
- [Usage](#usage)
- [API](#api)
- [Contributing](#contributing)
- [License](#license)

## Install

1. Add the `Statiq.Alerts` NuGet package to the Statiq project
2. Call `.AddAlertShortCodes()` on the bootstrapper

### Requirements

The extension requires that [Bootstrap] and [FontAwesome] are loaded by the Statiq theme.

## Usage

See [Using Shortcodes] for detailed instructions how to use shortcodes in Statiq.

### Tip

```markdown
<?# Tip ?>
This is a tip
<?#/ Tip ?>
```

Shows a tip alert:

![Tip alert](docs/tip.png)

### Info

```markdown
<?# Info ?>
This is an info message
<?#/ Info ?>
```

Shows an info message:

![Info alert](docs/info.png)

### Note

```markdown
<?# Note ?>
This is a note
<?#/ Note ?>
```

Shows a note:

![Note alert](docs/note.png)

### Warning

```markdown
<?# Warning ?>
This is a warning
<?#/ Warning ?>
```

Shows a warning:

![Warning alert](docs/warning.png)

### Important

```markdown
<?# Important ?>
This is an important message
<?#/ Important ?>
```

Shows an important message:

![Important alert](docs/important.png)

## API

### Custom Shortcuts

Additional custom shortcuts can be implemented by inheriting from the `AlertShortcode` class and
define the `DefaultAlertClass`, `DefaultAlertIcon` and `DefaultAlertTitle` properties.
See [Parameters](#Parameters) for documentation about possible values.

### Parameters

The following parameters are available on all shortcuts and allow to override the default styling.

#### Class

The `Class` parameter allows to override the CSS class of the alert `div` element:

```markdown
<?# Note Class="alert-secondary"?>
This is a note rendered in the secondary color
<?#/ Note ?>
```

The `alert` class will always be set.

#### Icon

##### Changing the icon

The `Icon` parameters allows to override the icon of the alert:

```markdown
<?# Note Title="fa-check"?>
This is a note with a different icon
<?#/ Note ?>
```

Any [Fontawesome] icon can be used.
The `fa-solid` class will always be set.

##### Removing the icon

To remove the icon the `Icon` parameter can be set to an empty string:

```markdown
<?# Note Iocn=""?>
This is a note without an icon
<?#/ Note ?>
```

#### Title

##### Changing the title

The `Title` parameters allows to override the title of the alert:

```markdown
<?# Note Title="Custom Title"?>
This is a note with a custom title
<?#/ Note ?>
```

##### Removing the title

To remove the title the `Title` parameter can be set to an empty string:

```markdown
<?# Note Title=""?>
This is a note without a title
<?#/ Note ?>
```

## Contributing

We accept Pull Requests

## License

[MIT © Swiss GRC AG](LICENSE)

[Statiq site generator]: https://www.statiq.dev/
[Bootstrap]: https://getbootstrap.com/
[FontAwesome]: https://fontawesome.com/
[Using Shortcodes]: https://www.statiq.dev/guide/content-and-data/shortcodes#using-shortcodes
13 changes: 13 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$SCRIPT_NAME = "recipe.cake"

Write-Host "Restoring .NET Core tools"
dotnet tool restore
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

Write-Host "Bootstrapping Cake"
dotnet cake $SCRIPT_NAME --bootstrap
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

Write-Host "Running Build"
dotnet cake $SCRIPT_NAME @args
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
11 changes: 11 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
SCRIPT_NAME="recipe.cake"

echo "Restoring .NET Core tools"
dotnet tool restore

echo "Bootstrapping Cake"
dotnet cake $SCRIPT_NAME --bootstrap

echo "Running Build"
dotnet cake $SCRIPT_NAME "$@"
3 changes: 3 additions & 0 deletions docs/important.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/note.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/tip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sdk": {
"allowPrerelease": true,
"version": "8.0.100",
"rollForward": "latestFeature"
}
}
22 changes: 22 additions & 0 deletions recipe.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#load nuget:?package=Cake.Recipe&version=3.1.1

Environment.SetVariableNames();

BuildParameters.SetParameters(
context: Context,
buildSystem: BuildSystem,
sourceDirectoryPath: "./src",
title: "Statiq.Alerts",
masterBranchName: "main",
repositoryOwner: "swissgrc",
repositoryName: "Statiq.Alerts",
shouldRunDotNetCorePack: true,
shouldUseDeterministicBuilds: true,
preferredBuildProviderType: BuildProviderType.GitHubActions,
preferredBuildAgentOperatingSystem: PlatformFamily.Linux);

BuildParameters.PrintParameters(Context);

ToolSettings.SetToolSettings(context: Context);

Build.RunDotNetCore();
5 changes: 5 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
</PropertyGroup>
</Project>
Loading

0 comments on commit c234e33

Please sign in to comment.