Class CodeFileController
Inheritance
Namespace: Umbraco.Web.Editors
Assembly: Umbraco.Web.dll
Syntax
[PluginController("UmbracoApi")]
public class CodeFileController : BackOfficeNotificationsController, IDiscoverable
Constructors
View SourceCodeFileController(IGlobalSettings, IUmbracoContextAccessor, ISqlContext, ServiceContext, AppCaches, IProfilingLogger, IRuntimeState, UmbracoHelper)
Declaration
public CodeFileController(IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper)
Parameters
Type | Name | Description |
---|---|---|
IGlobalSettings | globalSettings | |
IUmbracoContextAccessor | umbracoContextAccessor | |
ISqlContext | sqlContext | |
ServiceContext | services | |
AppCaches | appCaches | |
IProfilingLogger | logger | |
IRuntimeState | runtimeState | |
UmbracoHelper | umbracoHelper |
Methods
View SourceDelete(String, String)
Used to delete a specific file from disk via the FileService
Declaration
public HttpResponseMessage Delete(string type, string virtualPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | type | This is a string but will be 'scripts' 'partialViews', 'partialViewMacros' or 'stylesheets' |
System.String | virtualPath | The filename or URL encoded path of the file to delete |
Returns
Type | Description |
---|---|
HttpResponseMessage | Will return a simple 200 if file deletion succeeds |
GetByPath(String, String)
Used to get a specific file from disk via the FileService
Declaration
public CodeFileDisplay GetByPath(string type, string virtualPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | type | This is a string but will be 'scripts' 'partialViews', 'partialViewMacros' or 'stylesheets' |
System.String | virtualPath | The filename or URL encoded path of the file to open |
Returns
Type | Description |
---|---|
CodeFileDisplay | The file and its contents from the virtualPath |
GetScaffold(String, String, String)
Used to scaffold the json object for the editors for 'scripts', 'partialViews', 'partialViewMacros' and 'stylesheets'
Declaration
public CodeFileDisplay GetScaffold(string type, string id, string snippetName = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | type | This is a string but will be 'scripts' 'partialViews', 'partialViewMacros' or 'stylesheets' |
System.String | id | |
System.String | snippetName |
Returns
Type | Description |
---|---|
CodeFileDisplay |
GetSnippets(String)
Used to get a list of available templates/snippets to base a new Partial View or Partial View Macro from
Declaration
public IEnumerable<SnippetDisplay> GetSnippets(string type)
Parameters
Type | Name | Description |
---|---|---|
System.String | type | This is a string but will be 'partialViews', 'partialViewMacros' |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<SnippetDisplay> | Returns a list of SnippetDisplay if a correct type is sent |
PostCreate(String, CodeFileDisplay)
Used to create a brand new file
Declaration
public HttpResponseMessage PostCreate(string type, CodeFileDisplay display)
Parameters
Type | Name | Description |
---|---|---|
System.String | type | This is a string but will be 'scripts' 'partialViews', 'partialViewMacros' |
CodeFileDisplay | display |
Returns
Type | Description |
---|---|
HttpResponseMessage | Will return a simple 200 if file creation succeeds |
PostCreateContainer(String, String, String)
Used to create a container/folder in 'partialViews', 'partialViewMacros', 'scripts' or 'stylesheets'
Declaration
public HttpResponseMessage PostCreateContainer(string type, string parentId, string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | type | 'partialViews', 'partialViewMacros' or 'scripts' |
System.String | parentId | The virtual path of the parent. |
System.String | name | The name of the container/folder |
Returns
Type | Description |
---|---|
HttpResponseMessage |
PostExtractStylesheetRules(CodeFileController.StylesheetData)
Extracts "umbraco style rules" from a style sheet
Declaration
public StylesheetRule[] PostExtractStylesheetRules(CodeFileController.StylesheetData data)
Parameters
Type | Name | Description |
---|---|---|
CodeFileController.StylesheetData | data | The style sheet data |
Returns
Type | Description |
---|---|
StylesheetRule[] | The style rules |
PostInterpolateStylesheetRules(CodeFileController.StylesheetData)
Creates a style sheet from CSS and style rules
Declaration
public string PostInterpolateStylesheetRules(CodeFileController.StylesheetData data)
Parameters
Type | Name | Description |
---|---|---|
CodeFileController.StylesheetData | data | The style sheet data |
Returns
Type | Description |
---|---|
System.String | The style sheet combined from the CSS and the rules |
Remarks
Any "umbraco style rules" in the CSS will be removed and replaced with the rules passed in
PostSave(CodeFileDisplay)
Used to create or update a 'partialview', 'partialviewmacro', 'script' or 'stylesheets' file
Declaration
public CodeFileDisplay PostSave(CodeFileDisplay display)
Parameters
Type | Name | Description |
---|---|---|
CodeFileDisplay | display |
Returns
Type | Description |
---|---|
CodeFileDisplay | The updated CodeFileDisplay model |