Umbraco.Community.GunsNPrices
0.1.0
dotnet add package Umbraco.Community.GunsNPrices --version 0.1.0
NuGet\Install-Package Umbraco.Community.GunsNPrices -Version 0.1.0
<PackageReference Include="Umbraco.Community.GunsNPrices" Version="0.1.0" />
<PackageVersion Include="Umbraco.Community.GunsNPrices" Version="0.1.0" />
<PackageReference Include="Umbraco.Community.GunsNPrices" />
paket add Umbraco.Community.GunsNPrices --version 0.1.0
#r "nuget: Umbraco.Community.GunsNPrices, 0.1.0"
#:package Umbraco.Community.GunsNPrices@0.1.0
#addin nuget:?package=Umbraco.Community.GunsNPrices&version=0.1.0
#tool nuget:?package=Umbraco.Community.GunsNPrices&version=0.1.0
GunsNPrices for Umbraco
Read firearm and ammunition product titles in Umbraco: brand, model, caliber, magazine capacity, barrel length, rounds per box and cost per round, for gun shops, ammo stores, ranges and review sites built on Umbraco.
@Html.GunsNPricesSpecs(Model.ProductTitle)
<dl class="gunsnprices-specs">
<dt>Brand</dt><dd>Glock</dd>
<dt>Model</dt><dd>Glock 19 Gen 5 MOS</dd>
<dt>Caliber</dt><dd>9×19mm Parabellum</dd>
<dt>Capacity</dt><dd>15 rounds</dd>
<dt>Barrel length</dt><dd>4.02 in</dd>
</dl>
It is built on GunsNPrices, the title parser behind gunsnprices.com, a price comparison site for 40+ US gun and ammo stores: 50 brands of model dictionaries ("G19 GEN5 MOS" is the Glock 19 Gen 5 MOS) and 293 calibers with the spellings stores use ("300 BLK", "6.5 CM", "12ga"). Server-side only: no backoffice UI, no database tables, no configuration needed to start.
Umbraco 17 (LTS) and 18, .NET 10.
Install
dotnet add package Umbraco.Community.GunsNPrices
The package registers itself (an IComposer); there is nothing to add to Program.cs.
Use it in views
Parse any property or the node name, wherever the title comes from:
@using Umbraco.Community.GunsNPrices
@{
var info = Model.ParseTitle("productTitle", brand: Model.Value<string>("brand"));
// or: var info = Model.ParseName();
}
@if (info?.Model != null)
{
<p>@info.Model.Model, @info.Caliber?.Name, @info.Capacity rounds</p>
}
@Html.GunsNPricesSpecs(info)
ParseTitle(alias, culture, brand, mpn, price)on anyIPublishedElement(content and blocks) parses the property value;ParseName(brand, mpn, price)onIPublishedContentparses the node name. Both returnnullwhen there is nothing to parse.@Html.GunsNPricesSpecs(result or title, linkCalibers: false, cssClass: "gunsnprices-specs")renders a<dl>with the rows that have a value (Brand, Model, Caliber(s), Capacity, Barrel length, Rounds per box, Cost per round). Everything is HTML-encoded. WithlinkCalibers: trueeach caliber links to its ammo price comparison page on gunsnprices.com.- The result is a
GunsNPrices.ParseResult:Kind,Brand,Model(Family,Model,Generation,Configs,Features),Caliber,Calibers,Capacity,BarrelLength,Rounds,CostPerRound.TitleParser.Parse(...)is available directly too.
Or convert the property itself
List the text properties that hold product titles in appsettings.json:
{
"GunsNPrices": {
"TitlePropertyAliases": [ "productTitle" ]
}
}
After a restart, those properties (Text box or Textarea editors only) return a ParseResult instead of a string. With
ModelsBuilder the generated property is typed accordingly:
@Model.ProductTitle?.Title @* the text the editor typed *@
@Model.ProductTitle?.Model?.Model @* "Glock 19 Gen 5 MOS" *@
@Html.GunsNPricesSpecs(Model.ProductTitle)
In the Delivery API (headless) the property becomes an object:
"productTitle": {
"title": "Glock 19 Gen 5 MOS 9mm 4.02in 15rd Pistol",
"kind": "firearm",
"brand": "Glock",
"family": "Glock 19",
"model": "Glock 19 Gen 5 MOS",
"calibers": [ { "id": "9x19mmparabellum", "name": "9×19mm Parabellum", "type": "handgun", "url": "https://gunsnprices.com/ammo/handgun-ammo/9-19mm-parabellum" } ],
"capacity": 15,
"barrelLength": 4.02,
"rounds": null
}
Only the listed aliases are converted; every other text property stays a string. Remove an alias to switch back.
Settings
| Key | Default | |
|---|---|---|
GunsNPrices:TitlePropertyAliases |
[] |
text box / textarea properties to convert to ParseResult |
GunsNPrices:WarmupOnStartup |
true |
load the parser data in the background at startup (about 0.4 s once), so the first page doesn't wait |
What it recognizes
| Field | Example in a title | Result |
|---|---|---|
| Firearm or ammo | ... 150gr ... 20rds |
Kind == ProductKind.Ammo |
| Brand and model (50 brands) | G19 Gen5 MOS, part number PA195S203 |
Glock 19 Gen 5 MOS |
| Calibers (293) | .357 Mag / .38 Spl, 6.5 CM, 12ga, 300 BLK |
.357 Magnum, .38 S&W Special, ... |
| Magazine capacity | 15+1, 17RD, 13rd/15rd, 10-shot |
15, 17, 15, 10 |
| Barrel length, inches | 4.02in, 16 1/2", 22 BBL, O/U 12/28 |
4.02, 16.5, 22, 28 |
| Rounds per box | 50/Box, Box of 20, 1,000 Rounds |
50, 20, 1000 |
| Cost per round | price 449.99 + 1000 Rounds |
0.45 |
Titles from US retailers, in English. More in the GunsNPrices package README.
License
The code is under the MIT License. The model and caliber data inside the GunsNPrices package are under CC BY 4.0: credit GunsNPrices (gunsnprices.com) with a link. Source: https://github.com/gunsnprices/gunsnprices-dotnet. Questions and missing models: app@gunsnprices.com.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- GunsNPrices (>= 0.1.0)
- Umbraco.Cms.Core (>= 17.0.0 && < 19.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0 | 48 | 11/11/2026 |