forked from nubiancc/frapid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Added a new dashboard theme called MixERP.
-Update documentation of overrides.
- Loading branch information
Showing
81 changed files
with
11,539 additions
and
573 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,31 @@ | ||
# Overrides | ||
|
||
Frapid searches for overridden views on the instance directory and loads them if found. | ||
Frapid searches for overridden views on the theme and instance directories and loads them if found: | ||
|
||
For example: the view: | ||
For: | ||
|
||
`~/Areas/Frapid.Account/Views/SignUp/Index.cshtml` | ||
* **Domain Name**: fizbuzz.com | ||
* **Area Name** : Frapid.Account | ||
* **Controller Name** : SignUp | ||
* **Action Name** : Index | ||
* **Current Theme** : frapid | ||
|
||
When you request the view: | ||
|
||
```cs | ||
var view = View(GetRazorView<AreaRegistration>("SignUp/Index.cshtml")); | ||
``` | ||
|
||
would be overridden by: | ||
it will be searched on the current theme directory (~/Catalogs/fizzbuzz_com/Areas/Frapid.WebsiteBuilder/Themes/frapid/): | ||
|
||
`~/Catalogs/foo_com/Areas/Frapid.Account/Views/SignUp/Index.cshtml` | ||
`~/Catalogs/fizzbuzz_com/Areas/Frapid.WebsiteBuilder/Themes/frapid/Areas/Frapid.Account/Views/SignUp/Index.cshtml` | ||
|
||
for foo.com and | ||
if not found then | ||
|
||
`~/Catalogs/bar_com/Areas/Frapid.Account/Views/SignUp/Index.cshtml` | ||
`~/Catalogs/fizzbuzz_com/Areas/Frapid.Account/Views/SignUp/Index.cshtml` | ||
|
||
for bar.com. | ||
if not found then | ||
|
||
`~/Areas/Frapid.Account/Views/SignUp/Index.cshtml` | ||
|
||
[Back to Developer Documentation](README.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
src/Frapid.Web/Areas/Frapid.Config/db/1.x/1.0/src/09.menus/0.menu.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
SELECT * FROM core.create_app('Frapid.Config', 'Config', '1.0', 'MixERP Inc.', 'December 1, 2015', 'orange configure', '/dashboard/config/offices', null); | ||
|
||
SELECT * FROM core.create_menu('Frapid.Config', 'Office', '/dashboard/config/offices', 'building outline', ''); | ||
SELECT * FROM core.create_menu('Frapid.Config', 'Offices', '/dashboard/config/offices', 'building outline', ''); | ||
SELECT * FROM core.create_menu('Frapid.Config', 'Flags', '/dashboard/config/flags', 'flag', ''); | ||
SELECT * FROM core.create_menu('Frapid.Config', 'SMTP', '/dashboard/config/smtp', 'at', ''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System.Globalization; | ||
using System.Web.Hosting; | ||
using Frapid.ApplicationState.Cache; | ||
using Frapid.Configuration; | ||
using static System.String; | ||
|
||
namespace Frapid.Dashboard | ||
{ | ||
public class Configuration | ||
{ | ||
private const string Path = "~/Catalogs/{0}/Areas/Frapid.Dashboard/"; | ||
private const string ConfigFile = "Dashboard.config"; | ||
private const string DefaultThemeKey = "DefaultTheme"; | ||
|
||
public static string GetCurrentThemePath() | ||
{ | ||
string catalog = AppUsers.GetCatalog(); | ||
string path = Path + "Themes/{1}/"; | ||
string theme = GetDefaultTheme(); | ||
|
||
return Format(CultureInfo.InvariantCulture, path, catalog, theme); | ||
} | ||
|
||
public static string GetDashboardPath() | ||
{ | ||
string catalog = AppUsers.GetCatalog(); | ||
string path = HostingEnvironment.MapPath(Format(CultureInfo.InvariantCulture, Path, catalog)); | ||
|
||
return path != null && !System.IO.Directory.Exists(path) ? Empty : path; | ||
} | ||
|
||
public static string GetDefaultTheme() | ||
{ | ||
return Get(DefaultThemeKey); | ||
} | ||
|
||
public static string Get(string key) | ||
{ | ||
string path = GetDashboardPath() + "/" + ConfigFile; | ||
return ConfigurationManager.ReadConfigurationValue(path, key); | ||
} | ||
} | ||
} |
6 changes: 5 additions & 1 deletion
6
src/Frapid.Web/Areas/Frapid.Dashboard/Controllers/AppController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/Frapid.Web/Areas/Frapid.Dashboard/Controllers/MyTemplateController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System.EnterpriseServices; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Web; | ||
using System.Web.Hosting; | ||
using System.Web.Mvc; | ||
using Frapid.Configuration; | ||
|
||
namespace Frapid.Dashboard.Controllers | ||
{ | ||
public class MyTemplateController : Controller | ||
{ | ||
[Route("dashboard/my/template/{*resource}")] | ||
public ActionResult Get(string resource = "") | ||
{ | ||
string configFile = | ||
HostingEnvironment.MapPath($"~/Catalogs/{DbConvention.GetCatalog()}/Configs/Frapid.config"); | ||
|
||
if (!System.IO.File.Exists(configFile)) | ||
{ | ||
return this.HttpNotFound(); | ||
} | ||
|
||
var allowed = ConfigurationManager.ReadConfigurationValue(configFile, "MyAllowedResources").Split(','); | ||
|
||
if (string.IsNullOrWhiteSpace(resource) || allowed.Count().Equals(0)) | ||
{ | ||
return this.HttpNotFound(); | ||
} | ||
|
||
string directory = HostingEnvironment.MapPath(Configuration.GetCurrentThemePath()); | ||
|
||
if (directory == null) | ||
{ | ||
return this.HttpNotFound(); | ||
} | ||
|
||
string path = Path.Combine(directory, resource); | ||
|
||
if (!System.IO.File.Exists(path)) | ||
{ | ||
return this.HttpNotFound(); | ||
} | ||
|
||
string extension = Path.GetExtension(path); | ||
|
||
if (!allowed.Contains(extension)) | ||
{ | ||
return this.HttpNotFound(); | ||
} | ||
|
||
string mimeType = this.GetMimeType(path); | ||
return this.File(path, mimeType); | ||
} | ||
|
||
private string GetMimeType(string fileName) | ||
{ | ||
return MimeMapping.GetMimeMapping(fileName); | ||
} | ||
} | ||
} |
Oops, something went wrong.