mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Added git version tracking to file, and modified footer to load from that file (not the assembly)
This commit is contained in:
parent
fae5666599
commit
83801357be
1
.gitignore
vendored
1
.gitignore
vendored
@ -264,3 +264,4 @@ __pycache__/
|
||||
/Teknik/App_Data/Config.json
|
||||
/Teknik/appsettings.Production.json
|
||||
/Teknik/appsettings.Development.json
|
||||
/Teknik/App_Data/version.json
|
||||
|
@ -20,7 +20,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
||||
README.md = README.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Piwik", "Piwik\Piwik.csproj", "{F8823907-092C-4055-9F8E-D6756793C24A}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tracking", "Tracking\Tracking.csproj", "{F8823907-092C-4055-9F8E-D6756793C24A}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MailService", "MailService\MailService.csproj", "{03636C30-DA61-4307-8934-2FCC3BAC3255}"
|
||||
EndProject
|
||||
|
4
Teknik/App_Data/version.template.json
Normal file
4
Teknik/App_Data/version.template.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"version": "{{git_ver}}",
|
||||
"hash": "{{git_hash}}"
|
||||
}
|
@ -12,7 +12,7 @@ using Teknik.Controllers;
|
||||
using Teknik.Data;
|
||||
using Teknik.Filters;
|
||||
using Teknik.Logging;
|
||||
using Teknik.Piwik;
|
||||
using Teknik.Tracking;
|
||||
using Teknik.Utilities;
|
||||
|
||||
namespace Teknik.Areas.Stats.Controllers
|
||||
@ -179,7 +179,7 @@ namespace Teknik.Areas.Stats.Controllers
|
||||
|
||||
return Json(new { result = new { uniqueVisitors = uniqueData.ToArray(), totalVisitors = totalData.ToArray() } });
|
||||
}
|
||||
return Json(new { error = new { message = "Piwik not configured" } });
|
||||
return Json(new { error = new { message = "Tracking not configured" } });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Teknik.Configuration;
|
||||
using Teknik.Utilities;
|
||||
using Teknik.Piwik;
|
||||
using Teknik.Tracking;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
|
@ -8,7 +8,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Teknik.Configuration;
|
||||
using Teknik.Piwik;
|
||||
using Teknik.Tracking;
|
||||
using Teknik.Utilities;
|
||||
|
||||
namespace Teknik.Filters
|
||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Teknik.Configuration;
|
||||
using Teknik.Utilities;
|
||||
using Teknik.Piwik;
|
||||
using Teknik.Tracking;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
|
44
Teknik/TagHelpers/VersionHelper.cs
Normal file
44
Teknik/TagHelpers/VersionHelper.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Teknik.Utilities;
|
||||
|
||||
namespace Teknik.TagHelpers
|
||||
{
|
||||
[HtmlTargetElement("version")]
|
||||
public class VersionHelper : TagHelper
|
||||
{
|
||||
private const string _verFile = "version.json";
|
||||
|
||||
public string Source { get; set; }
|
||||
|
||||
public override void Process(TagHelperContext context, TagHelperOutput output)
|
||||
{
|
||||
// Clear the initial wrap tag
|
||||
output.TagName = string.Empty;
|
||||
|
||||
// Get the version file info
|
||||
string dataDir = (string)AppDomain.CurrentDomain.GetData("DataDirectory");
|
||||
string fullPath = Path.Combine(dataDir, _verFile);
|
||||
|
||||
if (File.Exists(fullPath))
|
||||
{
|
||||
using (StreamReader file = File.OpenText(fullPath))
|
||||
using (JsonTextReader reader = new JsonTextReader(file))
|
||||
{
|
||||
JObject res = (JObject)JToken.ReadFrom(reader);
|
||||
|
||||
string commitVer = res["version"].ToString();
|
||||
string commitHash = res["hash"].ToString();
|
||||
|
||||
output.Content.AppendHtml($"Version: {commitVer} - Hash: <a href=\"{Source}{commitHash}\">{commitHash.Truncate(10)}</a>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -77,7 +77,7 @@
|
||||
<ProjectReference Include="..\GitService\GitService.csproj" />
|
||||
<ProjectReference Include="..\Logging\Logging.csproj" />
|
||||
<ProjectReference Include="..\MailService\MailService.csproj" />
|
||||
<ProjectReference Include="..\Piwik\Piwik.csproj" />
|
||||
<ProjectReference Include="..\Tracking\Tracking.csproj" />
|
||||
<ProjectReference Include="..\Utilities\Utilities.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -108,4 +108,6 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions>
|
||||
|
||||
</Project>
|
||||
|
@ -1,5 +1,6 @@
|
||||
@using System.Diagnostics;
|
||||
@using System.Reflection;
|
||||
@using Newtonsoft;
|
||||
|
||||
<footer id="footer" class="footer navbar navbar-default">
|
||||
<div class="container">
|
||||
@ -26,27 +27,6 @@
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
@{
|
||||
Assembly assembly = Assembly.GetEntryAssembly();
|
||||
FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
|
||||
|
||||
string verNum = string.Empty;
|
||||
string commitVer = string.Empty;
|
||||
string commitHash = string.Empty;
|
||||
|
||||
if (!string.IsNullOrEmpty(fileVersionInfo.ProductVersion))
|
||||
{
|
||||
string[] fullVersion = fileVersionInfo.ProductVersion.Split('+');
|
||||
if (fullVersion.Count() > 1)
|
||||
{
|
||||
verNum = fullVersion[0];
|
||||
string commitStr = fullVersion[1];
|
||||
|
||||
commitVer = commitStr.Split('.')[0];
|
||||
commitHash = commitStr.Split('.').Last();
|
||||
}
|
||||
}
|
||||
}
|
||||
<div class="row">
|
||||
<div class="col-sm-5 col-sm-offset-1 text-left text-muted">
|
||||
© Teknik 2013-2018 | <a href="@Url.SubRouteUrl("faq", "FAQ.Index")">FAQ</a> | <a href="@Url.SubRouteUrl("privacy", "Privacy.Index")">Privacy</a> | <a href="@Url.SubRouteUrl("tos", "TOS.Index")">TOS</a> | <a href="@Url.SubRouteUrl("abuse", "Abuse.Index")">Abuse</a> | <a href="@Url.SubRouteUrl("stats", "Stats.Index")">Statistics</a>
|
||||
@ -59,7 +39,7 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-10 col-sm-offset-1 text-center text-muted">
|
||||
Version: @string.Format("{0}.{1}", verNum, commitVer) - Hash: <a href="http://git.teknik.io/Teknikode/Teknik/src/@commitHash">@commitHash.Truncate(10)</a>
|
||||
<version source="http://git.teknik.io/Teknikode/Teknik/src/"></version>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -7,6 +7,9 @@ var concat = require("gulp-concat");
|
||||
var cssmin = require("gulp-cssmin");
|
||||
var merge = require('merge-stream');
|
||||
var del = require("del");
|
||||
var replace = require("gulp-replace");
|
||||
var rename = require("gulp-rename");
|
||||
var git = require("git-rev-sync");
|
||||
|
||||
var uglifyes = require('uglify-es');
|
||||
var composer = require('gulp-uglify/composer');
|
||||
@ -71,7 +74,6 @@ gulp.task("clean", function (cb) {
|
||||
});
|
||||
|
||||
gulp.task('copy-assets', function () {
|
||||
|
||||
var streams = [];
|
||||
for (var asset in assets) {
|
||||
for (var item in assets[asset]) {
|
||||
@ -106,6 +108,14 @@ gulp.task("min:css", function () {
|
||||
return merge(tasks);
|
||||
});
|
||||
|
||||
gulp.task("update-version", function () {
|
||||
return gulp.src('./App_Data/version.template.json')
|
||||
.pipe(replace('{{git_ver}}', git.tag()))
|
||||
.pipe(replace('{{git_hash}}', git.long()))
|
||||
.pipe(rename('version.json'))
|
||||
.pipe(gulp.dest('./App_Data'));
|
||||
});
|
||||
|
||||
gulp.task("watch", function () {
|
||||
// Watch Source Files
|
||||
assets.forEach(function (src) {
|
||||
|
87
Teknik/package-lock.json
generated
87
Teknik/package-lock.json
generated
@ -184,6 +184,12 @@
|
||||
"integrity": "sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=",
|
||||
"dev": true
|
||||
},
|
||||
"binaryextensions": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/binaryextensions/-/binaryextensions-2.1.1.tgz",
|
||||
"integrity": "sha512-XBaoWE9RW8pPdPQNibZsW2zh8TW6gcarXp1FZPwT8Uop8ScSNldJEWf2k9l3HeTqdrEwsOsFcq74RiJECW34yA==",
|
||||
"dev": true
|
||||
},
|
||||
"block-ui": {
|
||||
"version": "2.70.1",
|
||||
"resolved": "https://registry.npmjs.org/block-ui/-/block-ui-2.70.1.tgz",
|
||||
@ -644,6 +650,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"editions": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/editions/-/editions-1.3.4.tgz",
|
||||
"integrity": "sha512-gzao+mxnYDzIysXKMQi/+M1mjy/rjestjg6OPoYTtI+3Izp23oiGZitsl9lPDPiTGXbcSIk1iJWhliSaglxnUg==",
|
||||
"dev": true
|
||||
},
|
||||
"end-of-stream": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz",
|
||||
@ -966,6 +978,17 @@
|
||||
"integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=",
|
||||
"dev": true
|
||||
},
|
||||
"git-rev-sync": {
|
||||
"version": "1.12.0",
|
||||
"resolved": "https://registry.npmjs.org/git-rev-sync/-/git-rev-sync-1.12.0.tgz",
|
||||
"integrity": "sha1-RGhAbH5sO6TPRYeZnhrbKNnRr1U=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"escape-string-regexp": "1.0.5",
|
||||
"graceful-fs": "4.1.11",
|
||||
"shelljs": "0.7.7"
|
||||
}
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.1.2",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
|
||||
@ -1285,6 +1308,15 @@
|
||||
"integrity": "sha1-eAWUHGD83+Y/RtfqNYxZreEcEyU=",
|
||||
"dev": true
|
||||
},
|
||||
"gulp-rename": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.1.0.tgz",
|
||||
"integrity": "sha1-kwkKqvTThsB/IFOKaIjxXvunJ6E=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"map-stream": "0.0.4"
|
||||
}
|
||||
},
|
||||
"gulp-util": {
|
||||
"version": "2.2.20",
|
||||
"resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-2.2.20.tgz",
|
||||
@ -1436,12 +1468,20 @@
|
||||
}
|
||||
},
|
||||
"gulp-rename": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.1.0.tgz",
|
||||
"integrity": "sha1-kwkKqvTThsB/IFOKaIjxXvunJ6E=",
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.3.0.tgz",
|
||||
"integrity": "sha512-nEuZB7/9i0IZ8AXORTizl2QLP9tcC9uWc/s329zElBLJw1CfOhmMXBxwVlCRKjDyrWuhVP0uBKl61KeQ32TiCg==",
|
||||
"dev": true
|
||||
},
|
||||
"gulp-replace": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/gulp-replace/-/gulp-replace-1.0.0.tgz",
|
||||
"integrity": "sha512-lgdmrFSI1SdhNMXZQbrC75MOl1UjYWlOWNbNRnz+F/KHmgxt3l6XstBoAYIdadwETFyG/6i+vWUSCawdC3pqOw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"map-stream": "0.0.4"
|
||||
"istextorbinary": "2.2.1",
|
||||
"readable-stream": "2.3.6",
|
||||
"replacestream": "4.0.3"
|
||||
}
|
||||
},
|
||||
"gulp-uglify": {
|
||||
@ -1882,6 +1922,17 @@
|
||||
"integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=",
|
||||
"dev": true
|
||||
},
|
||||
"istextorbinary": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/istextorbinary/-/istextorbinary-2.2.1.tgz",
|
||||
"integrity": "sha512-TS+hoFl8Z5FAFMK38nhBkdLt44CclNRgDHWeMgsV8ko3nDlr/9UI2Sf839sW7enijf8oKsZYXRvM8g0it9Zmcw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"binaryextensions": "2.1.1",
|
||||
"editions": "1.3.4",
|
||||
"textextensions": "2.2.0"
|
||||
}
|
||||
},
|
||||
"jquery": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz",
|
||||
@ -2870,6 +2921,17 @@
|
||||
"integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=",
|
||||
"dev": true
|
||||
},
|
||||
"replacestream": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmjs.org/replacestream/-/replacestream-4.0.3.tgz",
|
||||
"integrity": "sha512-AC0FiLS352pBBiZhd4VXB1Ab/lh0lEgpP+GGvZqbQh8a5cmXVoTe5EX/YeTFArnp4SRGTHh1qCHu9lGs1qG8sA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"escape-string-regexp": "1.0.5",
|
||||
"object-assign": "4.1.1",
|
||||
"readable-stream": "2.3.6"
|
||||
}
|
||||
},
|
||||
"resolve": {
|
||||
"version": "1.7.1",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz",
|
||||
@ -3004,6 +3066,17 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"shelljs": {
|
||||
"version": "0.7.7",
|
||||
"resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.7.tgz",
|
||||
"integrity": "sha1-svXHfvlxSPS09uImguELuoZnz/E=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"glob": "7.1.2",
|
||||
"interpret": "1.1.0",
|
||||
"rechoir": "0.6.2"
|
||||
}
|
||||
},
|
||||
"sigmund": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz",
|
||||
@ -3308,6 +3381,12 @@
|
||||
"uuid": "1.4.2"
|
||||
}
|
||||
},
|
||||
"textextensions": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/textextensions/-/textextensions-2.2.0.tgz",
|
||||
"integrity": "sha512-j5EMxnryTvKxwH2Cq+Pb43tsf6sdEgw6Pdwxk83mPaq0ToeFJt6WE4J3s5BqY7vmjlLgkgXvhtXUxo80FyBhCA==",
|
||||
"dev": true
|
||||
},
|
||||
"through2": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz",
|
||||
|
@ -21,9 +21,12 @@
|
||||
"description": "Teknik Services",
|
||||
"devDependencies": {
|
||||
"del": "^3.0.0",
|
||||
"git-rev-sync": "^1.12.0",
|
||||
"gulp": "3.9.1",
|
||||
"gulp-concat": "^2.6.1",
|
||||
"gulp-cssmin": "^0.2.0",
|
||||
"gulp-rename": "^1.3.0",
|
||||
"gulp-replace": "^1.0.0",
|
||||
"gulp-uglify": "^3.0.0",
|
||||
"merge-stream": "^1.0.1",
|
||||
"pump": "^3.0.0",
|
||||
@ -45,7 +48,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"pre-publish": "npm install && gulp clean && gulp copy-assets && gulp watch",
|
||||
"build": "npm install && gulp clean && gulp copy-assets && gulp min",
|
||||
"build": "npm install && gulp clean && gulp copy-assets && gulp min && gulp update-version",
|
||||
"gulp": "gulp"
|
||||
},
|
||||
"version": "2.1.0",
|
||||
|
@ -6,7 +6,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Teknik.Configuration;
|
||||
|
||||
namespace Teknik.Piwik
|
||||
namespace Teknik.Tracking
|
||||
{
|
||||
public static class Reporting
|
||||
{
|
@ -3,7 +3,7 @@ using System.Web;
|
||||
using Teknik.Configuration;
|
||||
using Teknik.Utilities;
|
||||
|
||||
namespace Teknik.Piwik
|
||||
namespace Teknik.Tracking
|
||||
{
|
||||
public static class Tracking
|
||||
{
|
@ -2,8 +2,8 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<AssemblyName>Teknik.Piwik</AssemblyName>
|
||||
<RootNamespace>Teknik.Piwik</RootNamespace>
|
||||
<AssemblyName>Teknik.Tracking</AssemblyName>
|
||||
<RootNamespace>Teknik.Tracking</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Teknik.Piwik
|
||||
namespace Teknik.Tracking
|
||||
{
|
||||
public class VisitorData
|
||||
{
|
@ -7,6 +7,7 @@ namespace Teknik.Utilities
|
||||
public const string LOGO_PATH = "images/logo-black.svg";
|
||||
public const string FAVICON_PATH = "images/favicon.ico";
|
||||
public const string ROBOTS_PATH = "~/App_Data/robots.txt";
|
||||
|
||||
public const string LOG_FILE_NAME_PREFIX = "Teknik";
|
||||
public const string LOG_FILE_EXT = ".log";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user