VNS.Umbraco
13.5.2
dotnet add package VNS.Umbraco --version 13.5.2
NuGet\Install-Package VNS.Umbraco -Version 13.5.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VNS.Umbraco" Version="13.5.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add VNS.Umbraco --version 13.5.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: VNS.Umbraco, 13.5.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install VNS.Umbraco as a Cake Addin #addin nuget:?package=VNS.Umbraco&version=13.5.2 // Install VNS.Umbraco as a Cake Tool #tool nuget:?package=VNS.Umbraco&version=13.5.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
VNS Umbraco
Some diffrent helper tools for Umbraco Core
Installation
Use the package manager nuget to install.
dotnet add package VNS.Umbraco
Intro
First things first, with this package, we added a custom composer that enables direct URL acces to a template
public void Compose(IUmbracoBuilder builder) {
builder.ContentFinders().Clear();
builder.ContentFinders()
.Append<ContentFinderByPageIdQuery>()
.Append<ContentFinderByUrl>()
.Append<ContentFinderByIdPath>()
// Add the url and template one back in here
.Append<ContentFinderByUrlAndTemplate>()
.Append<ContentFinderByUrlAlias>()
.Append<ContentFinderByRedirectUrl>();
}
Init
Add this to the top of you template
// Using
@using VNS.Umbraco;
// For injection
@inject VNS.Umbraco.Helper _vns;
Helper
Injection is required
// Get translation label
string _vns.GetTranslation(string name, string culture = "", string altText = "")
// Get the raw SVG from IPublishedContent
string _vns.GetSVG(IPublishedContent media);
Util (Utility)
This contains a lot of diffrent small static methods to help you create simple code
// Get httpcontext
HttpContext Util.ctx;
// Get appsettings (Will load from appsettings.json)
IConfigurationRoot Util.AppSettings;
// Get connection provider (Will return connection provider named umbracoDbDSN_ProviderName)
string Utill.ConnectionProvider;
// Get connectionstring (Will return connectionstring named umbracoDbDSN)
string Util.ConnectionString;
// Get smtp (Will return from Umbraco:CMS:Global:Smtp)
IConfigurationSection Util.Smtp;
// Get remote IP (With cloudflare support - Using CF-Connecting-IP header if behind CF)
string Util.RemoteIP;
// Get status code
int Util.StatusCode;
// Get request method
string Util.ReqMethod;
// Is request method post
bool Util.IsPost;
// Get current url
string Util.GetCurrentUrl(bool includePath = true, bool includeQueryString = false);
// Request from form/querystring
string Util.Req(string key);
// Request from form
string Util.ReqForm(string key);
// Request from querystring
string Util.ReqQuery(string key);
// IPGeo (If no IP is set, RemoteIP will be used)
string Util.IPGeo(string ip = "");
// Domain whois (Currently only .com domains)
string Util.Whois(string domain);
// Request headers
IHeaderDictionary Util.ReqHeaders;
// Request header
StringValues Util.ReqHeader(string key);
// Request header
string Util.ReqHead(string key, bool htmlDecode = false);
// Request referer
string Util.ReqRef;
// Request host
string Util.ReqHost;
// Request user-agent
string Util.ReqUserAgent;
// Is host in ref
bool Util.IsHostInRef;
// Url Encode/Decode
string Util.UrlEncode(string value);
string Util.UrlDecode(string value);
// Html Encode/Decode
string Util.HtmlEncode(string value);
string Util.HtmlDecode(string value);
// Write to body
void Util.Write(object message);
// Redirect
void Util.Redirect(string url);
// Set content type - Default is set to: application/json
void Util.SetContentType(string contentType);
// Check if dynamic object contains a key
bool Util.ContainsKey(dynamic obj, string key);
// Session
void Util.SetSession(string key, object value);
T Util.GetSession<T>(string key);
void Util.RemoveSession(string key);
void Util.ClearSession();
// Cookie
void Util.SetCookie(string key, object value, DateTime? expires = null)
T Util.GetCookie<T>(string key);
void Util.DeleteCookie(string key);
// Udi
Udi Util.GetUdi(this IPublishedContent content);
// Render view as string
string Util.RenderViewAsString(Microsoft.AspNetCore.Html.IHtmlContent partial, System.Text.Encodings.Web.HtmlEncoder encoder);
// Get request files
IFormCollection Util.ReqFiles
// Get request file
IFormFile Util.ReqFile(string name);
// Save file
bool Util.SaveFile(IFormFile file, string path);
// Convert file to base64
string Util.ConvertToBase64(this IFormFile file);
// Posted body
System.IO.Stream Util.ReqBody();
string Util.ReqBodyAsString();
// Convert to XDocument
XDocument Util.Json2Xml(string json, string root = "");
XDocument Util.Obj2Xml(object obj, string root = "");
// Convert to JSON
string Util.Obj2Json(object obj);
string Util.Xml2Json(string xml);
// Convert to dynamic
T Util.Xml2Dynamic<T>(string xml);
T Util.Json2Dynamic<T>(string json);
T Util.Obj2Dynamic<T>(object obj);
// Convert stream
string Util.StreamToString(System.IO.Stream stream);
// Send email (Will use smtp settings from appsettings, add from object and look for name parameter in smtp selection to use as from name if fromName parameter not set)
bool Util.SendEmail(System.Net.Mail.MailMessage mailMessage, string fromName = "");
// This will just prettify json with indents for better display on web
string Util.FormatJson(Newtonsoft.Json.Linq.JObject json, bool fix4Web = false);
string Util.FormatJson(string json, bool fix4Web = false);
// Combine objects
object Util.CombineObj(object obj1, object obj2, object obj3 = null, object obj4 = null);
// Convert UnixTime to datetime
DateTime Util.DateFromUnixTime(long unixdate);
// Expose object
void Util.DrillObject(object obj);
// Clone object
T Util.CloneObj<T>(T obj);
// Clean HTML
string Util.CleanHtml(string html);
Secy (Security)
This contains a lot of diffrent small static methods to help you create simple code
// Generate random password
string Secy.GeneratePassword(int passwordLength = 10);
// Hash
string Secy.Hash(string text, bool Use256 = false, bool Use512 = false);
// A2B
string Secy.A2B(string input);
// B2A
string Secy.B2A(string input);
// Encrypt Text
string Secy.EncryptText(string text, string secret = "");
// Decrypt Text
string Secy.DecryptText(string text, string secret = "");
// Generate JWT token
string Secy.GetToken(object payload, string serectKey = "", int expireAfterMinutes = 1440, int notValidBeforeMinutes = 0);
// Check if JWT token is valid
bool Secy.IsTokenValid(string token, string serectKey, out string message);
// Get token headers from JWT
dynamic Secy.GetTokenHeaders(string token);
// Get token payload from JWT
dynamic Secy.GetTokenPayload(string token);
Soap
// Init
var soap = new SOAP(string url, string xmlns = "")
// Get / Set properties
Dictionary<string, string> soap.Headers;
// Execute
string soap.Execute(string method, string payloadXml = "");
// Result status
int soap.StatusCode;
string soap.StatusDescription;
bool soap.IsSuccess;
Rest
// Init
var rest = REST(string token);
or
var rest = new REST(string login = "", string password = "", string seperator = ":", string prefix = "Basic");
// Get / Set properties
string rest.ContentType;
string rest.Accept;
string rest.Method;
string rest.BaseUrl;
bool rest.KeepAlive;
Dictionary<string, string> rest.Headers;
// Execute
string rest.Execute(string url, string payload = "");
// Result status
int rest.StatusCode;
string rest.StatusDescription;
bool rest.IsSuccess;
SQL
// Init
var sql = new SQL(string connectionString);
or
var sql = new SQL(string server, string database, string login, string password);
// Select data from SQL
var reader = sql.GetReader(string sql);
// Loop reader
while(reader.Read()){
// Do stuff
}
// Close reader
reader.Close();
// Insert, Update, Delete etc.
void sql.Execute(string sql);
// Close sql
sql.Close();
SQLite
// Init
var sqlite = new SQLite(string connectionString);
or
var sqlite = new SQLite(string dataSource, bool foreignKeys, bool pooling);
// Select data from SQL
var reader = sqlite.GetReader(string sql);
// Loop reader
while(reader.Read()){
// Do stuff
}
// Close reader
reader.Close();
// Insert, Update, Delete etc.
void sqlite.Execute(string sql);
// Close sql
sqlite.Close();
Cookiebot
// Init
var cookiebot = new Cookiebot(string cookieName = "CookieConsent", string preferencesName = "preferences", string statisticsName = "statistics", string marketingName = "marketing");
// Properties
bool cookiebot.Necessary;
bool cookiebot.Statistics;
bool cookiebot.Marketing;
bool cookiebot.Preferences;
Log
Injection is required
_vns.Log.Trace(string message, Exception ex = null);
_vns.Log.Debug(string message, Exception ex = null);
_vns.Log.Info(string message, Exception ex = null);
_vns.Log.Warning(string message, Exception ex = null);
_vns.Log.Error(string message, Exception ex = null);
_vns.Log.Fatal(string message, Exception ex = null);
Content
Injection is required
// Create a node
IContent _vns.Content.Create(string name, int parent, string documentTypeAlias, Dictionary<string, object> keyValues = null);
// Get a node
IContent _vns.Content.Get(int id);
// Copy node
void _vns.Content.Copy(IContent content, int parentId);
// Move node
void _vns.Content.Move(IContent content, int parentId);
// Get schedule collection
ContentScheduleCollection _vns.Content.GetScheduleCollection(IContent content);
// Get release date
DateTime _vns.Content.GetReleaseDate(IContent content);
// Set release date - Will set the schedule and save the node
void _vns.Content.SetReleaseDate(IContent content, DateTime releaseDate)
// Get expire date
DateTime _vns.Content.GetExpireDate(IContent content);
// Set expire date - Will set the schedule and save the node
void _vns.Content.SetExpireDate(IContent content, DateTime expireDate)
// Unpublish node
void _vns.Content.Unpublish(IContent content);
// Save node
void _vns.Content.Save(IContent content, ContentScheduleCollection contentScheduleCollection = null);
// Save and publish node
void _vns.Content.SaveAndPublish(IContent content);
// Delete node
void _vns.Content.Delete(int id);
Member
Injection is required
// Properties for current member
bool _vns.Member.IsLoggedIn;
int _vns.Member.Id;
string _vns.Member.Username;
string _vns.Member.Name;
string _vns.Member.Email;
string _vns.Member.Comments;
DateTime? _vns.Member.LastLoginDate;
// SignOut
void _vns.Member.SignOut();
// Validate
bool _vns.Member.Validate(string userName, string password);
// Create member
IdentityResult result = _vns.Member.Create(string name, string email, string password, bool isApproved = true);
IdentityResult result = _vns.Member.Create(string name, string email, string userName, string password, bool isApproved, string memberTypeAlias = "Member");
// IdentityResult properties
bool result.Succeeded;
IEnumerable<T> result.Errors;
// Login
SignInResult result = _vns.Member.Login(string userName, string password);
// SignInResult properties
bool result.IsLockedOut;
bool result.IsNotAllowed;
bool result.RequiresTwoFactor;
// Lock / Unlock
void _vns.Member.Lock(IMember member);
void _vns.Member.Unlock(IMember member);
// Exists
bool _vns.Member.Exists(string userName);
bool _vns.Member.EmailExists(string email);
// Get a member
IMember _vns.Member.Get(); // Will return current loggedin member
IMember _vns.Member.Get(int id);
IMember _vns.Member.Get(Guid key);
IMember _vns.Member.Get(string userName);
IMember _vns.Member.GetByEmail(string email);
// Get multiple members
IEnumerable<IMember> _vns.Member.GetAllMembers(params int[] ids);
IEnumerable<IMember> _vns.Member.GetMembersByMemberType(string memberTypeid)
// Get Types
IEnumerable<IMemberType> _vns.Member.GetAllMembertypes(params int[] ids);
// Get Roles
IEnumerable<IMemberGroup> _vns.Member.GetAllRoles();
IEnumerable<string> _vns.Member.GetAllRoles(int memberid);
// Generate password
string _vns.Member.GeneratePassword();
// Reset password
string _vns.Member.ResetPassword(string email);
// Change password
IdentityResult result = _vns.Member.ChangePassword(string oldPassword, string newPassword);
// IdentityResult properties
bool result.Succeeded;
IEnumerable<T> result.Errors;
// Save member
void _vns.Member.Save(IMember member);
// Delete member
void _vns.Member.Delete(int id);
void _vns.Member.Delete(string userName);
void _vns.Member.Delete(IMember member);
License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- jose-jwt (>= 5.1.0)
- Microsoft.Data.Sqlite (>= 8.0.1)
- Newtonsoft.Json (>= 13.0.3)
- System.Data.SqlClient (>= 4.8.6)
- Umbraco.Cms.Web.Common (>= 13.5.2)
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 |
---|---|---|
13.5.2 | 96 | 11/15/2024 |
13.5.1 | 107 | 9/30/2024 |
13.5.0 | 123 | 9/13/2024 |
13.4.0 | 123 | 6/21/2024 |
13.3.2 | 97 | 6/10/2024 |
13.0.0 | 108 | 5/30/2024 |
4.0.3 | 98 | 5/2/2024 |
4.0.2 | 141 | 2/8/2024 |
4.0.1 | 112 | 1/17/2024 |
4.0.0 | 171 | 12/14/2023 |
3.0.23 | 123 | 1/17/2024 |
3.0.22 | 135 | 12/13/2023 |
3.0.21 | 147 | 11/7/2023 |
3.0.20 | 147 | 10/26/2023 |
3.0.19 | 141 | 10/4/2023 |
3.0.18 | 123 | 9/21/2023 |
3.0.17 | 160 | 9/1/2023 |
3.0.16 | 145 | 8/15/2023 |
3.0.15 | 154 | 7/14/2023 |
3.0.14 | 174 | 6/30/2023 |
3.0.13 | 165 | 5/26/2023 |
3.0.12 | 206 | 4/12/2023 |
3.0.11 | 209 | 3/28/2023 |
3.0.10 | 256 | 2/24/2023 |
3.0.8 | 294 | 2/9/2023 |
3.0.7 | 288 | 1/31/2023 |
3.0.6 | 322 | 1/31/2023 |
3.0.5 | 285 | 1/25/2023 |
3.0.4 | 307 | 1/25/2023 |
3.0.3 | 295 | 1/18/2023 |
3.0.2 | 302 | 12/14/2022 |
3.0.1 | 298 | 12/14/2022 |
3.0.0 | 300 | 12/6/2022 |
2.0.17 | 388 | 10/28/2022 |
2.0.16 | 402 | 10/24/2022 |
2.0.15 | 600 | 9/13/2022 |
2.0.14 | 554 | 9/13/2022 |
2.0.13 | 469 | 7/11/2022 |
2.0.12 | 481 | 7/11/2022 |
2.0.11 | 500 | 7/10/2022 |
2.0.10 | 467 | 7/10/2022 |
2.0.9 | 532 | 7/10/2022 |
2.0.8 | 503 | 7/10/2022 |
2.0.7 | 481 | 7/2/2022 |
2.0.5 | 467 | 6/30/2022 |
2.0.4 | 469 | 6/30/2022 |
2.0.3 | 463 | 6/29/2022 |
2.0.2 | 496 | 6/29/2022 |
2.0.1 | 464 | 6/29/2022 |
1.0.23 | 473 | 7/2/2022 |
1.0.20 | 500 | 6/29/2022 |
1.0.19 | 473 | 6/29/2022 |
1.0.17 | 493 | 6/2/2022 |
1.0.16 | 520 | 5/11/2022 |
1.0.15 | 520 | 5/10/2022 |
1.0.14 | 504 | 5/10/2022 |
1.0.13 | 503 | 5/9/2022 |
1.0.12 | 475 | 5/9/2022 |
1.0.11 | 522 | 5/9/2022 |
1.0.10 | 538 | 5/9/2022 |
1.0.9 | 541 | 5/9/2022 |
1.0.8 | 570 | 4/30/2022 |