├── lib ├── sqlite3.dll └── Gistlyn.Resources.dll ├── src ├── Gistlyn │ ├── src │ │ ├── sum.ts │ │ ├── assets │ │ │ ├── img │ │ │ │ ├── compiling.png │ │ │ │ ├── editor-bg.png │ │ │ │ ├── ajax-loader.gif │ │ │ │ └── logo-32-inverted.png │ │ │ └── css │ │ │ │ ├── octicon │ │ │ │ ├── octicons.ttf │ │ │ │ └── octicons.woff │ │ │ │ ├── roboto │ │ │ │ ├── Roboto-Regular.ttf │ │ │ │ ├── roboto-v15-latin-regular.woff │ │ │ │ └── roboto-v15-latin-regular.woff2 │ │ │ │ ├── iconfont │ │ │ │ ├── MaterialIcons-Regular.eot │ │ │ │ ├── MaterialIcons-Regular.ttf │ │ │ │ ├── MaterialIcons-Regular.woff │ │ │ │ ├── MaterialIcons-Regular.woff2 │ │ │ │ └── material-icons.css │ │ │ │ ├── reset.css │ │ │ │ ├── editor.css │ │ │ │ ├── collections.css │ │ │ │ └── dialogs.css │ │ ├── sum.test.ts │ │ ├── codemirror.ext.js │ │ ├── Console.tsx │ │ ├── TestClient.tsx │ │ ├── EditGistDialog.tsx │ │ ├── ConsoleViewerDialog.tsx │ │ ├── InadequateBrowserDialog.tsx │ │ ├── SaveAsDialog.tsx │ │ ├── json-viewer.tsx │ │ ├── app.tsx │ │ ├── Collections.tsx │ │ ├── TakeSnapshotDialog.tsx │ │ ├── ImageUploadDialog.tsx │ │ ├── ShortcutsDialog.tsx │ │ └── codemirror.js │ ├── favicon.ico │ ├── Global.asax │ ├── wwwroot_build │ │ └── .gitignore │ ├── tsconfig.json │ ├── Global.asax.cs │ ├── index.template.ejs │ ├── AppHost.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── webpack.config.vendor.js │ ├── package.json │ ├── webpack.config.js │ └── packages.config ├── Gistlyn.AppMac │ ├── platform.css │ ├── Resources │ │ └── logo.icns │ ├── AppDelegate.designer.cs │ ├── platform.js │ ├── Program.cs │ ├── packages.config │ ├── AppDelegate.cs │ ├── MainWindow.designer.cs │ ├── MainWindow.cs │ ├── Info.plist │ ├── MainWindowController.cs │ ├── AppHost.cs │ └── Gistlyn.AppMac.csproj ├── Gistlyn.AppConsole │ ├── logo.ico │ ├── platform.css │ ├── platform.js │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── AppHost.cs │ └── packages.config ├── Gistlyn.AppWinForms │ ├── logo.ico │ ├── win-icon.ico │ ├── Properties │ │ ├── Settings.settings │ │ ├── Settings.Designer.cs │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ └── Resources.resx │ ├── platform.css │ ├── FormMain.cs │ ├── platform.js │ ├── AppHost.cs │ ├── FormMain.Designer.cs │ ├── Program.cs │ └── AppUpdater.cs ├── Gistlyn.Resources │ ├── dist │ │ ├── app.css.map │ │ └── img │ │ │ ├── octicons.ttf │ │ │ ├── ajax-loader.gif │ │ │ ├── compiling.png │ │ │ ├── editor-bg.png │ │ │ ├── octicons.woff │ │ │ ├── logo-32-inverted.png │ │ │ ├── MaterialIcons-Regular.eot │ │ │ ├── MaterialIcons-Regular.ttf │ │ │ ├── MaterialIcons-Regular.woff │ │ │ ├── MaterialIcons-Regular.woff2 │ │ │ ├── roboto-v15-latin-regular.woff │ │ │ └── roboto-v15-latin-regular.woff2 │ ├── favicon.ico │ ├── SharedEmbeddedResources.cs │ ├── testclient.html │ ├── App.config │ ├── packages.config │ ├── index.html │ └── Properties │ │ └── AssemblyInfo.cs ├── Gistlyn.ServiceModel │ ├── packages.config │ ├── Types │ │ ├── ConsoleMessage.cs │ │ ├── ErrorInfo.cs │ │ ├── AssemblyReference.cs │ │ ├── MemoizedResult.cs │ │ ├── ScriptStatus.cs │ │ ├── ScriptVariableJson.cs │ │ ├── PackageCollection.cs │ │ ├── ScriptStateVariables.cs │ │ ├── VariableInfo.cs │ │ ├── NugetPackageInfo.cs │ │ ├── EmbedScriptExecutionResult.cs │ │ └── ScriptExecutionResult.cs │ ├── GetEmbedScript.cs │ ├── TestServerEvents.cs │ ├── EvaluateSource.cs │ ├── GetScriptVariables.cs │ ├── CancelScript.cs │ ├── GetScriptStatus.cs │ ├── SearchInstalledPackages.cs │ ├── InstallNugetPackage.cs │ ├── AddPackageAsReference.cs │ ├── SearchNugetPackages.cs │ ├── EvaluateExpression.cs │ ├── StoreGist.cs │ ├── RunEmbedScript.cs │ ├── RunScript.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Gistlyn.ServiceModel.csproj ├── Gistlyn.SnippetEngine │ ├── ScriptUtils.cs │ ├── INotifier.cs │ └── GistSourceResolver.cs ├── README.md ├── Gistlyn.ServiceInterface │ ├── ConsoleWriter.cs │ ├── ScriptRunnerInfo.cs │ ├── DebugService.cs │ ├── NotifierProxy.cs │ ├── packages.config │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── CacheExtensions.cs │ ├── DomainWrapper.cs │ ├── RunScriptSupportServices.cs │ ├── NugetUtils.cs │ └── RunScriptService.Embed.cs ├── Gistlyn.Tests │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── packages.config │ └── UnitTest.cs └── GistlynMac.sln ├── license.txt └── .gitignore /lib/sqlite3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/lib/sqlite3.dll -------------------------------------------------------------------------------- /src/Gistlyn/src/sum.ts: -------------------------------------------------------------------------------- 1 | export function sum(a:number, b:number) { 2 | return a + b; 3 | } 4 | -------------------------------------------------------------------------------- /src/Gistlyn.AppMac/platform.css: -------------------------------------------------------------------------------- 1 | /* mac */ 2 | .mac, ul > li.mac { 3 | display: block; 4 | } 5 | -------------------------------------------------------------------------------- /src/Gistlyn/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn/favicon.ico -------------------------------------------------------------------------------- /lib/Gistlyn.Resources.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/lib/Gistlyn.Resources.dll -------------------------------------------------------------------------------- /src/Gistlyn.AppConsole/logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn.AppConsole/logo.ico -------------------------------------------------------------------------------- /src/Gistlyn.AppConsole/platform.css: -------------------------------------------------------------------------------- 1 | /* console */ 2 | .console, ul > li.console { 3 | display: block; 4 | } 5 | -------------------------------------------------------------------------------- /src/Gistlyn/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="Gistlyn.Global" Language="C#" %> 2 | -------------------------------------------------------------------------------- /src/Gistlyn/wwwroot_build/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /src/Gistlyn.AppWinForms/logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn.AppWinForms/logo.ico -------------------------------------------------------------------------------- /src/Gistlyn.Resources/dist/app.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":[],"names":[],"mappings":"","file":"app.css","sourceRoot":""} -------------------------------------------------------------------------------- /src/Gistlyn.Resources/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn.Resources/favicon.ico -------------------------------------------------------------------------------- /src/Gistlyn.AppWinForms/win-icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn.AppWinForms/win-icon.ico -------------------------------------------------------------------------------- /src/Gistlyn.AppMac/Resources/logo.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn.AppMac/Resources/logo.icns -------------------------------------------------------------------------------- /src/Gistlyn/src/assets/img/compiling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn/src/assets/img/compiling.png -------------------------------------------------------------------------------- /src/Gistlyn/src/assets/img/editor-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn/src/assets/img/editor-bg.png -------------------------------------------------------------------------------- /src/Gistlyn.Resources/dist/img/octicons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn.Resources/dist/img/octicons.ttf -------------------------------------------------------------------------------- /src/Gistlyn/src/assets/img/ajax-loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn/src/assets/img/ajax-loader.gif -------------------------------------------------------------------------------- /src/Gistlyn.Resources/dist/img/ajax-loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn.Resources/dist/img/ajax-loader.gif -------------------------------------------------------------------------------- /src/Gistlyn.Resources/dist/img/compiling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn.Resources/dist/img/compiling.png -------------------------------------------------------------------------------- /src/Gistlyn.Resources/dist/img/editor-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn.Resources/dist/img/editor-bg.png -------------------------------------------------------------------------------- /src/Gistlyn.Resources/dist/img/octicons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn.Resources/dist/img/octicons.woff -------------------------------------------------------------------------------- /src/Gistlyn/src/assets/css/octicon/octicons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn/src/assets/css/octicon/octicons.ttf -------------------------------------------------------------------------------- /src/Gistlyn/src/assets/css/octicon/octicons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn/src/assets/css/octicon/octicons.woff -------------------------------------------------------------------------------- /src/Gistlyn/src/assets/img/logo-32-inverted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn/src/assets/img/logo-32-inverted.png -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | // Copyright (c) Service Stack LLC. All Rights Reserved. 2 | // License: https://raw.github.com/ServiceStack/ServiceStack/master/license.txt 3 | -------------------------------------------------------------------------------- /src/Gistlyn.Resources/dist/img/logo-32-inverted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn.Resources/dist/img/logo-32-inverted.png -------------------------------------------------------------------------------- /src/Gistlyn/src/assets/css/roboto/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn/src/assets/css/roboto/Roboto-Regular.ttf -------------------------------------------------------------------------------- /src/Gistlyn/src/sum.test.ts: -------------------------------------------------------------------------------- 1 | import { sum } from './sum'; 2 | 3 | it('adds 1 + 2 to equal 3 in TypeScript', () => { 4 | expect(sum(1, 2)).toBe(3); 5 | }); 6 | -------------------------------------------------------------------------------- /src/Gistlyn.Resources/dist/img/MaterialIcons-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn.Resources/dist/img/MaterialIcons-Regular.eot -------------------------------------------------------------------------------- /src/Gistlyn.Resources/dist/img/MaterialIcons-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn.Resources/dist/img/MaterialIcons-Regular.ttf -------------------------------------------------------------------------------- /src/Gistlyn.Resources/dist/img/MaterialIcons-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn.Resources/dist/img/MaterialIcons-Regular.woff -------------------------------------------------------------------------------- /src/Gistlyn.Resources/dist/img/MaterialIcons-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn.Resources/dist/img/MaterialIcons-Regular.woff2 -------------------------------------------------------------------------------- /src/Gistlyn.Resources/dist/img/roboto-v15-latin-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn.Resources/dist/img/roboto-v15-latin-regular.woff -------------------------------------------------------------------------------- /src/Gistlyn.Resources/dist/img/roboto-v15-latin-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn.Resources/dist/img/roboto-v15-latin-regular.woff2 -------------------------------------------------------------------------------- /src/Gistlyn/src/assets/css/iconfont/MaterialIcons-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn/src/assets/css/iconfont/MaterialIcons-Regular.eot -------------------------------------------------------------------------------- /src/Gistlyn/src/assets/css/iconfont/MaterialIcons-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn/src/assets/css/iconfont/MaterialIcons-Regular.ttf -------------------------------------------------------------------------------- /src/Gistlyn/src/assets/css/iconfont/MaterialIcons-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn/src/assets/css/iconfont/MaterialIcons-Regular.woff -------------------------------------------------------------------------------- /src/Gistlyn/src/assets/css/iconfont/MaterialIcons-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn/src/assets/css/iconfont/MaterialIcons-Regular.woff2 -------------------------------------------------------------------------------- /src/Gistlyn/src/assets/css/roboto/roboto-v15-latin-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn/src/assets/css/roboto/roboto-v15-latin-regular.woff -------------------------------------------------------------------------------- /src/Gistlyn/src/assets/css/roboto/roboto-v15-latin-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ServiceStack/Gistlyn/HEAD/src/Gistlyn/src/assets/css/roboto/roboto-v15-latin-regular.woff2 -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/Types/ConsoleMessage.cs: -------------------------------------------------------------------------------- 1 | namespace Gistlyn.ServiceModel.Types 2 | { 3 | public class ConsoleMessage 4 | { 5 | public string Message { get; set; } 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /src/Gistlyn.AppMac/AppDelegate.designer.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace Gistlyn.AppMac 3 | { 4 | // Should subclass MonoMac.AppKit.NSResponder 5 | [Foundation.Register ("AppDelegate")] 6 | public partial class AppDelegate 7 | { 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/Types/ErrorInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Gistlyn.ServiceModel.Types 4 | { 5 | [Serializable] 6 | public class ErrorInfo 7 | { 8 | public string Info { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/Types/AssemblyReference.cs: -------------------------------------------------------------------------------- 1 | namespace Gistlyn.ServiceModel.Types 2 | { 3 | public class AssemblyReference 4 | { 5 | public string Name { get; set; } 6 | 7 | public string Path { get; set; } 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /src/Gistlyn.AppConsole/platform.js: -------------------------------------------------------------------------------- 1 | /* console */ 2 | document.documentElement.className += ' console'; 3 | window.nativeHost = { 4 | quit: function() { 5 | }, 6 | showAbout: function() { 7 | }, 8 | ready: function() { 9 | }, 10 | platform: 'console' 11 | }; -------------------------------------------------------------------------------- /src/Gistlyn.Resources/SharedEmbeddedResources.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Gistlyn.Resources 8 | { 9 | public class SharedEmbeddedResources { } 10 | } 11 | -------------------------------------------------------------------------------- /src/Gistlyn.SnippetEngine/ScriptUtils.cs: -------------------------------------------------------------------------------- 1 | using ServiceStack; 2 | 3 | namespace Gistlyn.SnippetEngine 4 | { 5 | public static class ScriptUtils 6 | { 7 | public static string ToJson(object value) 8 | { 9 | return value.ToSafeJson(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Gistlyn.AppWinForms/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/Gistlyn.SnippetEngine/INotifier.cs: -------------------------------------------------------------------------------- 1 | using Gistlyn.ServiceModel.Types; 2 | 3 | namespace Gistlyn.SnippetEngine 4 | { 5 | public interface INotifier 6 | { 7 | void SendConsoleMessage(string message); 8 | void SendScriptExecutionResults(ScriptExecutionResult result); 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/Types/MemoizedResult.cs: -------------------------------------------------------------------------------- 1 | namespace Gistlyn.ServiceModel.Types 2 | { 3 | public class MemoizedResult 4 | { 5 | public int Id { get; set; } 6 | 7 | public string CodeHash { get; set; } 8 | 9 | public EmbedScriptExecutionResult Result { get; set; } 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/GetEmbedScript.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using ServiceStack; 3 | 4 | namespace Gistlyn.ServiceModel 5 | { 6 | [Route("/gists/{Gist}/embed")] 7 | public class GetEmbedScript 8 | { 9 | public string Gist { get; set; } 10 | 11 | public bool NoCache { get; set; } 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /src/Gistlyn.AppMac/platform.js: -------------------------------------------------------------------------------- 1 | /* mac */ 2 | document.documentElement.className += ' mac'; 3 | window.nativeHost = { 4 | quit: function () { 5 | $.post('/nativehost/quit'); 6 | }, 7 | showAbout: function () { 8 | $.post('/nativehost/showAbout'); 9 | }, 10 | ready: function () { 11 | // 12 | }, 13 | platform: 'mac' 14 | }; -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/Types/ScriptStatus.cs: -------------------------------------------------------------------------------- 1 | namespace Gistlyn.ServiceModel.Types 2 | { 3 | public enum ScriptStatus 4 | { 5 | Unknown, 6 | PrepareToRun, 7 | Running, 8 | Completed, 9 | Cancelled, 10 | CompiledWithErrors, 11 | ThrowedException, 12 | AnotherScriptExecuting 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/Types/ScriptVariableJson.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Gistlyn.ServiceModel.Types 4 | { 5 | [Serializable] 6 | public class ScriptVariableJson 7 | { 8 | public ScriptStatus Status { get; set; } 9 | 10 | public string Name { get; set; } 11 | 12 | public string Json { get; set; } 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/Types/PackageCollection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Xml.Serialization; 4 | 5 | namespace Gistlyn.ServiceModel.Types 6 | { 7 | [Serializable] 8 | [XmlRoot("packages")] 9 | public class PackageCollection 10 | { 11 | [XmlElement("package")] 12 | public List Packages { get; set; } 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/TestServerEvents.cs: -------------------------------------------------------------------------------- 1 | using ServiceStack; 2 | 3 | namespace Gistlyn.ServiceModel 4 | { 5 | [Route("/test")] 6 | [Route("/test/{Name}")] 7 | public class TestServerEvents : IReturn 8 | { 9 | public string Name { get; set; } 10 | } 11 | 12 | public class TestServerEventsResponse 13 | { 14 | public string Result { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/Gistlyn/src/codemirror.ext.js: -------------------------------------------------------------------------------- 1 | "format cjs"; 2 | (function (mod) { 3 | if (typeof exports === "object" && typeof module === "object") 4 | mod(require('codemirror')); 5 | else if (typeof define === "function" && define.amd) 6 | define(["codemirror"], mod); 7 | else 8 | mod(CodeMirror); 9 | })(function (CodeMirror) { 10 | "use strict"; 11 | 12 | console.log(CodeMirror.toString()); 13 | }); -------------------------------------------------------------------------------- /src/Gistlyn/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "noImplicitAny": false, 4 | "noEmitOnError": true, 5 | "removeComments": false, 6 | "sourceMap": true, 7 | "target": "es5", 8 | "module": "commonjs", 9 | "jsx": "react", 10 | "experimentalDecorators": true, 11 | "lib": [ "es2015", "dom" ] 12 | }, 13 | "exclude": [ 14 | "dist", 15 | "node_modules", 16 | "wwwroot" 17 | ] 18 | } -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/Types/ScriptStateVariables.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Gistlyn.ServiceModel.Types 5 | { 6 | [Serializable] 7 | public class ScriptStateVariables 8 | { 9 | public ScriptStatus Status { get; set; } 10 | 11 | public VariableInfo ParentVariable { get; set; } 12 | 13 | public List Variables { get; set; } 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /src/Gistlyn/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Security; 6 | using System.Web.SessionState; 7 | 8 | namespace Gistlyn 9 | { 10 | public class Global : System.Web.HttpApplication 11 | { 12 | protected void Application_Start(object sender, EventArgs e) 13 | { 14 | new AppHost().Init(); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/EvaluateSource.cs: -------------------------------------------------------------------------------- 1 | using ServiceStack; 2 | using Gistlyn.ServiceModel.Types; 3 | 4 | namespace Gistlyn.ServiceModel 5 | { 6 | [Route("/evaluate")] 7 | public class EvaluateSource : IReturn 8 | { 9 | public string Code { get; set; } 10 | } 11 | 12 | public class EvaluateSourceResponse 13 | { 14 | public ScriptExecutionResult Result { get; set;} 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/GetScriptVariables.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Gistlyn.ServiceModel.Types; 3 | using ServiceStack; 4 | 5 | namespace Gistlyn.ServiceModel 6 | { 7 | [Route("/scripts/{ScriptId}/vars")] 8 | [Route("/scripts/{ScriptId}/vars/{VariableName}")] 9 | public class GetScriptVariables : IReturn 10 | { 11 | public string ScriptId { get; set; } 12 | 13 | public string VariableName { get; set; } 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/CancelScript.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Gistlyn.ServiceModel.Types; 3 | using ServiceStack; 4 | 5 | namespace Gistlyn.ServiceModel 6 | { 7 | [Route("/scripts/{ScriptId}/cancel")] 8 | public class CancelScript : IReturn 9 | { 10 | public string ScriptId { get; set; } 11 | } 12 | 13 | public class CancelScriptResponse 14 | { 15 | public ScriptExecutionResult Result { get; set; } 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/GetScriptStatus.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Gistlyn.ServiceModel.Types; 3 | using ServiceStack; 4 | 5 | namespace Gistlyn.ServiceModel 6 | { 7 | [Route("/scripts/{ScriptId}/status")] 8 | public class GetScriptStatus : IReturn 9 | { 10 | public string ScriptId { get; set; } 11 | } 12 | 13 | public class ScriptStatusResponse 14 | { 15 | public ScriptStatus Status { get; set; } 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/Types/VariableInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Gistlyn.ServiceModel.Types 4 | { 5 | [Serializable] 6 | public class VariableInfo 7 | { 8 | public string Name { get; set; } 9 | 10 | public string Value { get; set; } 11 | 12 | public string Type { get; set; } 13 | 14 | public string Json { get; set; } 15 | 16 | public bool IsBrowseable { get; set; } 17 | 18 | public bool CanInspect { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/SearchInstalledPackages.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Gistlyn.ServiceModel.Types; 3 | using ServiceStack; 4 | 5 | namespace Gistlyn.ServiceModel 6 | { 7 | [Route("/packages/search/{Search}")] 8 | public class SearchInstalledPackages : IReturn 9 | { 10 | public string Search { get; set; } 11 | } 12 | 13 | public class SearchInstalledPackagesResponse 14 | { 15 | public List Packages { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/InstallNugetPackage.cs: -------------------------------------------------------------------------------- 1 | using ServiceStack; 2 | 3 | namespace Gistlyn.ServiceModel 4 | { 5 | [Route("/packages/install")] 6 | public class InstallNugetPackage : IReturn 7 | { 8 | public string PackageId { get; set; } 9 | 10 | public string Version { get; set; } 11 | 12 | public bool AllowPrereleaseVersion { get; set; } 13 | } 14 | 15 | public class InstallNugetPackageResponse 16 | { 17 | public string Error { get; set; } 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/Gistlyn.AppMac/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using CoreGraphics; 3 | using Foundation; 4 | using AppKit; 5 | using ObjCRuntime; 6 | 7 | namespace Gistlyn.AppMac 8 | { 9 | public static class Program 10 | { 11 | public static string HostUrl = "http://localhost:2337/"; 12 | 13 | public static AppHost App; 14 | public static NSMenu MainMenu; 15 | 16 | static void Main (string[] args) 17 | { 18 | App = new AppHost(); 19 | App.Init().Start("http://*:2337/"); 20 | 21 | NSApplication.Init(); 22 | NSApplication.Main(args); 23 | } 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/AddPackageAsReference.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Gistlyn.ServiceModel.Types; 4 | using ServiceStack; 5 | 6 | namespace Gistlyn.ServiceModel 7 | { 8 | [Route("/packages/references")] 9 | public class AddPackageAsReference : IReturn 10 | { 11 | public string PackageId { get; set; } 12 | 13 | public string Version { get; set; } 14 | } 15 | 16 | public class AddPackageAsReferenceResponse 17 | { 18 | public List Assemblies { get; set; } 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/SearchNugetPackages.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Gistlyn.ServiceModel.Types; 4 | using ServiceStack; 5 | 6 | namespace Gistlyn.ServiceModel 7 | { 8 | [Route("/nuget/packages/search/{Search}")] 9 | public class SearchNugetPackages : IReturn 10 | { 11 | public string Search { get; set; } 12 | 13 | public bool AllowPrereleaseVersion { get; set; } 14 | } 15 | 16 | public class SearchNugetPackagesResponse 17 | { 18 | public List Packages { get; set; } 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/Types/NugetPackageInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Xml.Serialization; 4 | 5 | namespace Gistlyn.ServiceModel.Types 6 | { 7 | [Serializable] 8 | public class NugetPackageInfo 9 | { 10 | [XmlAttribute("id")] 11 | public string Id { get; set; } 12 | 13 | [XmlAttribute("version")] 14 | public string Version { get; set; } 15 | 16 | [XmlAttribute("targetFramework")] 17 | public string TargetFramework { get; set; } 18 | 19 | public List Assemblies { get; set; } 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /src/Gistlyn.Resources/testclient.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Gistlyn 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/README.md: -------------------------------------------------------------------------------- 1 | # react-desktop-apps-netfx 2 | 3 | ASP.NET, Winforms, OSX Cocoa and Console React Desktop Apps Template 4 | 5 | [![](https://raw.githubusercontent.com/ServiceStack/Assets/master/csharp-templates/react-desktop-apps-netfx.png)](http://react-desktop-apps-netfx.web-templates.io/) 6 | 7 | > Browse [source code](https://github.com/NetFrameworkTemplates/react-desktop-apps-netfx), view live demo [react-desktop-apps-netfx.web-templates.io](http://react-desktop-apps-netfx.web-templates.io) and install with [dotnet-new](http://docs.servicestack.net/dotnet-new): 8 | 9 | $ npm install -g @servicestack/cli 10 | 11 | $ dotnet-new react-desktop-apps-netfx ProjectName 12 | 13 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/EvaluateExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Gistlyn.ServiceModel.Types; 3 | using ServiceStack; 4 | 5 | namespace Gistlyn.ServiceModel 6 | { 7 | [Route("/scripts/{ScriptId}/evaluate")] 8 | public class EvaluateExpression : IReturn 9 | { 10 | public string ScriptId { get; set; } 11 | 12 | public string Expression { get; set; } 13 | 14 | public bool IncludeJson { get; set; } 15 | } 16 | 17 | public class EvaluateExpressionResponse 18 | { 19 | public ScriptExecutionResult Result { get; set; } 20 | 21 | public ResponseStatus ResponseStatus { get; set; } 22 | } 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /src/Gistlyn.AppMac/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/Gistlyn.AppConsole/Program.cs: -------------------------------------------------------------------------------- 1 | using ServiceStack.Text; 2 | using System; 3 | using System.Diagnostics; 4 | using System.Threading; 5 | 6 | namespace Gistlyn.AppConsole 7 | { 8 | static class Program 9 | { 10 | public static string HostUrl = "http://localhost:4000/"; 11 | 12 | /// 13 | /// The main entry point for the application 14 | /// 15 | //[STAThread] Makes unloading the script AppDomain hang 16 | static void Main(string[] args) 17 | { 18 | new AppHost().Init().Start("http://*:4000/"); 19 | $"ServiceStack SelfHost listening at {HostUrl}".Print(); 20 | Process.Start(HostUrl); 21 | 22 | Thread.Sleep(Timeout.Infinite); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Gistlyn.AppMac/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using CoreGraphics; 3 | using Foundation; 4 | using AppKit; 5 | using ObjCRuntime; 6 | 7 | namespace Gistlyn.AppMac 8 | { 9 | public partial class AppDelegate : NSApplicationDelegate 10 | { 11 | public static MainWindowController MainWindowController; 12 | 13 | public AppDelegate(){} 14 | 15 | public override void DidFinishLaunching (NSNotification notification) 16 | { 17 | #if DEBUG 18 | //Enable WebInspector in WebView 19 | var defaults = NSUserDefaults.StandardUserDefaults; 20 | defaults.SetBool(true, "WebKitDeveloperExtras"); 21 | defaults.Synchronize(); 22 | #endif 23 | MainWindowController = new MainWindowController(); 24 | MainWindowController.Window.MakeKeyAndOrderFront(this); 25 | } 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceInterface/ConsoleWriter.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Text; 3 | 4 | namespace Gistlyn.ServiceInterface 5 | { 6 | public class ConsoleWriter : TextWriter 7 | { 8 | readonly NotifierProxy proxy; 9 | readonly StringBuilder sb = new StringBuilder(); 10 | 11 | public ConsoleWriter(NotifierProxy proxy) 12 | { 13 | this.proxy = proxy; 14 | } 15 | 16 | public override Encoding Encoding => Encoding.UTF8; 17 | 18 | public override void Write(char value) 19 | { 20 | sb.Append(value); 21 | if (value == '\n') 22 | { 23 | proxy.SendConsoleMessage(sb.ToString()); 24 | sb.Length = 0; 25 | } 26 | } 27 | } 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/Types/EmbedScriptExecutionResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.Serialization; 4 | using ServiceStack; 5 | 6 | namespace Gistlyn.ServiceModel.Types 7 | { 8 | [Serializable] 9 | public class EmbedScriptExecutionResult 10 | { 11 | public ScriptStatus Status { get; set; } 12 | 13 | public List Errors { get; set; } 14 | 15 | [IgnoreDataMember] 16 | public Exception Exception { get; set; } 17 | 18 | public ResponseStatus ErrorResponseStatus 19 | { 20 | get { return Exception != null ? new ResponseStatus(Exception.GetType().Name, Exception.Message) : null; } 21 | } 22 | 23 | public string LastVariableJson { get; set; } 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/Gistlyn.Resources/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Gistlyn/index.template.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Gistlyn - Your C# Gist IDE in the Sky! 8 | 9 | {{ ifDebug | select: }} 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceInterface/ScriptRunnerInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Service Stack LLC. All Rights Reserved. 2 | // License: https://raw.github.com/ServiceStack/ServiceStack/master/license.txt 3 | 4 | using System; 5 | 6 | namespace Gistlyn.ServiceInterface 7 | { 8 | public class ScriptRunnerInfo : IDisposable 9 | { 10 | public string ScriptId { get; set; } 11 | 12 | public string SessionId { get; set; } 13 | 14 | public DateTime CreatedDate { get; set; } 15 | 16 | public DomainWrapper DomainWrapper { get; set; } 17 | 18 | public AppDomain ScriptDomain { get; set; } 19 | 20 | public void Dispose() 21 | { 22 | DomainWrapper?.Cancel(); 23 | 24 | if (ScriptDomain != null) 25 | AppDomain.Unload(ScriptDomain); 26 | } 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/Types/ScriptExecutionResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.Serialization; 4 | using ServiceStack; 5 | 6 | namespace Gistlyn.ServiceModel.Types 7 | { 8 | [Serializable] 9 | public class ScriptExecutionResult 10 | { 11 | public ScriptStatus Status { get; set; } 12 | 13 | public List Variables { get; set; } 14 | 15 | public List Errors { get; set; } 16 | 17 | [IgnoreDataMember] 18 | public Exception Exception { get; set; } 19 | 20 | public ResponseStatus ErrorResponseStatus 21 | { 22 | get { return Exception != null ? new ResponseStatus(Exception.GetType().Name, Exception.Message) : null; } 23 | } 24 | 25 | public string Console { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Gistlyn.AppMac/MainWindow.designer.cs: -------------------------------------------------------------------------------- 1 | // WARNING 2 | // 3 | // This file has been generated automatically by Xamarin Studio to store outlets and 4 | // actions made in the UI designer. If it is removed, they will be lost. 5 | // Manual changes to this file may not be handled correctly. 6 | // 7 | using Foundation; 8 | using System.CodeDom.Compiler; 9 | 10 | namespace Gistlyn.AppMac 11 | { 12 | [Register ("MainWindow")] 13 | partial class MainWindow 14 | { 15 | [Outlet] 16 | WebKit.WebView webView { get; set; } 17 | 18 | void ReleaseDesignerOutlets () 19 | { 20 | if (webView != null) { 21 | webView.Dispose (); 22 | webView = null; 23 | } 24 | } 25 | } 26 | 27 | [Register ("MainWindowController")] 28 | partial class MainWindowController 29 | { 30 | 31 | void ReleaseDesignerOutlets () 32 | { 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/StoreGist.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using ServiceStack; 3 | 4 | namespace Gistlyn.ServiceModel 5 | { 6 | public class StoreGist : IReturn 7 | { 8 | public string Gist { get; set; } 9 | public bool Fork { get; set; } 10 | public bool Public { get; set; } 11 | public string OwnerLogin { get; set; } 12 | public string Description { get; set; } 13 | public Dictionary Files { get; set; } 14 | } 15 | 16 | public class StoreGistResponse 17 | { 18 | public string Gist { get; set; } 19 | public ResponseStatus ResponseStatus { get; set; } 20 | } 21 | 22 | public class GithubFile 23 | { 24 | public string filename { get; set; } 25 | public string content { get; set; } 26 | } 27 | } -------------------------------------------------------------------------------- /src/Gistlyn.ServiceInterface/DebugService.cs: -------------------------------------------------------------------------------- 1 | #if DEBUG 2 | using System.Collections.Generic; 3 | using ServiceStack; 4 | using ServiceStack.Configuration; 5 | 6 | namespace Gistlyn.ServiceInterface 7 | { 8 | [Route("/debug")] 9 | public class Debug : IReturn { } 10 | 11 | public class DebugResponse 12 | { 13 | public Dictionary AppSettings { get; set; } 14 | } 15 | 16 | public class DebugService : Service 17 | { 18 | public IAppSettings AppSettings { get; set; } 19 | 20 | public object Any(Debug request) 21 | { 22 | var appSettings = new Dictionary(); 23 | AppSettings.GetAllKeys().Each(x => appSettings[x] = AppSettings.GetString(x)); 24 | 25 | return new DebugResponse 26 | { 27 | AppSettings = appSettings 28 | }; 29 | } 30 | } 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/RunEmbedScript.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Gistlyn.ServiceModel.Types; 4 | using ServiceStack; 5 | 6 | namespace Gistlyn.ServiceModel 7 | { 8 | [Route("/embed-scripts/{ScriptId}/gists/{GistHash}/run")] 9 | public class RunEmbedScript : IReturn 10 | { 11 | public string ScriptId { get; set; } 12 | 13 | public string GistHash { get; set; } 14 | 15 | public string MainSource { get; set; } 16 | 17 | public List Sources { get; set; } 18 | 19 | public List References { get; set; } 20 | 21 | public string Packages { get; set; } 22 | 23 | public bool NoCache { get; set; } 24 | } 25 | 26 | public class RunEmbedScriptResponse 27 | { 28 | public EmbedScriptExecutionResult Result { get; set; } 29 | 30 | public List References { get; set; } 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/RunScript.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Gistlyn.ServiceModel.Types; 3 | using ServiceStack; 4 | 5 | namespace Gistlyn.ServiceModel 6 | { 7 | [Route("/scripts/{ScriptId}/run")] 8 | public class RunScript : IReturn 9 | { 10 | public string ScriptId { get; set; } 11 | 12 | public string MainSource { get; set; } 13 | 14 | public List Sources { get; set; } 15 | 16 | public string PackagesConfig { get; set; } 17 | 18 | public List References { get; set; } 19 | 20 | public bool ForceRun { get; set; } 21 | } 22 | 23 | public class RunScriptResponse 24 | { 25 | public ScriptExecutionResult Result { get; set; } 26 | 27 | public List References { get; set; } 28 | 29 | public int ScriptsRemoved { get; set; } 30 | 31 | public ResponseStatus ResponseStatus { get; set; } 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /src/Gistlyn.AppWinForms/platform.css: -------------------------------------------------------------------------------- 1 | /* winforms */ 2 | winforms, ul > li.winforms { 3 | display: block; 4 | } 5 | body { 6 | -webkit-touch-callout: none; 7 | -webkit-user-select: none; 8 | user-select: none; 9 | } 10 | 11 | .alert-hide { 12 | display: none; 13 | } 14 | 15 | #alertUpdate { 16 | position: absolute; 17 | width: 100%; 18 | top: 0; 19 | border-radius: 0; 20 | box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.3); 21 | } 22 | #closeUpdate { 23 | position: absolute; 24 | right: 45px; 25 | top: 10px; 26 | font-size: 24px; 27 | cursor: pointer; 28 | } 29 | #alertUpdate button { 30 | position: absolute; 31 | right: 70px; 32 | padding: 5px 20px; 33 | top: 8px; 34 | font-size: 14px; 35 | } 36 | 37 | #footer-spacer { 38 | min-height: 40px; 39 | width: 100%; 40 | } 41 | 42 | #footer { 43 | position: absolute; 44 | bottom: 0; 45 | width: 100%; 46 | } 47 | 48 | .winforms #console { 49 | height: 300px; 50 | } -------------------------------------------------------------------------------- /src/Gistlyn.Resources/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Gistlyn/AppHost.cs: -------------------------------------------------------------------------------- 1 | using Funq; 2 | using Gistlyn.ServiceInterface; 3 | using ServiceStack; 4 | using ServiceStack.Configuration; 5 | using ServiceStack.IO; 6 | 7 | namespace Gistlyn 8 | { 9 | public partial class AppHost : AppHostBase 10 | { 11 | public AppHost() 12 | : base("Gistlyn", typeof(RunScriptService).Assembly) 13 | { 14 | var appSettings = SharedAppHostConfig.GetMemoryAppSettings(); 15 | OverrideAppSettings(appSettings); 16 | AppSettings = appSettings; 17 | } 18 | 19 | public override void Configure(Container container) 20 | { 21 | SharedAppHostConfig.Configure(this, "~/App_Data/packages".MapHostAbsolutePath()); 22 | VirtualFiles = new FileSystemVirtualFiles(MapProjectPath("~/")); 23 | Config.WebHostPhysicalPath = MapProjectPath("~/wwwroot"); 24 | Config.DebugMode = true; 25 | } 26 | 27 | static partial void OverrideAppSettings(DictionarySettings appSettings); 28 | } 29 | } -------------------------------------------------------------------------------- /src/Gistlyn.Resources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Gistlyn - Your C# Gist IDE in the Sky! 8 | 9 | {{ ifDebug | select: }} 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Gistlyn.AppMac/MainWindow.cs: -------------------------------------------------------------------------------- 1 | 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using Foundation; 6 | using AppKit; 7 | 8 | namespace Gistlyn.AppMac 9 | { 10 | public partial class MainWindow : AppKit.NSWindow 11 | { 12 | #region Constructors 13 | 14 | // Called when created from unmanaged code 15 | public MainWindow (IntPtr handle) : base (handle) 16 | { 17 | Initialize (); 18 | } 19 | 20 | // Called when created directly from a XIB file 21 | [Export ("initWithCoder:")] 22 | public MainWindow (NSCoder coder) : base (coder) 23 | { 24 | Initialize (); 25 | } 26 | 27 | // Shared initialization code 28 | void Initialize () 29 | { 30 | } 31 | 32 | #endregion 33 | 34 | public override void AwakeFromNib() 35 | { 36 | base.AwakeFromNib (); 37 | Program.MainMenu = NSApplication.SharedApplication.MainMenu; 38 | webView.MainFrameUrl = Program.HostUrl; 39 | webView.Frame = new CoreGraphics.CGRect(0,0,this.Frame.Width,this.Frame.Height); 40 | this.DidResize += (sender, e) => { 41 | webView.Frame = new CoreGraphics.CGRect(0,0,this.Frame.Width,this.Frame.Height); 42 | }; 43 | } 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /src/Gistlyn/src/assets/css/iconfont/material-icons.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Material Icons'; 3 | font-style: normal; 4 | font-weight: 400; 5 | src: url(MaterialIcons-Regular.eot); /* For IE6-8 */ 6 | src: local('Material Icons'), 7 | local('MaterialIcons-Regular'), 8 | url(MaterialIcons-Regular.woff2) format('woff2'), 9 | url(MaterialIcons-Regular.woff) format('woff'), 10 | url(MaterialIcons-Regular.ttf) format('truetype'); 11 | } 12 | 13 | .material-icons { 14 | font-family: 'Material Icons'; 15 | font-weight: normal; 16 | font-style: normal; 17 | font-size: 24px; /* Preferred icon size */ 18 | display: inline-block; 19 | width: 1em; 20 | height: 1em; 21 | line-height: 1; 22 | text-transform: none; 23 | letter-spacing: normal; 24 | word-wrap: normal; 25 | white-space: nowrap; 26 | direction: ltr; 27 | 28 | /* Support for all WebKit browsers. */ 29 | -webkit-font-smoothing: antialiased; 30 | /* Support for Safari and Chrome. */ 31 | text-rendering: optimizeLegibility; 32 | 33 | /* Support for Firefox. */ 34 | -moz-osx-font-smoothing: grayscale; 35 | 36 | /* Support for IE. */ 37 | font-feature-settings: 'liga'; 38 | } 39 | -------------------------------------------------------------------------------- /src/Gistlyn.AppWinForms/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Gistlyn.AppWinForms.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.5.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceInterface/NotifierProxy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Gistlyn.ServiceModel.Types; 3 | using Gistlyn.SnippetEngine; 4 | using ServiceStack; 5 | 6 | namespace Gistlyn.ServiceInterface 7 | { 8 | public class NotifierProxy : MarshalByRefObject, INotifier 9 | { 10 | readonly IServerEvents serverEvents; 11 | readonly string subscriptionId; 12 | const string channel = "gist"; 13 | 14 | public NotifierProxy(IServerEvents serverEvents, string subscriptionId) 15 | { 16 | this.serverEvents = serverEvents; 17 | this.subscriptionId = subscriptionId; 18 | } 19 | 20 | public override object InitializeLifetimeService() 21 | { 22 | return null; 23 | } 24 | 25 | public void SendConsoleMessage(string message) 26 | { 27 | var consoleMessage = new ConsoleMessage { Message = message }; 28 | serverEvents.NotifySubscription(subscriptionId, consoleMessage, channel); 29 | } 30 | 31 | public void SendScriptExecutionResults(ScriptExecutionResult result) 32 | { 33 | serverEvents.NotifySubscription(subscriptionId, result, channel); 34 | } 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /src/Gistlyn.AppWinForms/FormMain.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | using CefSharp; 4 | using CefSharp.WinForms; 5 | using CefSharp.WinForms.Internals; 6 | 7 | namespace Gistlyn.AppWinForms 8 | { 9 | public partial class FormMain : Form 10 | { 11 | public ChromiumWebBrowser ChromiumBrowser { get; private set; } 12 | public FormMain() 13 | { 14 | InitializeComponent(); 15 | VerticalScroll.Visible = false; 16 | 17 | ChromiumBrowser = new ChromiumWebBrowser(Program.HostUrl) 18 | { 19 | Dock = DockStyle.Fill 20 | }; 21 | 22 | Controls.Add(ChromiumBrowser); 23 | 24 | Load += (sender, args) => 25 | { 26 | FormBorderStyle = FormBorderStyle.Sizable; 27 | Left = (int) (Screen.PrimaryScreen.WorkingArea.Width * .1); 28 | Top = (int)(Screen.PrimaryScreen.WorkingArea.Height * .1); 29 | Width = (int) (Screen.PrimaryScreen.WorkingArea.Width * .8); 30 | Height = (int) (Screen.PrimaryScreen.WorkingArea.Height * .8); 31 | }; 32 | 33 | ChromiumBrowser.RegisterJsObject("nativeHost", new NativeHost(this)); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Gistlyn.AppWinForms/platform.js: -------------------------------------------------------------------------------- 1 | /* winforms */ 2 | document.documentElement.className += ' winforms'; 3 | 4 | document.write(''); 8 | 9 | window.updateAvailable = function () { 10 | setTimeout(function () { 11 | document.getElementById("alertUpdate").style.display = 'block'; 12 | }, 500); 13 | }; 14 | window.updateNow = function () { 15 | setTimeout(function () { 16 | document.getElementById("alertUpdate").innerHTML = 'Applying update.. Please wait, application will restart..'; 17 | }, 500); 18 | window.nativeHost.performUpdate(); 19 | }; 20 | window.closeUpdate = function (e) { 21 | document.getElementById("alertUpdate").style.display = 'none'; 22 | }; 23 | 24 | window.onresize = function () { 25 | console.log('onresize'); 26 | document.getElementById("content").style.height = '85%'; 27 | setTimeout(function() { 28 | document.getElementById("content").style.height = '100%'; 29 | }, 0); 30 | }; 31 | 32 | window.nativeHost.ready(); 33 | -------------------------------------------------------------------------------- /src/Gistlyn.AppWinForms/AppHost.cs: -------------------------------------------------------------------------------- 1 | using Funq; 2 | using ServiceStack; 3 | using Gistlyn.Resources; 4 | using Gistlyn.ServiceInterface; 5 | 6 | namespace Gistlyn.AppWinForms 7 | { 8 | public class AppHost : AppSelfHostBase 9 | { 10 | /// 11 | /// Default constructor. 12 | /// Base constructor requires a name and assembly to locate web service classes. 13 | /// 14 | public AppHost() 15 | : base("Gistlyn.AppWinForms", typeof(RunScriptService).Assembly) 16 | { 17 | AppSettings = SharedAppHostConfig.GetMemoryAppSettings(); 18 | } 19 | 20 | /// 21 | /// Application specific configuration 22 | /// This method should initialize any IoC resources utilized by your web service classes. 23 | /// 24 | /// 25 | public override void Configure(Container container) 26 | { 27 | SetConfig(new HostConfig 28 | { 29 | EmbeddedResourceBaseTypes = { typeof(AppHost), typeof(SharedEmbeddedResources) }, 30 | }); 31 | 32 | var packagesPath = "~/packages".MapAbsolutePath(); 33 | SharedAppHostConfig.Configure(this, packagesPath); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceInterface/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Gistlyn.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Gistlyn")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Gistlyn")] 13 | [assembly: AssemblyCopyright("Copyright (c) 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Revision and Build Numbers 30 | // by using the '*' as shown below: 31 | [assembly: AssemblyVersion("1.0.0.0")] 32 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /src/Gistlyn/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Gistlyn")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Gistlyn")] 13 | [assembly: AssemblyCopyright("Copyright (c) 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Revision and Build Numbers 30 | // by using the '*' as shown below: 31 | [assembly: AssemblyVersion("1.0.0")] 32 | [assembly: AssemblyFileVersion("1.0.0")] 33 | -------------------------------------------------------------------------------- /src/Gistlyn.AppConsole/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Gistlyn")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Gistlyn")] 13 | [assembly: AssemblyCopyright("Copyright (c) 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Revision and Build Numbers 30 | // by using the '*' as shown below: 31 | [assembly: AssemblyVersion("1.0.0.0")] 32 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /src/Gistlyn.Resources/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Gistlyn")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Gistlyn")] 13 | [assembly: AssemblyCopyright("Copyright (c) 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Revision and Build Numbers 30 | // by using the '*' as shown below: 31 | [assembly: AssemblyVersion("1.0.0.0")] 32 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Gistlyn")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Gistlyn")] 13 | [assembly: AssemblyCopyright("Copyright (c) 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Revision and Build Numbers 30 | // by using the '*' as shown below: 31 | [assembly: AssemblyVersion("1.0.0.0")] 32 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /src/Gistlyn.ServiceInterface/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Gistlyn")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Gistlyn")] 13 | [assembly: AssemblyCopyright("Copyright (c) 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Revision and Build Numbers 30 | // by using the '*' as shown below: 31 | [assembly: AssemblyVersion("1.0.0.0")] 32 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /src/Gistlyn.Tests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Gistlyn.AppMac/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDisplayName 6 | Gistlyn 7 | CFBundleIdentifier 8 | com.your-company.Gistlyn 9 | CFBundleName 10 | Gistlyn 11 | CFBundleVersion 12 | 1 13 | LSMinimumSystemVersion 14 | 10.6 15 | NSMainNibFile 16 | MainMenu 17 | NSPrincipalClass 18 | NSApplication 19 | CFBundleIconFile 20 | logo 21 | CFBundleShortVersionString 22 | 1 23 | NSAppTransportSecurity 24 | 25 | NSExceptionDomains 26 | 27 | localhost 28 | 29 | NSTemporaryExceptionAllowsInsecureHTTPSLoads 30 | 31 | NSIncludesSubdomains 32 | 33 | NSTemporaryExceptionAllowsInsecureHTTPLoads 34 | 35 | NSTemporaryExceptionMinimumTLSVersion 36 | 1.0 37 | NSTemporaryExceptionRequiresForwardSecrecy 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/Gistlyn/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /src/Gistlyn.AppWinForms/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Gistlyn")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("ServiceStack")] 12 | [assembly: AssemblyProduct("Gistlyn")] 13 | [assembly: AssemblyCopyright("Copyright (c) 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Version information for an assembly consists of the following four values: 23 | // 24 | // Major Version 25 | // Minor Version 26 | // Build Number 27 | // Revision 28 | // 29 | // You can specify all the values or you can default the Revision and Build Numbers 30 | // by using the '*' as shown below: 31 | [assembly: AssemblyVersion("1.0.0")] 32 | [assembly: AssemblyFileVersion("1.0.0")] 33 | [assembly: AssemblyMetadata("SquirrelAwareVersion", "1")] 34 | -------------------------------------------------------------------------------- /src/Gistlyn/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /src/Gistlyn.AppMac/MainWindowController.cs: -------------------------------------------------------------------------------- 1 | 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using Foundation; 6 | using AppKit; 7 | 8 | namespace Gistlyn.AppMac 9 | { 10 | public partial class MainWindowController : AppKit.NSWindowController 11 | { 12 | #region Constructors 13 | 14 | // Called when created from unmanaged code 15 | public MainWindowController(IntPtr handle) : base(handle) 16 | { 17 | Initialize(); 18 | } 19 | 20 | // Called when created directly from a XIB file 21 | [Export ("initWithCoder:")] 22 | public MainWindowController(NSCoder coder) : base(coder) 23 | { 24 | Initialize(); 25 | } 26 | 27 | // Call to load from the XIB/NIB file 28 | public MainWindowController() : base ("MainWindow") 29 | { 30 | Initialize(); 31 | } 32 | 33 | // Shared initialization code 34 | void Initialize() 35 | { 36 | DisplayAtCenter(); 37 | } 38 | 39 | #endregion 40 | 41 | //Strong Typed Window Property 42 | public new MainWindow Window 43 | { 44 | get { return (MainWindow)base.Window; } 45 | } 46 | 47 | public void DisplayAtCenter() 48 | { 49 | var xPos = Window.Screen.Frame.Width / 2 - Window.Frame.Width / 2; 50 | var yPos = Window.Screen.Frame.Height / 2 - Window.Frame.Height / 2; 51 | Window.SetFrame(new CoreGraphics.CGRect(xPos, yPos, Window.Frame.Width, Window.Frame.Height), display:true); 52 | } 53 | 54 | public void Hide() 55 | { 56 | Window.OrderOut(Window); 57 | } 58 | } 59 | } 60 | 61 | -------------------------------------------------------------------------------- /src/Gistlyn/src/Console.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | export default class Console extends React.Component { 4 | consoleScroll: HTMLDivElement; 5 | 6 | componentDidUpdate() { 7 | if (!this.consoleScroll) return; 8 | this.consoleScroll.scrollTop = this.consoleScroll.scrollHeight; 9 | } 10 | 11 | render() { 12 | return ( 13 |
this.consoleScroll = el}> 14 | 15 | console 16 | this.props.showDialog("console-viewer")}>open_in_new 18 | 19 | this.props.onClear() }>clear 20 |
21 | 22 | 23 | {this.props.logs.map(log => ( 24 | 25 | 26 | 27 | ))} 28 | 29 |
{log.msg}
30 |
31 |
); 32 | } 33 | } -------------------------------------------------------------------------------- /src/Gistlyn.ServiceInterface/CacheExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Service Stack LLC. All Rights Reserved. 2 | // License: https://raw.github.com/ServiceStack/ServiceStack/master/license.txt 3 | 4 | using System.Collections.Generic; 5 | using ServiceStack; 6 | using ServiceStack.Caching; 7 | 8 | namespace Gistlyn.ServiceInterface 9 | { 10 | public static class CacheExtensions 11 | { 12 | const string ScriptPrefix = "script:"; 13 | 14 | private static string GetScriptCacheKey(string scriptId) 15 | { 16 | var cacheKey = scriptId.StartsWith(ScriptPrefix) 17 | ? scriptId 18 | : ScriptPrefix + scriptId; 19 | return cacheKey; 20 | } 21 | 22 | public static void SetScriptRunnerInfo(this ICacheClient cache, string scriptId, ScriptRunnerInfo info) 23 | { 24 | var cacheKey = GetScriptCacheKey(scriptId); 25 | cache.Set(cacheKey, info); 26 | } 27 | 28 | public static ScriptRunnerInfo GetScriptRunnerInfo(this ICacheClient cache, string scriptId) 29 | { 30 | if (scriptId == null) 31 | return null; 32 | 33 | var cacheKey = GetScriptCacheKey(scriptId); 34 | return cache.Get(cacheKey); 35 | } 36 | 37 | public static void RemoveScriptRunnerInfo(this ICacheClient cache, string scriptId) 38 | { 39 | var cacheKey = GetScriptCacheKey(scriptId); 40 | cache.Remove(cacheKey); 41 | } 42 | 43 | public static IEnumerable GetAllScriptKeys(this ICacheClient cache) 44 | { 45 | return cache.GetKeysStartingWith(ScriptPrefix); 46 | } 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /src/Gistlyn/src/assets/css/reset.css: -------------------------------------------------------------------------------- 1 | html, body, div, span, applet, object, iframe, 2 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 3 | a, abbr, acronym, address, big, cite, code, 4 | del, dfn, em, img, ins, kbd, q, s, samp, 5 | small, strike, strong, sub, sup, tt, var, 6 | b, u, i, center, dl, dt, dd, ol, ul, li, 7 | fieldset, form, label, legend, 8 | table, caption, tbody, tfoot, thead, tr, th, td, 9 | article, aside, canvas, details, embed, 10 | figure, figcaption, footer, header, hgroup, 11 | menu, nav, output, ruby, section, summary, 12 | time, mark, audio, video { 13 | margin: 0; 14 | padding: 0; 15 | border: 0; 16 | font-size: 100%; 17 | font: inherit; 18 | vertical-align: baseline; 19 | } 20 | article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { 21 | display: block; 22 | } 23 | body { 24 | line-height: 1; 25 | } 26 | ol, ul { 27 | list-style: none; 28 | } 29 | table { 30 | border-collapse: collapse; 31 | border-spacing: 0; 32 | } 33 | 34 | /* Custom */ 35 | ::selection { 36 | background: #0371BE; /* WebKit/Blink Browsers */ 37 | color: #f7f7f7; 38 | } 39 | ::-moz-selection { 40 | background: #0371BE; /* Gecko Browsers */ 41 | color: #f7f7f7; 42 | } 43 | ::-webkit-scrollbar { 44 | width: 5px; 45 | height: 5px; 46 | } 47 | 48 | ::-webkit-scrollbar-track { 49 | } 50 | 51 | ::-webkit-scrollbar-thumb { 52 | background-color: #ccc; 53 | } 54 | 55 | .console-viewer ::-webkit-scrollbar-thumb { 56 | background-color: #555; 57 | } 58 | 59 | .noselect { 60 | -webkit-touch-callout: none; /* iOS Safari */ 61 | -webkit-user-select: none; /* Chrome/Safari/Opera */ 62 | -moz-user-select: none; /* Firefox */ 63 | -ms-user-select: none; /* IE/Edge */ 64 | user-select: none; /* non-prefixed version, currently 65 | not supported by any browser */ 66 | } 67 | -------------------------------------------------------------------------------- /src/Gistlyn/src/TestClient.tsx: -------------------------------------------------------------------------------- 1 | import * as ReactDOM from 'react-dom'; 2 | import * as React from 'react'; 3 | 4 | import { JsonServiceClient, IReturn, nameOf } from '@servicestack/client'; 5 | import { Hello, HelloResponse } from './Gistlyn.dtos'; 6 | 7 | export class a implements IReturn 8 | { 9 | name: string; 10 | createResponse() { return new HelloResponse(); } 11 | getTypeName() { return "Hello2"; } 12 | } 13 | 14 | console.log('Hello', nameOf(new Hello())); 15 | console.log('Hello2', nameOf(new a())); 16 | 17 | var client = new JsonServiceClient("/"); 18 | 19 | class Test extends React.Component { 20 | 21 | componentWillMount(): void { 22 | this.state = { result: 'loading...' }; 23 | //this.loadGist("6831799881c92434f80e141c8a2699eb"); 24 | 25 | //const request = new Hello(); 26 | //request.name = "World"; 27 | 28 | //client.get(request) 29 | // .then(r => { 30 | // console.log(r); 31 | // this.setState({ result: r.result }); 32 | // }) 33 | // .catch(r => { 34 | // console.log('error', r); 35 | // }); 36 | } 37 | 38 | loadGist(gist) { 39 | fetch("https://api.github.com/gists/" + gist) 40 | .then((r) => { 41 | r.json().then((result) => { 42 | console.log(result); 43 | 44 | var sb = []; 45 | for (let k in result.files) { 46 | var file = result.files[k]; 47 | sb.push(file.filename); 48 | } 49 | 50 | this.setState({ result: sb.join(', ') }); 51 | }); 52 | }); 53 | } 54 | 55 | render() { 56 | return (
{this.state.result}
); 57 | } 58 | } 59 | 60 | ReactDOM.render( 61 | , 62 | document.getElementById("app")); 63 | -------------------------------------------------------------------------------- /src/GistlynMac.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gistlyn.AppMac", "Gistlyn.AppMac\Gistlyn.AppMac.csproj", "{318B96DE-9A31-42A9-8241-84D14472F078}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gistlyn.ServiceModel", "Gistlyn.ServiceModel\Gistlyn.ServiceModel.csproj", "{08BEF328-AB7D-48D3-800D-48ACC75C7914}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gistlyn.ServiceInterface", "Gistlyn.ServiceInterface\Gistlyn.ServiceInterface.csproj", "{582DFB0F-F84D-4E43-9BCA-2A5A86600B7A}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {08BEF328-AB7D-48D3-800D-48ACC75C7914}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {08BEF328-AB7D-48D3-800D-48ACC75C7914}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {08BEF328-AB7D-48D3-800D-48ACC75C7914}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {08BEF328-AB7D-48D3-800D-48ACC75C7914}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {318B96DE-9A31-42A9-8241-84D14472F078}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {318B96DE-9A31-42A9-8241-84D14472F078}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {318B96DE-9A31-42A9-8241-84D14472F078}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {318B96DE-9A31-42A9-8241-84D14472F078}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {582DFB0F-F84D-4E43-9BCA-2A5A86600B7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {582DFB0F-F84D-4E43-9BCA-2A5A86600B7A}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {582DFB0F-F84D-4E43-9BCA-2A5A86600B7A}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {582DFB0F-F84D-4E43-9BCA-2A5A86600B7A}.Release|Any CPU.Build.0 = Release|Any CPU 28 | EndGlobalSection 29 | EndGlobal 30 | -------------------------------------------------------------------------------- /src/Gistlyn/src/EditGistDialog.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | export default class EditGistDialog extends React.Component { 4 | txtDescription: HTMLInputElement; 5 | 6 | render() { 7 | var description = this.props.description; 8 | if (this.txtDescription) { 9 | description = this.txtDescription.value; 10 | } else { 11 | setTimeout(() => this.txtDescription.select(), 0); 12 | } 13 | 14 | return (
this.props.onHide() } onKeyDown={e => e.keyCode === 27 ? this.props.onHide() : null }> 15 |
this.props.dialogRef(e) } onClick={e => e.stopPropagation() }> 16 |
17 | this.props.onHide() }>close 18 | Edit Gist 19 |
20 |
21 |
22 | 23 | this.txtDescription = e} type="text" id="txtDescription" 24 | defaultValue={ description } 25 | onKeyUp={e => this.forceUpdate() } 26 | onKeyDown={e => e.keyCode == 13 && description ? this.props.onSave({ description }) : null } 27 | autoFocus /> 28 |
29 |
30 |
31 | 32 | description ? this.props.onSave({ description }) : null }> 34 | Save 35 | 36 |
37 |
38 |
); 39 | } 40 | } -------------------------------------------------------------------------------- /src/Gistlyn/src/ConsoleViewerDialog.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | export default class ConsoleViewerDialog extends React.Component { 4 | dialog: HTMLDivElement; 5 | 6 | render() { 7 | setTimeout(() => this.dialog && (this.dialog.scrollTop = this.dialog.scrollHeight), 0); 8 | 9 | return (
this.props.onHide() } onKeyDown={e => e.keyCode === 27 ? this.props.onHide() : null }> 10 |
this.props.dialogRef(this.dialog = e) } onClick={e => e.stopPropagation() } 11 | style={{ maxHeight: "90%", maxWidth: "90%", overflow: "auto", borderRadius: 0 }}> 12 |
13 | this.props.onHide() }>close 14 | this.dialog.scrollTop = this.dialog.scrollHeight}>scroll down 15 | this.props.onClear() }>clear 16 | Console Logs 17 |
18 |
20 | 21 | 22 | {this.props.logs.map(log => ( 23 | 24 | 25 | 26 | )) } 27 | 28 |
{log.msg}
29 |
30 |
31 |

32 | this.props.onHide() }>close 33 | this.dialog.scrollTop = 0}>scroll up 34 |

35 |
36 |
37 |
); 38 | } 39 | } -------------------------------------------------------------------------------- /src/Gistlyn.AppWinForms/FormMain.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace Gistlyn.AppWinForms 2 | { 3 | partial class FormMain 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain)); 32 | this.SuspendLayout(); 33 | // 34 | // FormMain 35 | // 36 | this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); 37 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 38 | this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 39 | this.BackColor = System.Drawing.Color.White; 40 | this.ClientSize = new System.Drawing.Size(426, 403); 41 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 42 | this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); 43 | this.Name = "FormMain"; 44 | this.ShowIcon = false; 45 | this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; 46 | this.Text = "Gistlyn"; 47 | this.ResumeLayout(false); 48 | 49 | } 50 | 51 | #endregion 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /src/Gistlyn/webpack.config.vendor.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const VENDOR = [ 4 | 'bootstrap/dist/css/bootstrap.css', 5 | 'font-awesome/css/font-awesome.css', 6 | 'es6-shim', 7 | 'classnames', 8 | 'react', 9 | 'react-dom', 10 | 'react-router-dom', 11 | '@servicestack/client' 12 | ]; 13 | 14 | const path = require('path'), 15 | webpack = require('webpack'), 16 | ExtractTextPlugin = require('extract-text-webpack-plugin'), 17 | Clean = require('clean-webpack-plugin'); 18 | 19 | module.exports = (env) => { 20 | const extractCSS = new ExtractTextPlugin('vendor.dll.css'); 21 | const isDev = !(env && env.prod); 22 | return [{ 23 | entry: { vendor: VENDOR }, 24 | stats: { modules: false }, 25 | resolve: { 26 | extensions: [ '.js' ] 27 | }, 28 | module: { 29 | rules: [ 30 | { test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, use: 'url-loader?limit=100000' }, 31 | { test: /\.css(\?|$)/, use: extractCSS.extract([ isDev ? 'css-loader' : 'css-loader?minimize' ]) } 32 | ] 33 | }, 34 | devtool: "source-map", 35 | output: { 36 | path: root('wwwroot/dist'), 37 | publicPath: 'dist/', 38 | filename: '[name].dll.js', 39 | library: '[name]_[hash]', 40 | }, 41 | plugins: [ 42 | new Clean([root('wwwroot/dist')]), 43 | extractCSS, 44 | new webpack.DllPlugin({ 45 | path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'), 46 | name: '[name]_[hash]' 47 | }), 48 | new webpack.DefinePlugin({ 49 | 'process.env.NODE_ENV': isDev ? '"development"' : '"production"' 50 | }) 51 | ].concat(isDev ? [] : [ 52 | new webpack.optimize.UglifyJsPlugin({ sourceMap: true }), 53 | new Clean([root('bin/Release/netcoreapp2.0/publish/wwwroot/dist')]), 54 | ]) 55 | }]; 56 | 57 | //helpers 58 | function root(args) { 59 | args = Array.prototype.slice.call(arguments, 0); 60 | return (path || (path = require("path"))).join.apply(path, [__dirname].concat(args)); 61 | } 62 | }; 63 | 64 | -------------------------------------------------------------------------------- /src/Gistlyn/src/InadequateBrowserDialog.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | export default class InadequateBrowserDialog extends React.Component { 4 | render() { 5 | return (
11 |
12 |

13 | If you're seeing this message your browser still doesn't have native support for 14 | 15 | Server Sent Events (SSE) 16 | 17 | - a simple 18 | 19 | Web Standard 20 | 21 | supported by most modern browsers since 2011. If you would like this site to 22 | work in Internet Explorer or MS Edge browsers 23 | 24 | vote to have them implement it. 25 | 26 |

27 | 28 |
29 |

30 | In the meantime we recommend using these better browsers below: 31 |

32 | 33 | 39 |
40 |
); 41 | } 42 | } -------------------------------------------------------------------------------- /src/Gistlyn.AppWinForms/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using System.Windows.Forms; 7 | using CefSharp; 8 | using ServiceStack; 9 | using ServiceStack.Text; 10 | using Squirrel; 11 | 12 | namespace Gistlyn.AppWinForms 13 | { 14 | static class Program 15 | { 16 | public static string HostUrl = "http://localhost:4000/"; 17 | public static AppHost AppHost; 18 | public static FormMain Form; 19 | 20 | /// 21 | /// The main entry point for the application. 22 | /// 23 | [STAThread] 24 | static void Main() 25 | { 26 | AppHost = new AppHost(); 27 | SquirrelAwareApp.HandleEvents( 28 | OnInitialInstall, 29 | OnAppUpdate, 30 | onAppUninstall: OnAppUninstall, 31 | onFirstRun: OnFirstRun); 32 | 33 | Cef.EnableHighDPISupport(); 34 | 35 | var cacheFolder = Path.Combine(Path.GetTempPath(), "gistlyn-cache"); 36 | Cef.Initialize(new CefSettings { 37 | CachePath = cacheFolder //persist localStorage + Cookies 38 | }); 39 | 40 | Application.EnableVisualStyles(); 41 | Application.SetCompatibleTextRenderingDefault(false); 42 | 43 | AppHost.Init().Start("http://*:4000/"); 44 | "ServiceStack SelfHost listening at {0} ".Fmt(HostUrl).Print(); 45 | Form = new FormMain(); 46 | Form.Disposed += (sender, args) => AppUpdater.Dispose(); 47 | Application.Run(Form); 48 | } 49 | 50 | public static void OnInitialInstall(Version version) 51 | { 52 | // Hook for first install 53 | AppUpdater.CreateShortcutForThisExe(); 54 | } 55 | 56 | public static void OnAppUpdate(Version version) 57 | { 58 | // Hook for application update, CheckForUpdates() initiates this. 59 | AppUpdater.CreateShortcutForThisExe(); 60 | } 61 | 62 | public static void OnAppUninstall(Version version) 63 | { 64 | // Hook for application uninstall 65 | AppUpdater.RemoveShortcutForThisExe(); 66 | } 67 | 68 | public static void OnFirstRun() 69 | { 70 | // Hook for first run 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/Gistlyn.SnippetEngine/GistSourceResolver.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Service Stack LLC. All Rights Reserved. 2 | // License: https://raw.github.com/ServiceStack/ServiceStack/master/license.txt 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Collections.Immutable; 7 | using System.IO; 8 | using Microsoft.CodeAnalysis; 9 | 10 | namespace Gistlyn.SnippetEngine 11 | { 12 | public class GistSourceResolver : SourceReferenceResolver 13 | { 14 | public string baseDirectory; 15 | private readonly ImmutableArray searchPaths; 16 | private readonly ImmutableArray> pathMap; 17 | private readonly Dictionary scripts = new Dictionary(); 18 | 19 | public Dictionary Scripts => scripts; 20 | 21 | public GistSourceResolver(List scripts) 22 | { 23 | int i = 1; 24 | foreach (var script in scripts) 25 | { 26 | this.scripts.Add(i.ToString(), script); 27 | i++; 28 | } 29 | } 30 | 31 | public override string NormalizePath(string path, string baseFilePath) 32 | { 33 | return path; 34 | } 35 | 36 | public override Stream OpenRead(string resolvedPath) 37 | { 38 | var code = scripts[resolvedPath]; 39 | var stream = new MemoryStream(System.Text.Encoding.ASCII.GetBytes(code)); 40 | return stream; 41 | } 42 | 43 | public override string ResolveReference(string path, string baseFilePath) 44 | { 45 | return path; 46 | } 47 | 48 | public override bool Equals(object obj) 49 | { 50 | // Explicitly check that we're not comparing against a derived type 51 | if (obj == null || GetType() != obj.GetType()) 52 | return false; 53 | 54 | return Equals((GistSourceResolver)obj); 55 | } 56 | 57 | public bool Equals(GistSourceResolver other) 58 | { 59 | return 60 | string.Equals(baseDirectory, other.baseDirectory, StringComparison.Ordinal) && 61 | scripts.Equals(other.scripts); 62 | } 63 | 64 | public override int GetHashCode() 65 | { 66 | return baseDirectory.GetHashCode() ^ scripts.GetHashCode(); 67 | } 68 | } 69 | } 70 | 71 | -------------------------------------------------------------------------------- /src/Gistlyn/src/SaveAsDialog.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | export default class SaveAsDialog extends React.Component { 4 | txtDescription: HTMLInputElement; 5 | 6 | render() { 7 | var description = this.props.description; 8 | if (this.txtDescription) { 9 | description = this.txtDescription.value; 10 | } else { 11 | setTimeout(() => this.txtDescription.select(), 0); 12 | } 13 | 14 | return (
this.props.onHide() } onKeyDown={e => e.keyCode === 27 ? this.props.onHide() : null }> 15 |
this.props.dialogRef(e) } onClick={e => e.stopPropagation() }> 16 |
17 | this.props.onHide() }>close 18 | {this.props.shouldFork ? "Fork" : "Save"} Gist 19 |
20 |
21 |
22 | 23 | this.txtDescription = e} type="text" id="txtDescription" 24 | defaultValue={ description } 25 | onKeyUp={e => this.forceUpdate() } 26 | onKeyDown={e => e.keyCode == 13 && description ? this.props.onSave({ description }) : null } 27 | autoFocus /> 28 |
29 |
30 | 31 | check 32 | Is {this.props.isPublic ? "public" : "private"} 33 |
34 |
35 |
36 | 37 | description ? this.props.onSave({ description }) : null }> 39 | Create {this.props.shouldFork ? "Fork" : "Gist"} 40 | 41 |
42 |
43 |
); 44 | } 45 | } -------------------------------------------------------------------------------- /src/Gistlyn/src/json-viewer.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | export interface IPrettyPrintProps { 4 | value?: any; 5 | json?: string; 6 | } 7 | 8 | export class JsonViewer extends React.Component { 9 | render() { 10 | const value = this.props.value || (this.props.json && JSON.parse(this.props.json)); 11 | return (
{val(value)}
); 12 | } 13 | } 14 | 15 | const show = (k) => typeof k !== "string" || k.substr(0, 2) !== "__"; 16 | const keyFmt = t => t; 17 | const uniqueKeys = (m: any[]): any => { 18 | var h = {}; 19 | for (var i = 0, len = m.length; i < len; i++) { 20 | for (let k in m[i]) { 21 | if (show(k)) 22 | h[k] = k; 23 | } 24 | } 25 | return h; 26 | }; 27 | 28 | var valueFmt = (k, v, vFmt) => vFmt; 29 | 30 | const num = (m) => m; 31 | const date = (s) => new Date(parseFloat(/Date\(([^)]+)\)/.exec(s)[1])); 32 | const pad = (d) => d < 10 ? '0' + d : d; 33 | const dmft = (d) => d.getFullYear() + '/' + pad(d.getMonth() + 1) + '/' + pad(d.getDate()); 34 | var str = (m) => m.substr(0, 6) === '/Date(' ? dmft(date(m)) : m; 35 | 36 | const obj = (m:any) => { 37 | return ( 38 |
39 | {Object.keys(m).filter(show).map(k => ( 40 | [
{keyFmt(k)}
,
{valueFmt(k, m[k], val(m[k]))}
] 41 | ))} 42 |
43 | ); 44 | } 45 | 46 | const arr = (m: any[]) => { 47 | if (typeof m[0] == 'string' || typeof m[0] == 'number') 48 | return {m.join(', ') }; 49 | 50 | var h = uniqueKeys(m); 51 | return ( 52 | 53 | 54 | 55 | 56 | {Object.keys(h).map(k => ()) } 57 | 58 | 59 | 60 | {m.map(row => ( 61 | 62 | {Object.keys(h).filter(show).map(k => ) } 63 | 64 | )) } 65 | 66 |
{keyFmt(k) }
{valueFmt(k, row[k], val(row[k])) }
67 | ); 68 | } 69 | 70 | const val = (m: any, valueFn: (k: string, v: any, vFmt: string) => string = null) => { 71 | if (valueFn) 72 | valueFmt = valueFn; 73 | if (m == null) return ""; 74 | if (typeof m == "number") return num(m); 75 | if (typeof m == "string") return str(m); 76 | if (typeof m == "boolean") return m ? "true" : "false"; 77 | return m.length ? arr(m) : obj(m); 78 | } 79 | -------------------------------------------------------------------------------- /src/Gistlyn.AppMac/AppHost.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Reflection; 4 | using System.Linq; 5 | using Funq; 6 | using ServiceStack; 7 | using ServiceStack.Text; 8 | using ServiceStack.Auth; 9 | using ServiceStack.Redis; 10 | using AppKit; 11 | using Gistlyn.ServiceInterface; 12 | using Gistlyn.Resources; 13 | 14 | namespace Gistlyn.AppMac 15 | { 16 | public class AppHost : AppSelfHostBase 17 | { 18 | /// 19 | /// Default constructor. 20 | /// Base constructor requires a name and assembly to locate web service classes. 21 | /// 22 | public AppHost() 23 | : base("Gistlyn.AppMac", typeof(RunScriptService).Assembly) {} 24 | 25 | /// 26 | /// Application specific configuration 27 | /// This method should initialize any IoC resources utilized by your web service classes. 28 | /// 29 | /// 30 | public override void Configure(Container container) 31 | { 32 | //Config examples 33 | //this.Plugins.Add(new PostmanFeature()); 34 | //Plugins.Add(new CorsFeature()); 35 | 36 | SetConfig(new HostConfig { 37 | DebugMode = true, 38 | EmbeddedResourceBaseTypes = { typeof(AppHost), typeof(SharedEmbeddedResources) } 39 | }); 40 | 41 | SharedAppHostConfig.Configure(this, "~/packages".MapAbsolutePath()); 42 | 43 | Routes.Add("/nativehost/{Action}"); 44 | ServiceController.RegisterService(typeof(NativeHostService)); 45 | } 46 | } 47 | 48 | public class NativeHostService : Service 49 | { 50 | public void Any(NativeHostAction request) 51 | { 52 | if (string.IsNullOrEmpty(request.Action)) 53 | throw HttpError.NotFound ("Function Not Found"); 54 | 55 | var nativeHost = typeof(NativeHost).CreateInstance(); 56 | var methodName = request.Action.Substring(0, 1).ToUpper() + request.Action.Substring(1); 57 | var methodInfo = typeof(NativeHost).GetMethod(methodName); 58 | if (methodInfo == null) 59 | throw new HttpError(HttpStatusCode.NotFound,"Function Not Found"); 60 | 61 | methodInfo.Invoke(nativeHost, null); 62 | } 63 | } 64 | 65 | public class NativeHostAction : IReturnVoid 66 | { 67 | public string Action { get; set; } 68 | } 69 | 70 | public class NativeHost 71 | { 72 | public void ShowAbout() 73 | { 74 | //Invoke native about menu item programmatically. 75 | Program.MainMenu.InvokeOnMainThread (() => { 76 | foreach (var item in Program.MainMenu.ItemArray()) { 77 | if (item.Title == "Gistlyn") { 78 | item.Submenu.PerformActionForItem(0); 79 | return; 80 | } 81 | } 82 | }); 83 | } 84 | 85 | public void Quit() 86 | { 87 | Program.MainMenu.InvokeOnMainThread (() => { 88 | NSApplication.SharedApplication.Terminate(NSApplication.SharedApplication); 89 | }); 90 | } 91 | } 92 | } 93 | 94 | -------------------------------------------------------------------------------- /src/Gistlyn.AppWinForms/AppUpdater.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using ServiceStack; 6 | using ServiceStack.Configuration; 7 | using Squirrel; 8 | 9 | namespace Gistlyn.AppWinForms 10 | { 11 | public static class AppUpdater 12 | { 13 | private static UpdateManager updateManagerInstance; 14 | 15 | public static UpdateManager AppUpdateManager 16 | { 17 | get 18 | { 19 | if (updateManagerInstance != null) 20 | return updateManagerInstance; 21 | 22 | var appSettings = new AppSettings(); 23 | var updateManagerTask = 24 | UpdateManager.GitHubUpdateManager(appSettings.GetString("UpdateManagerUrl")); 25 | updateManagerTask.Wait(TimeSpan.FromMinutes(1)); 26 | updateManagerInstance = updateManagerTask.Result; 27 | return updateManagerInstance; 28 | } 29 | } 30 | 31 | public static void Dispose() 32 | { 33 | if (updateManagerInstance != null) 34 | { 35 | updateManagerInstance.Dispose(); 36 | } 37 | } 38 | 39 | public static async Task CheckForUpdates(string deployUrl) 40 | { 41 | #if DEBUG 42 | // Copy Squirrel.exe and rename to Update.exe for debugging, 43 | // see https://github.com/Squirrel/Squirrel.Windows/blob/master/docs/using/debugging-updates.md#updateexe-not-found 44 | if (!File.Exists("..\\Update.exe")) 45 | { 46 | var squirrelExe = Directory.GetFiles( 47 | "..\\..\\..\\..\\packages\\", "Squirrel.exe", SearchOption.AllDirectories) 48 | .ToList().FirstNonDefault(); 49 | if (squirrelExe != null) 50 | { 51 | File.Copy( 52 | squirrelExe.MapHostAbsolutePath(), 53 | "..\\Update.exe"); 54 | } 55 | } 56 | #endif 57 | try 58 | { 59 | var updateInfo = await AppUpdateManager.CheckForUpdate(); 60 | if (updateInfo.ReleasesToApply.Count > 0) 61 | { 62 | return true; 63 | } 64 | } 65 | catch (Exception) 66 | { 67 | // Update failed. 68 | } 69 | return false; 70 | } 71 | 72 | public static async Task ApplyUpdates(string deployUrl) 73 | { 74 | var result = await AppUpdateManager.UpdateApp(); 75 | return result; 76 | } 77 | 78 | public static void CreateShortcutForThisExe() 79 | { 80 | AppUpdateManager.CreateShortcutForThisExe(); 81 | } 82 | 83 | public static void RemoveShortcutForThisExe() 84 | { 85 | AppUpdateManager.RemoveShortcutForThisExe(); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/Gistlyn.AppWinForms/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Gistlyn.AppWinForms.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Gistlyn.AppWinForms.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Gistlyn.AppConsole/AppHost.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using Funq; 6 | using ServiceStack; 7 | using Gistlyn.Resources; 8 | using Gistlyn.ServiceInterface; 9 | using ServiceStack.Configuration; 10 | 11 | namespace Gistlyn.AppConsole 12 | { 13 | public class AppHost : AppSelfHostBase 14 | { 15 | /// 16 | /// Default constructor. 17 | /// Base constructor requires a name and assembly to locate web service classes. 18 | /// 19 | public AppHost() 20 | : base("Gistlyn.AppConsole", typeof(RunScriptService).Assembly) 21 | { 22 | AppSettings = SharedAppHostConfig.GetMemoryAppSettings(); 23 | } 24 | 25 | /// 26 | /// Application specific configuration 27 | /// This method should initialize any IoC resources utilized by your web service classes. 28 | /// 29 | /// 30 | public override void Configure(Container container) 31 | { 32 | SetConfig(new HostConfig 33 | { 34 | EmbeddedResourceBaseTypes = { typeof(AppHost), typeof(SharedEmbeddedResources) }, 35 | }); 36 | 37 | SharedAppHostConfig.Configure(this, "~/packages".MapAbsolutePath()); 38 | 39 | // This route is added using Routes.Add and ServiceController.RegisterService due to 40 | // using ILMerge limiting our AppHost : base() call to one assembly. 41 | // If two assemblies are used, the base() call searchs the same assembly twice due to the ILMerged result. 42 | Routes.Add("/nativehost/{Action}"); 43 | ServiceController.RegisterService(typeof(NativeHostService)); 44 | } 45 | } 46 | 47 | public class NativeHostService : Service 48 | { 49 | public void Any(NativeHostAction request) 50 | { 51 | if (string.IsNullOrEmpty(request.Action)) 52 | throw HttpError.NotFound("Function Not Found"); 53 | 54 | var nativeHost = typeof(NativeHost).CreateInstance(); 55 | var methodName = request.Action.Substring(0, 1).ToUpper() + request.Action.Substring(1); 56 | var methodInfo = typeof(NativeHost).GetMethod(methodName); 57 | if (methodInfo == null) 58 | throw new HttpError(HttpStatusCode.NotFound, "Function Not Found"); 59 | 60 | methodInfo.Invoke(nativeHost, null); 61 | } 62 | } 63 | 64 | public class NativeHostAction : IReturnVoid 65 | { 66 | public string Action { get; set; } 67 | } 68 | 69 | public class NativeHost 70 | { 71 | public void Quit() 72 | { 73 | System.Threading.ThreadPool.QueueUserWorkItem(_ => 74 | { 75 | System.Threading.Thread.Sleep(10); // Allow /nativehost/quit to return gracefully 76 | Environment.Exit(0); 77 | }); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/Gistlyn/src/assets/css/editor.css: -------------------------------------------------------------------------------- 1 | 2 | #editor { 3 | display: flex; 4 | flex-flow: column; 5 | flex: 1; 6 | overflow: auto; 7 | color: #000; 8 | background: url(../img/editor-bg.png); /* needed in CEF */ 9 | } 10 | .safari #editor { 11 | overflow: hidden; /* hide double scrollbars with Safari height fix*/ 12 | } 13 | 14 | #tabs { 15 | display: flex; 16 | flex-flow: row; 17 | background: #01215A; 18 | padding: 8px 0 0 6px; 19 | min-height: 24px; 20 | } 21 | #tabs #files-menu { 22 | color: #ddd; 23 | cursor: pointer; 24 | width: 24px; 25 | } 26 | #tabs #files-menu:hover { 27 | color: #ffc; 28 | } 29 | #tabs .delete { 30 | font-size: 16px; 31 | vertical-align: bottom; 32 | padding: 0 0 0 5px; 33 | cursor: pointer; 34 | } 35 | #tabs .delete:hover { 36 | color: #f00; 37 | } 38 | .popup { 39 | display: none; 40 | position: absolute; 41 | z-index: 100; 42 | background: #0371BE; 43 | color: #f7f7f7; 44 | margin: 2px 2px; 45 | font-size: 14px; 46 | 47 | -webkit-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3); 48 | -moz-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3); 49 | box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3); 50 | -webkit-background-clip: padding-box; 51 | -moz-background-clip: padding-box; 52 | background-clip: padding-box; 53 | } 54 | .popup div { 55 | padding: 8px 10px; 56 | } 57 | .popup div:hover { 58 | background: #0488E4; 59 | cursor: pointer; 60 | } 61 | .popup a { 62 | display: block; 63 | color: #f7f7f7; 64 | text-decoration: none; 65 | } 66 | #tabs div { 67 | padding: 5px 8px; 68 | margin: 0 4px 0 0; 69 | background: #0371BE; 70 | color: #fff; 71 | font-size: 14px; 72 | cursor: pointer; 73 | } 74 | #tabs div.active { 75 | background: #fff; 76 | color: #444; 77 | margin-bottom: -1px; 78 | cursor: auto; 79 | } 80 | #tabs .txtFileName { 81 | border: none; 82 | padding: 0 2px; 83 | } 84 | 85 | #markdown-toolbar { 86 | margin: 0 0 2px 30px; 87 | box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3); 88 | z-index: 1; 89 | } 90 | 91 | #markdown-toolbar i { 92 | margin: 2px; 93 | vertical-align: middle; 94 | color: #666; 95 | cursor: pointer; 96 | border: solid 1px #fff; 97 | font-size: 30px; 98 | } 99 | #markdown-toolbar i:hover { 100 | border: solid 1px #c6c6c6; 101 | border-radius: 2px; 102 | background: #f8f8f8; 103 | } 104 | 105 | .owner #tabs { 106 | background: #4CAF50; 107 | } 108 | .owner #tabs div { 109 | background: #388E3C; 110 | } 111 | .owner #tabs div.active { 112 | background: #fff; 113 | } 114 | 115 | .dropzone { 116 | } 117 | .dropzone .droparea { 118 | background: #f1f1f1; 119 | border: 4px dashed #ccc; 120 | text-align: center; 121 | height: 250px; 122 | color: #aaa; 123 | cursor: pointer; 124 | } 125 | .dropzone-active .droparea { 126 | background: #ddd; 127 | border-color: #aaa; 128 | } 129 | .loading .dropzone .droparea { 130 | color: #ccc; 131 | } 132 | .dropzone .droparea p { 133 | font-size: 24px; 134 | margin: 110px 0 0 0; 135 | } 136 | -------------------------------------------------------------------------------- /src/Gistlyn/src/app.tsx: -------------------------------------------------------------------------------- 1 | import "./assets/css/iconfont/material-icons.css"; 2 | import "./assets/css/octicon/octicon.css"; 3 | 4 | import "./assets/css/reset.css"; 5 | import "./assets/css/app.css"; 6 | import "./assets/css/collections.css"; 7 | import "./assets/css/dialogs.css"; 8 | import "./assets/css/editor.css"; 9 | import "./assets/css/codemirror.css"; 10 | 11 | import "es6-shim"; 12 | 13 | import * as React from 'react'; 14 | import * as ReactDOM from 'react-dom'; 15 | import * as ReactGA from 'react-ga'; 16 | import { Provider, connect } from 'react-redux'; 17 | import { ServerEventsClient, ServerEventConnect, humanize } from '@servicestack/client'; 18 | 19 | import { GistlynApp } from './GistlynApp'; 20 | 21 | import { store } from './state'; 22 | import { client, statusToError, UA, BatchItems, evalExpression } from './utils'; 23 | import { GetScriptVariables, ScriptExecutionResult } from './Gistlyn.dtos'; 24 | 25 | import InadequateBrowserDialog from './InadequateBrowserDialog'; 26 | 27 | ReactGA.initialize("UA-80898009-1"); 28 | 29 | if (UA.nosse) { 30 | ReactGA.event({ category: 'error', action: 'load', label: "nosse" }); 31 | 32 | ReactDOM.render( 33 | , 34 | document.getElementById("app")); 35 | 36 | throw "This browser does not support Server Sent Events"; 37 | } 38 | 39 | const ScriptStatusError = ["Cancelled", "CompiledWithErrors", "ThrowedException"]; 40 | const batchLogs = new BatchItems(30, logs => store.dispatch({ type: 'CONSOLE_LOG', logs })); 41 | 42 | const channels = ["gist"]; 43 | const sse = new ServerEventsClient("/", channels, { 44 | handlers: { 45 | onConnect(activeSub: ServerEventConnect) { 46 | store.dispatch({ type: 'SSE_CONNECT', activeSub }); 47 | ReactGA.set({ userId: activeSub.userId }); 48 | fetch("/session-to-token", { method:"POST", credentials:"include" }); 49 | }, 50 | ConsoleMessage(m, e) { 51 | batchLogs.queue({ msg: m.message }); 52 | }, 53 | ScriptExecutionResult(m: ScriptExecutionResult, e) { 54 | if (m.status === store.getState().scriptStatus) return; 55 | 56 | if (ScriptStatusError.indexOf(m.status) >= 0 && m.errorResponseStatus) { 57 | batchLogs.queue(statusToError(m.errorResponseStatus)); 58 | } else { 59 | batchLogs.queue({ msg: humanize(m.status) }); 60 | } 61 | 62 | store.dispatch({ type: 'SCRIPT_STATUS', scriptStatus: m.status }); 63 | 64 | if (m.status === "CompiledWithErrors" && m.errors) { 65 | const errorMsgs = m.errors.map(e => ({ msg: e.info, cls: "error" })); 66 | errorMsgs.forEach(m => batchLogs.queue(m)); 67 | } else if (m.status === "Completed") { 68 | const request = new GetScriptVariables(); 69 | const state = store.getState(); 70 | request.scriptId = state.activeSub.id; 71 | client.get(request) 72 | .then(r => { 73 | store.dispatch({ type: "VARS_LOAD", variables: r.variables }); 74 | }); 75 | 76 | if (state.expression) { 77 | evalExpression(state.gist, state.activeSub.id, state.expression); 78 | } 79 | } 80 | } 81 | } 82 | }).start(); 83 | 84 | ReactDOM.render( 85 | 86 | 87 | , 88 | document.getElementById("app")); 89 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceInterface/DomainWrapper.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Service Stack LLC. All Rights Reserved. 2 | // License: https://raw.github.com/ServiceStack/ServiceStack/master/license.txt 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Threading; 7 | using Gistlyn.ServiceModel.Types; 8 | using Gistlyn.SnippetEngine; 9 | 10 | namespace Gistlyn.ServiceInterface 11 | { 12 | public class DomainWrapper : MarshalByRefObject 13 | { 14 | readonly ScriptRunner runner = new ScriptRunner(); 15 | string mainScript; 16 | List scripts; 17 | List references; 18 | CancellationTokenSource tokenSource; 19 | 20 | public string ScriptId { get; set; } 21 | 22 | public string MainScript => mainScript; 23 | 24 | public List Scripts => scripts; 25 | 26 | public List References => references; 27 | 28 | public override object InitializeLifetimeService() 29 | { 30 | return null; 31 | } 32 | 33 | public void Cancel() 34 | { 35 | tokenSource?.Cancel(true); 36 | } 37 | 38 | public ScriptExecutionResult EvaluateExpression(string expr, bool includeJson) 39 | { 40 | return runner.EvaluateExpression(expr, includeJson); 41 | } 42 | 43 | public ScriptStatus GetScriptStatus() 44 | { 45 | return runner.GetScriptStatus(); 46 | } 47 | 48 | public object GetVariableValue(string varName) 49 | { 50 | return runner.GetVariableValue(varName, out _); 51 | } 52 | 53 | public ScriptStateVariables GetVariables(string parentVariable) 54 | { 55 | return runner.GetVariables(parentVariable); 56 | } 57 | 58 | public ScriptExecutionResult Run(string mainScript, List scripts, List references, NotifierProxy writerProxy) 59 | { 60 | this.mainScript = mainScript; 61 | this.scripts = scripts; 62 | this.references = references; 63 | 64 | var result = new ScriptExecutionResult(); 65 | 66 | var tmp = Console.Out; 67 | using (var writer = new ConsoleWriter(writerProxy)) 68 | { 69 | Console.SetOut(writer); 70 | 71 | try 72 | { 73 | var task = runner.Execute(mainScript, scripts, references); 74 | //Session.SetScriptTask(task); 75 | result = task.Result; 76 | //ServerEvents.NotifySession(Session.GetSessionId(), result); 77 | } 78 | catch (Exception e) 79 | { 80 | result.Exception = e; 81 | } 82 | 83 | Console.SetOut(tmp); 84 | } 85 | 86 | return result; 87 | } 88 | 89 | public ScriptExecutionResult RunAsync(string mainScript, List scripts, List references, NotifierProxy writerProxy) 90 | { 91 | this.mainScript = mainScript; 92 | this.scripts = scripts; 93 | this.references = references; 94 | 95 | var writer = new ConsoleWriter(writerProxy); 96 | Console.SetOut(writer); 97 | 98 | tokenSource = new CancellationTokenSource(); 99 | var result = runner.ExecuteAsync(mainScript, scripts, references, writerProxy, tokenSource.Token); 100 | 101 | /*TextWriter tmp = Console.Out; 102 | task.ContinueWith((_) => 103 | { 104 | Console.SetOut(tmp); 105 | writer.Close(); 106 | });*/ 107 | 108 | return result; 109 | } 110 | } 111 | } 112 | 113 | -------------------------------------------------------------------------------- /src/Gistlyn/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Gistlyn", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "postinstall": "npm run build-vendor && npm run build", 7 | "dev": "webpack --config webpack.config.js --watch", 8 | "dev-server": "webpack-dev-server", 9 | "build": "webpack --config webpack.config.js", 10 | "build-prod": "webpack --config webpack.config.js --env.prod", 11 | "build-vendor": "webpack --config webpack.config.vendor.js", 12 | "publish": "webpack --config webpack.config.vendor.js --env.prod && npm run build-prod", 13 | "test": "jest", 14 | "test-watch": "jest --watch", 15 | "test-coverage": "jest --coverage", 16 | "dtos": "cd src && typescript-ref" 17 | }, 18 | "jest": { 19 | "globals": { 20 | "BaseUrl": "http://localhost:5000" 21 | }, 22 | "transform": { 23 | ".(ts|tsx)": "/node_modules/ts-jest/preprocessor.js" 24 | }, 25 | "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", 26 | "moduleFileExtensions": [ 27 | "ts", 28 | "tsx", 29 | "js" 30 | ], 31 | "moduleNameMapper": { 32 | "^.+\\.(css|scss|sass)$": "identity-obj-proxy", 33 | "^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/src/test.fileMock.js" 34 | }, 35 | "setupFiles": [ 36 | "/src/test.shim.js", 37 | "/src/test.setup.js" 38 | ] 39 | }, 40 | "dependencies": { 41 | "@servicestack/client": "^1.0.4", 42 | "bootstrap": "^4.0.0", 43 | "classnames": "^2.2.5", 44 | "codemirror": "^5.34.0", 45 | "es6-shim": "^0.35.3", 46 | "font-awesome": "^4.7.0", 47 | "marked": "^0.3.12", 48 | "octicons": "^7.1.0", 49 | "react": "^16.0.0", 50 | "react-codemirror": "^1.0.0", 51 | "react-dom": "^16.0.0", 52 | "react-dropzone": "^4.2.7", 53 | "react-ga": "^2.4.1", 54 | "react-redux": "^5.0.6", 55 | "react-router-dom": "^4.2.2", 56 | "redux": "^3.7.2" 57 | }, 58 | "devDependencies": { 59 | "@servicestack/cli": "^1.0.2", 60 | "@types/classnames": "^2.2.3", 61 | "@types/codemirror": "0.0.53", 62 | "@types/jest": "^21.1.10", 63 | "@types/marked": "^0.3.0", 64 | "@types/node": "^8.9.2", 65 | "@types/react": "^16.0.36", 66 | "@types/react-dom": "^16.0.2", 67 | "@types/react-dropzone": "^4.2.0", 68 | "@types/react-redux": "^5.0.14", 69 | "add-asset-html-webpack-plugin": "^2.1.2", 70 | "autoprefixer": "^7.2.6", 71 | "awesome-typescript-loader": "^3.2.3", 72 | "chalk": "^2.3.0", 73 | "clean-webpack-plugin": "^0.1.18", 74 | "copy-webpack-plugin": "^4.4.1", 75 | "css-loader": "^0.28.9", 76 | "del": "^2.2.2", 77 | "enzyme": "^3.3.0", 78 | "enzyme-adapter-react-16": "^1.1.1", 79 | "extract-text-webpack-plugin": "^3.0.2", 80 | "file-loader": "^1.1.6", 81 | "globule": "^1.1.0", 82 | "gulp": "^3.9.1", 83 | "gulp-msbuild": "^0.4.7", 84 | "gulp-newer": "^1.4.0", 85 | "gulp-nuget-pack": "^0.0.7", 86 | "gulp-nuget-restore": "^0.5.0", 87 | "gulp-util": "^3.0.7", 88 | "html-loader": "^0.5.5", 89 | "html-webpack-plugin": "^2.30.1", 90 | "identity-obj-proxy": "^3.0.0", 91 | "image-webpack-loader": "^3.6.0", 92 | "imports-loader": "^0.7.1", 93 | "jest": "^21.2.1", 94 | "node-sass": "^4.5.3", 95 | "null-loader": "^0.1.1", 96 | "postcss-loader": "^2.1.0", 97 | "precss": "^2.0.0", 98 | "react-test-renderer": "^16.0.0", 99 | "run-sequence": "^1.2.2", 100 | "sass-loader": "^6.0.6", 101 | "source-map-loader": "^0.2.3", 102 | "style-loader": "^0.19.1", 103 | "ts-jest": "^21.1.4", 104 | "typescript": "^2.7.1", 105 | "url-loader": "^0.6.2", 106 | "webpack": "^3.8.1", 107 | "webpack-dev-server": "^2.11.1" 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceInterface/RunScriptSupportServices.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Service Stack LLC. All Rights Reserved. 2 | // License: https://raw.github.com/ServiceStack/ServiceStack/master/license.txt 3 | 4 | #if ASPNET 5 | using System; 6 | using System.Linq; 7 | using Gistlyn.ServiceModel; 8 | using Gistlyn.ServiceModel.Types; 9 | using Gistlyn.SnippetEngine; 10 | using NuGet; 11 | using ServiceStack; 12 | 13 | namespace Gistlyn.ServiceInterface 14 | { 15 | /// 16 | /// Non essential Services we can remove later 17 | /// 18 | public class RunScriptSupportServices : Service 19 | { 20 | public IServerEvents ServerEvents { get; set; } 21 | 22 | public object Any(TestServerEvents request) 23 | { 24 | var response = new TestServerEventsResponse { Result = "Hello, {0}!".Fmt(request.Name) }; 25 | 26 | try 27 | { 28 | ServerEvents.NotifySession(Request.GetSessionId(), response, "@channels"); 29 | ServerEvents.NotifyUserId(request.Name, response, "@channels"); 30 | } 31 | catch (Exception e) 32 | { 33 | Console.WriteLine(e); 34 | } 35 | return response; 36 | } 37 | 38 | public object Any(GetScriptStatus request) 39 | { 40 | var runner = LocalCache.GetScriptRunnerInfo(request.ScriptId); 41 | 42 | var wrapper = runner != null ? runner.DomainWrapper : null; 43 | 44 | return new ScriptStatusResponse 45 | { 46 | Status = wrapper != null ? wrapper.GetScriptStatus() : ScriptStatus.Unknown 47 | }; 48 | } 49 | 50 | public object Any(EvaluateSource request) 51 | { 52 | var runner = new ScriptRunner(); 53 | var response = new EvaluateSourceResponse(); 54 | 55 | try 56 | { 57 | response.Result = runner.Execute(request.Code).Result; 58 | } 59 | catch (Exception e) 60 | { 61 | response.Result = new ScriptExecutionResult { Exception = e }; 62 | } 63 | 64 | return response; 65 | } 66 | } 67 | 68 | public class NugetService : Service 69 | { 70 | public AppData AppData { get; set; } 71 | 72 | public IDataContext DataContext { get; set; } 73 | 74 | public object Any(SearchNugetPackages request) 75 | { 76 | var repo = PackageRepositoryFactory.Default.CreateRepository("https://packages.nuget.org/api/v2"); 77 | 78 | var packages = repo.Search(request.Search, request.AllowPrereleaseVersion) 79 | .Take(50) 80 | .ToList(); 81 | 82 | var packageInfos = packages 83 | .Select(p => new NugetPackageInfo { Id = p.Id, Version = p.Version.ToNormalizedString() }) 84 | .ToList(); 85 | 86 | return new SearchNugetPackagesResponse 87 | { 88 | Packages = packageInfos 89 | }; 90 | } 91 | 92 | public object Any(InstallNugetPackage request) 93 | { 94 | NugetUtils.InstallPackage(DataContext, AppData.NugetPackagesDirectory, request.PackageId, request.Version); 95 | 96 | return new InstallNugetPackageResponse(); 97 | } 98 | 99 | public object Any(AddPackageAsReference request) 100 | { 101 | return new AddPackageAsReferenceResponse 102 | { 103 | Assemblies = NugetUtils.RestorePackage(DataContext, AppData.NugetPackagesDirectory, request.PackageId, request.Version) 104 | }; 105 | } 106 | 107 | public object Any(SearchInstalledPackages request) 108 | { 109 | var packages = DataContext.SearchPackages(request.Search, null); 110 | 111 | return new SearchInstalledPackagesResponse 112 | { 113 | Packages = packages 114 | }; 115 | } 116 | } 117 | } 118 | #endif 119 | -------------------------------------------------------------------------------- /src/Gistlyn/src/Collections.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { queryString } from '@servicestack/client'; 3 | 4 | export default class Collections extends React.Component { 5 | render() { 6 | var LiveLists = null; 7 | if (this.props.showLiveLists) { 8 | const allGists = Object.keys(this.props.gistStats) 9 | .map(k => this.props.gistStats[k]) 10 | .filter(x => this.props.excludeGists.indexOf(x.id) === -1); 11 | const sortByRecent = gists => { 12 | gists.sort((a, b) => b.date - a.date); 13 | return gists; 14 | }; 15 | const removeDupes = xs => { 16 | var dupes = {}; 17 | return xs.filter(x => dupes[x.description] ? false : !!(dupes[x.description] = x)); 18 | }; 19 | 20 | var recentGists = removeDupes(sortByRecent(allGists.filter(x => !x.collection))); 21 | var recentCollections = removeDupes(sortByRecent(allGists.filter(x => x.collection))); 22 | var myGists = recentGists.filter(x => x.owner_login === this.props.authUsername); 23 | 24 | if (recentGists.length > 0 || recentCollections.length > 0) { 25 | LiveLists = ( 26 |
27 |
28 | {recentCollections.length > 0 29 | ? (
30 |

Recent Collections

31 | { recentCollections.slice(0, 5).map(x => {x.description}) } 32 |
) 33 | : null} 34 | 35 | {recentGists.length > 0 36 | ? (
37 |

Recent Gists

38 | { recentGists.slice(0, 5).map(x => {x.description}) } 39 |
) 40 | : null} 41 | 42 | {myGists.length > 0 43 | ? (
44 |

My Gists

45 | { myGists.slice(0, 20).map(x => {x.description}) } 46 |
) 47 | : null} 48 |
49 |
); 50 | } 51 | } 52 | 53 | return ( 54 |
{ 56 | var a = e.target as HTMLAnchorElement; 57 | if (a && a.href) { 58 | const qs = queryString(a.href); 59 | if (qs["gist"] || qs["collection"] || qs["snapshot"]) { 60 | e.preventDefault(); 61 | if (qs["gist"]) 62 | this.props.changeGist(qs["gist"], { activeFileName: qs["activeFileName"] }); 63 | if (qs["collection"]) 64 | this.props.changeCollection(qs["collection"], true); 65 | if (qs["snapshot"]) 66 | this.props.viewSnapshot(qs["snapshot"]); 67 | } 68 | } 69 | } }> 70 |
71 | this.props.onHome()} title="Home">home 72 | {this.props.collection.description || "Collections"} 73 |
74 |
75 | {LiveLists} 76 |
78 |
79 |
); 80 | } 81 | } -------------------------------------------------------------------------------- /src/Gistlyn/src/TakeSnapshotDialog.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { JsonServiceClient } from '@servicestack/client'; 3 | import { StoreGist } from './Gistlyn.dtos'; 4 | import { GistTemplates } from './utils'; 5 | 6 | export default class TakeSnapshotDialog extends React.Component { 7 | dialog: HTMLDivElement; 8 | txtDescription: HTMLInputElement; 9 | 10 | constructor(props) { 11 | super(props); 12 | this.state = { snapshotUrl: null, error:null }; 13 | } 14 | 15 | onSave(opt) { 16 | const request = new StoreGist(); 17 | const json = JSON.stringify(this.props.snapshot); 18 | request.files = { 19 | ["snapshot.json"]: { filename:"snapshot.json", content: json } 20 | }; 21 | 22 | this.dialog.classList.add("disabled"); 23 | 24 | const client = new JsonServiceClient("/"); 25 | client.post(request) 26 | .then(r => { 27 | this.dialog.classList.remove("disabled"); 28 | this.setState({ snapshotUrl: location.origin + `?snapshot=${r.gist}`, error:null }); 29 | }).catch(e => { 30 | this.dialog.classList.remove("disabled"); 31 | this.setState({ error: (e.status || {}).message }); 32 | }); 33 | } 34 | 35 | render() { 36 | var description = this.props.description; 37 | if (this.txtDescription) { 38 | description = this.txtDescription.value; 39 | } else { 40 | setTimeout(() => this.txtDescription.select(), 0); 41 | } 42 | var Body = []; 43 | 44 | if (!this.state.snapshotUrl) { 45 | Body.push([ 46 |
47 | 48 | this.txtDescription = e} type="text" id="txtDescription" 49 | defaultValue={ description } 50 | onKeyUp={e => this.forceUpdate() } 51 | onKeyDown={e => e.keyCode == 13 && description ? this.onSave({ description }) : null } 52 | autoFocus /> 53 |
, 54 |
55 | 56 | description ? this.onSave({ description }) : null }> 58 | Save Snapshot 59 | 60 | 61 |
]); 62 | } else { 63 | setTimeout(() => this.txtDescription.select(), 0); 64 | Body.push([ 65 |
66 | 67 | this.txtDescription = e} type="text" id="txtDescription" value={ this.state.snapshotUrl } autoFocus /> 68 |
]); 69 | } 70 | 71 | if (this.state.error) { 72 | Body.push({this.state.error}); 73 | } 74 | 75 | return (
this.props.onHide() } onKeyDown={e => e.keyCode === 27 ? this.props.onHide() : null }> 76 |
this.dialog = e } onClick={e => e.stopPropagation() }> 77 |
78 | this.props.onHide() }>close 79 | Capture Snapshot 80 |
81 |
82 |
83 | this.props.urlChanged(GistTemplates.SnapshotsCollection) } title="What is this?">help_outline 84 |
85 | 86 | {Body} 87 |
88 |
89 | this.props.onHide() } style={{ cursor: "pointer" }}>close 90 |
91 |
92 |
); 93 | } 94 | } -------------------------------------------------------------------------------- /src/Gistlyn/src/assets/css/collections.css: -------------------------------------------------------------------------------- 1 | #btnCollections { 2 | position: absolute; 3 | top: 0; 4 | margin: 0px 0 0 45px; 5 | padding: 6px 0 0 2px; 6 | font-size: 30px; 7 | height: 42px; 8 | cursor: pointer; 9 | width: 40px; 10 | } 11 | #btnCollections:hover { 12 | color: #cef; 13 | } 14 | #btnCollections.active { 15 | color: #f7f7f7; 16 | background: #01215A; 17 | } 18 | 19 | 20 | #collection { 21 | background: #fff; 22 | } 23 | 24 | #collection-header { 25 | background: #01215A; 26 | text-align: left; 27 | color: #fff; 28 | padding: 4px 12px; 29 | line-height: 24px; 30 | } 31 | .owner #collection-header { 32 | background: #4CAF50; 33 | } 34 | #btnHome { 35 | color: #fff; 36 | font-size: 17px; 37 | vertical-align: middle; 38 | margin: -2px 6px 0 -5px; 39 | cursor: pointer; 40 | } 41 | 42 | #collection-body { 43 | overflow-y: auto; 44 | overflow-x: hidden; 45 | width: 50%; 46 | position: absolute; 47 | top: 74px; 48 | bottom: 41px; 49 | } 50 | 51 | #livelist { 52 | font-size: 14px; 53 | line-height: 22px; 54 | background: #f7f7f7; 55 | box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.3); 56 | } 57 | #livelist h3 { 58 | font-size: 14px; 59 | line-height: 24px; 60 | background: #0371BE; 61 | color: #f7f7f7; 62 | padding: 2px 8px; 63 | } 64 | #livelist a { 65 | padding: 2px 8px; 66 | display: block; 67 | text-decoration: none; 68 | color: #444; 69 | width: 200px; 70 | overflow: hidden; 71 | white-space: nowrap; 72 | text-overflow: ellipsis; 73 | } 74 | #livelist a:hover { 75 | text-decoration: underline; 76 | } 77 | .ipad #livelist { 78 | display: none; 79 | } 80 | 81 | #markdown { 82 | line-height: 1.5; 83 | font-size: 16px; 84 | color: #444; 85 | padding: 0 0 0 30px; 86 | max-width: 750px; 87 | } 88 | .ipad #markdown { 89 | font-size: 90%; 90 | } 91 | #markdown h1, #markdown h2, #markdown h3, #markdown h4, #markdown h5, #markdown h6 { 92 | margin-top: 24px; 93 | margin-bottom: 16px; 94 | font-weight: 600; 95 | line-height: 1.25; 96 | } 97 | .ipad #markdown h1, .ipad #markdown h2, .ipad #markdown h3, .ipad #markdown h4, .ipad #markdown h5, .ipad #markdown h6 { 98 | margin-top: 18px; 99 | margin-bottom: 12px; 100 | } 101 | .ipad #markdown img { 102 | max-width: 450px; 103 | } 104 | 105 | #markdown h1, #markdown h2 { 106 | padding-bottom: 0.3em; 107 | font-size: 1.5em; 108 | border-bottom: 1px solid #eee; 109 | } 110 | #markdown h3 { font-size: 1.25em; } 111 | #markdown h4 { font-size: 1em; } 112 | #markdown h5 { font-size: 0.875em; } 113 | #markdown h6 { font-size: 0.85em; color: #777; } 114 | #markdown p { 115 | margin: 0 0 16px 0; 116 | } 117 | #markdown strong, #markdown b { 118 | font-weight: bold; 119 | } 120 | #markdown em { 121 | font-style: italic; 122 | } 123 | #markdown ul, #markdown ol { 124 | padding-left: 2em; 125 | margin: 0 0 16px 0; 126 | } 127 | #markdown li>ul, #markdown li>ol { 128 | margin: 0; 129 | } 130 | #markdown li+li { 131 | margin-top: 0.25em; 132 | } 133 | #markdown ul ul, #markdown ol ul { 134 | list-style-type: circle; 135 | } 136 | #markdown ul { 137 | list-style-type: disc; 138 | } 139 | #markdown ol { 140 | list-style-type: decimal; 141 | } 142 | #markdown li > a { 143 | white-space: nowrap; 144 | } 145 | #markdown a { 146 | color: #428bca; 147 | text-decoration: none; 148 | } 149 | #markdown a:hover { 150 | color: #2a6496; 151 | } 152 | #markdown pre { 153 | padding: 16px; 154 | overflow: auto; 155 | font-size: 85%; 156 | line-height: 1.45; 157 | background-color: #f7f7f7; 158 | border-radius: 3px; 159 | margin-bottom: 16px; 160 | color: #333; 161 | } 162 | #markdown code { 163 | font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; 164 | background-color: #f7f7f7; 165 | font-size: 13px; 166 | padding: 0 2px; 167 | } 168 | #markdown pre>code { 169 | padding: 0; 170 | } 171 | #markdown code::before, #markdown code::after { 172 | letter-spacing: -0.2em; 173 | content: "\00a0"; 174 | } 175 | #markdown pre>code::before, #markdown pre>code::after { 176 | letter-spacing: 0; 177 | content: ""; 178 | } 179 | #markdown blockquote { 180 | padding: 0 1em; 181 | color: #777; 182 | border-left: 0.25em solid #ddd; 183 | } 184 | #markdown hr { 185 | border: none; 186 | border-bottom: 1px solid #eee; 187 | } 188 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceModel/Gistlyn.ServiceModel.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {B0A7EABE-8C51-4EFF-A116-2B56EF8BA11E} 8 | Library 9 | Properties 10 | Gistlyn.ServiceModel 11 | Gistlyn.ServiceModel 12 | v4.6.2 13 | 512 14 | ..\..\ 15 | true 16 | 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | ..\packages\ServiceStack.Interfaces.5.10.0\lib\net45\ServiceStack.Interfaces.dll 38 | True 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 90 | -------------------------------------------------------------------------------- /src/Gistlyn.Tests/UnitTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using NUnit.Framework; 4 | using ServiceStack; 5 | using ServiceStack.Testing; 6 | using Gistlyn.ServiceModel; 7 | using Gistlyn.ServiceInterface; 8 | using Gistlyn.SnippetEngine; 9 | using ServiceStack.DataAnnotations; 10 | using ServiceStack.OrmLite; 11 | using ServiceStack.Text; 12 | 13 | namespace Gistlyn.Tests 14 | { 15 | [TestFixture] 16 | public class UnitTests 17 | { 18 | private readonly ServiceStackHost appHost; 19 | 20 | public UnitTests() 21 | { 22 | appHost = new BasicAppHost(typeof(RunScriptService).Assembly) 23 | { 24 | ConfigureContainer = container => 25 | { 26 | //Add your IoC dependencies here 27 | } 28 | } 29 | .Init(); 30 | } 31 | 32 | [OneTimeTearDown] 33 | public void TestFixtureTearDown() 34 | { 35 | appHost.Dispose(); 36 | } 37 | 38 | [Test] 39 | public void TestMethod1() 40 | { 41 | //var service = appHost.Container.Resolve(); 42 | 43 | //var response = (HelloResponse)service.Any(new Hello { Name = "World" }); 44 | 45 | //Assert.That(response.Result, Is.EqualTo("Hello, World!")); 46 | } 47 | 48 | 49 | public class User 50 | { 51 | public long Id { get; set; } 52 | 53 | [Index] 54 | public string Name { get; set; } 55 | 56 | public DateTime CreatedDate { get; set; } 57 | } 58 | 59 | [Test] 60 | public void Can_detect_Circular_References_in_OrmLite_scripts() 61 | { 62 | var dbFactory = new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider); 63 | using (var db = dbFactory.OpenDbConnection()) 64 | { 65 | db.DropAndCreateTable(); 66 | 67 | db.Insert(new User 68 | { 69 | Id = 1, 70 | Name = "A", 71 | CreatedDate = DateTime.Now 72 | }); 73 | db.Insert(new User { Id = 2, Name = "B", CreatedDate = DateTime.Now }); 74 | db.Insert(new User { Id = 3, Name = "B", CreatedDate = DateTime.Now }); 75 | 76 | var rowsB = db.Select("Name = @name", new { name = "B" }); 77 | 78 | var rowIds = rowsB.ConvertAll(x => x.Id); 79 | 80 | //Assert.That(TypeSerializer.HasCircularReferences(SqliteDialect.Provider)); 81 | Assert.That(TypeSerializer.HasCircularReferences(dbFactory)); 82 | Assert.That(TypeSerializer.HasCircularReferences(db)); 83 | Assert.That(!TypeSerializer.HasCircularReferences(rowsB)); 84 | Assert.That(!TypeSerializer.HasCircularReferences(rowsB[0])); 85 | Assert.That(!TypeSerializer.HasCircularReferences(rowIds)); 86 | 87 | //SqliteDialect.Provider.ToSafeJson().Print(); 88 | dbFactory.ToSafeJson().Print(); 89 | db.ToSafeJson().Print(); 90 | rowsB.ToSafeJson().Print(); 91 | rowsB[0].ToSafeJson().Print(); 92 | rowIds.ToSafeJson().Print(); 93 | } 94 | } 95 | 96 | public class Node 97 | { 98 | public Node(int id, params Node[] children) 99 | { 100 | Id = id; 101 | Children = children; 102 | } 103 | 104 | public int Id { get; set; } 105 | 106 | public Node[] Children { get; set; } 107 | } 108 | 109 | [Test] 110 | public void Can_detect_Circular_References_in_models() 111 | { 112 | var node = new Node(1, 113 | new Node(11, new Node(111)), 114 | new Node(12, new Node(121))); 115 | 116 | Assert.That(!TypeSerializer.HasCircularReferences(node)); 117 | 118 | var root = new Node(1, 119 | new Node(11)); 120 | 121 | var cyclicalNode = new Node(1, root); 122 | root.Children[0].Children = new[] { cyclicalNode }; 123 | 124 | Assert.That(TypeSerializer.HasCircularReferences(root)); 125 | } 126 | 127 | [Test] 128 | public void Generate_new_Key() 129 | { 130 | RsaUtils.CreatePrivateKeyParams().ToPrivateKeyXml().Replace("\"", "\\\"").Print(); 131 | } 132 | } 133 | } -------------------------------------------------------------------------------- /src/Gistlyn/src/ImageUploadDialog.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import DropZone from 'react-dropzone'; 3 | 4 | export default class ImageUploadDialog extends React.Component { 5 | dialog: HTMLDivElement; 6 | fileImage: HTMLInputElement; 7 | txtImageUrl: HTMLInputElement; 8 | 9 | handleImageUrl() { 10 | if (this.txtImageUrl && this.txtImageUrl.value.startsWith("http")) { 11 | this.props.onChange(this.txtImageUrl.value); 12 | this.props.onHide(); 13 | return; 14 | } 15 | } 16 | 17 | handleDrop(files:File[]) { 18 | this.dialog.classList.add("disabled"); 19 | if (this.txtImageUrl) this.txtImageUrl.disabled = true; 20 | 21 | var uploadFiles = files.map(f => this.uploadFile(f)); 22 | Promise.all(uploadFiles) 23 | .then(() => { 24 | this.dialog.classList.remove("disabled"); 25 | this.props.onHide(); 26 | }); 27 | } 28 | 29 | uploadFile(file: File) { 30 | var formData = new FormData(); 31 | formData.append('description', file.name + ' on http://gistlyn.com?gist=' + this.props.id); 32 | formData.append('type', 'file'); 33 | formData.append('image', file); 34 | 35 | return fetch('https://api.imgur.com/3/upload.json', { 36 | method: 'POST', 37 | headers: { 38 | Accept: 'application/json', 39 | Authorization: 'Client-ID c891e34185a353f' 40 | }, 41 | body: formData 42 | }) 43 | .then(r => { 44 | if (r.status == 200 || r.status == 0) { 45 | r.json().then(o => { 46 | this.props.onChange(o.data.link); 47 | }); 48 | } else { 49 | alert("Error uploading Image: " + file.name); 50 | } 51 | }); 52 | } 53 | 54 | render() { 55 | const hasSelectedImage = !!(this.fileImage && this.fileImage.value); 56 | const hasProvidedUrl = this.txtImageUrl && this.txtImageUrl.value.startsWith("http"); 57 | const disabledColor = {color:"#999"}; 58 | 59 | return (
this.props.onHide() } onKeyDown={e => e.keyCode === 27 ? this.props.onHide() : null }> 60 |
this.props.dialogRef(this.dialog = e) } onClick={e => e.stopPropagation() }> 61 |
62 | this.props.onHide() }>close 63 | Insert Image 64 |
65 |
66 |
67 | 68 | this.txtImageUrl = e} type="text" id="txtImageUrl" 69 | onKeyUp={e => this.forceUpdate() } 70 | placeholder="Enter the url you want to use" 71 | onKeyDown={e => e.keyCode == 13 && hasProvidedUrl ? e.preventDefault() || this.handleImageUrl() : null } 72 | disabled={hasSelectedImage} autoFocus /> 73 | this.handleImageUrl() }> 76 | {hasSelectedImage ? "Upload to Imgur" : "Insert Image"} 77 | 78 |
79 |
80 | this.handleDrop(files) } 81 | className="dropzone" activeClassName="dropzone-active" accept="image/*"> 82 |
83 |

Click or drag Images to upload to Imgur

84 |
85 | Uploading to Imgur... 86 | 87 |
88 |
89 |
90 |
91 |
92 |
93 |
); 94 | } 95 | } -------------------------------------------------------------------------------- /src/Gistlyn.ServiceInterface/NugetUtils.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Service Stack LLC. All Rights Reserved. 2 | // License: https://raw.github.com/ServiceStack/ServiceStack/master/license.txt 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Runtime.Versioning; 9 | using Gistlyn.ServiceModel.Types; 10 | using NuGet; 11 | using ServiceStack; 12 | 13 | namespace Gistlyn.ServiceInterface 14 | { 15 | public static class NugetUtils 16 | { 17 | public static NugetPackageInfo GetPackageInfo(this IPackage package) 18 | { 19 | var info = new NugetPackageInfo 20 | { 21 | Id = package.Id, 22 | Version = package.Version.ToNormalizedString() 23 | }; 24 | 25 | info.Assemblies = package.AssemblyReferences 26 | .Select(a => new AssemblyReference 27 | { 28 | Name = a.Name, 29 | Path = Path.Combine(info.Id + "." + package.Version.ToNormalizedString(), a.Path) 30 | }) 31 | .ToList(); 32 | 33 | return info; 34 | } 35 | 36 | public static void InstallPackage(IDataContext dataContext, string nugetPackagesDir, string packageId, string version) 37 | { 38 | //Connect to the official package repository 39 | var repo = PackageRepositoryFactory.Default.CreateRepository("https://packages.nuget.org/api/v2"); 40 | 41 | //Initialize the package manager 42 | var packageManager = new PackageManager(repo, nugetPackagesDir); 43 | 44 | packageManager.PackageInstalled += (sender, e) => 45 | { 46 | var info = e.Package.GetPackageInfo(); 47 | 48 | dataContext.SavePackage(info); 49 | }; 50 | 51 | //Download and unzip the package 52 | packageManager.InstallPackage(packageId, SemanticVersion.Parse(version)); //new SemanticVersion(request.Version) 53 | 54 | } 55 | 56 | private static readonly FrameworkName Net45FrameworkName = VersionUtility.ParseFrameworkName("net45"); 57 | 58 | public static List RestorePackage(IDataContext dataContext, string nugetPackagesDir, string packageId, string version) 59 | { 60 | var packages = dataContext.GetPackageAndDependencies(packageId, version); 61 | 62 | //trying to install first 63 | if (packages.Count == 0) 64 | { 65 | InstallPackage(dataContext, nugetPackagesDir, packageId, version); 66 | packages = dataContext.GetPackageAndDependencies(packageId, version); 67 | } 68 | 69 | var assemblies = new List(); 70 | var uniqueNames = new HashSet(); 71 | 72 | foreach (var package in packages) 73 | { 74 | //Add preferred .NET 4.5 dlls first (if any) 75 | foreach (var assembly in package.Assemblies) 76 | { 77 | var fxName = GetFrameworkName(assembly); 78 | if (fxName == Net45FrameworkName) 79 | { 80 | assemblies.Add(assembly); 81 | uniqueNames.Add(assembly.Name); 82 | } 83 | } 84 | 85 | foreach (var assembly in package.Assemblies) 86 | { 87 | var fxName = GetFrameworkName(assembly); 88 | if (fxName != null && 89 | VersionUtility.IsCompatible(Net45FrameworkName, new[] { fxName }) && 90 | !uniqueNames.Contains(assembly.Name)) 91 | { 92 | assemblies.Add(assembly); 93 | uniqueNames.Add(assembly.Name); 94 | } 95 | } 96 | } 97 | 98 | return assemblies; 99 | } 100 | 101 | private static FrameworkName GetFrameworkName(AssemblyReference assembly) 102 | { 103 | string effectivePath; 104 | var fxName = VersionUtility.ParseFrameworkNameFromFilePath(assembly.Path, out effectivePath); 105 | if (fxName != null) 106 | return fxName; 107 | 108 | if (assembly.Path.IndexOf("lib" + Path.DirectorySeparatorChar, StringComparison.Ordinal) == -1) 109 | return null; 110 | 111 | var libDirName = assembly.Path.RightPart("lib" + Path.DirectorySeparatorChar).LeftPart(Path.DirectorySeparatorChar); 112 | return VersionUtility.ParseFrameworkName(libDirName); 113 | } 114 | } 115 | } 116 | 117 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | #custom 5 | coverage/ 6 | 7 | # User-specific files 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | bld/ 24 | [Bb]in/ 25 | [Oo]bj/ 26 | 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # MSTest test Results 33 | [Tt]est[Rr]esult*/ 34 | [Bb]uild[Ll]og.* 35 | 36 | # NUNIT 37 | *.VisualState.xml 38 | TestResult.xml 39 | 40 | # Build Results of an ATL Project 41 | [Dd]ebugPS/ 42 | [Rr]eleasePS/ 43 | dlldata.c 44 | 45 | # DNX 46 | project.lock.json 47 | artifacts/ 48 | 49 | *_i.c 50 | *_p.c 51 | *_i.h 52 | *.ilk 53 | *.meta 54 | *.obj 55 | *.pch 56 | *.pdb 57 | *.pgc 58 | *.pgd 59 | *.rsp 60 | *.sbr 61 | *.tlb 62 | *.tli 63 | *.tlh 64 | *.tmp 65 | *.tmp_proj 66 | *.log 67 | *.vspscc 68 | *.vssscc 69 | .builds 70 | *.pidb 71 | *.svclog 72 | *.scc 73 | 74 | # Chutzpah Test files 75 | _Chutzpah* 76 | 77 | # Visual C++ cache files 78 | ipch/ 79 | *.aps 80 | *.ncb 81 | *.opendb 82 | *.opensdf 83 | *.sdf 84 | *.cachefile 85 | 86 | # Visual Studio profiler 87 | *.psess 88 | *.vsp 89 | *.vspx 90 | *.sap 91 | 92 | # TFS 2012 Local Workspace 93 | $tf/ 94 | 95 | # Guidance Automation Toolkit 96 | *.gpState 97 | 98 | # ReSharper is a .NET coding add-in 99 | _ReSharper*/ 100 | *.[Rr]e[Ss]harper 101 | *.DotSettings.user 102 | 103 | # JustCode is a .NET coding add-in 104 | .JustCode 105 | 106 | # TeamCity is a build add-in 107 | _TeamCity* 108 | 109 | # DotCover is a Code Coverage Tool 110 | *.dotCover 111 | 112 | # NCrunch 113 | _NCrunch_* 114 | .*crunch*.local.xml 115 | nCrunchTemp_* 116 | 117 | # MightyMoose 118 | *.mm.* 119 | AutoTest.Net/ 120 | 121 | # Web workbench (sass) 122 | .sass-cache/ 123 | 124 | # Installshield output folder 125 | [Ee]xpress/ 126 | 127 | # DocProject is a documentation generator add-in 128 | DocProject/buildhelp/ 129 | DocProject/Help/*.HxT 130 | DocProject/Help/*.HxC 131 | DocProject/Help/*.hhc 132 | DocProject/Help/*.hhk 133 | DocProject/Help/*.hhp 134 | DocProject/Help/Html2 135 | DocProject/Help/html 136 | 137 | # Click-Once directory 138 | publish/ 139 | 140 | # Publish Web Output 141 | *.[Pp]ublish.xml 142 | *.azurePubxml 143 | # TODO: Comment the next line if you want to checkin your web deploy settings 144 | # but database connection strings (with potential passwords) will be unencrypted 145 | *.pubxml 146 | *.publishproj 147 | 148 | # NuGet Packages 149 | *.nupkg 150 | # The packages folder can be ignored because of Package Restore 151 | **/packages/* 152 | # except build/, which is used as an MSBuild target. 153 | !**/packages/build/ 154 | # Uncomment if necessary however generally it will be regenerated when needed 155 | #!**/packages/repositories.config 156 | # NuGet v3's project.json files produces more ignoreable files 157 | *.nuget.props 158 | *.nuget.targets 159 | 160 | # Microsoft Azure Build Output 161 | csx/ 162 | *.build.csdef 163 | 164 | # Microsoft Azure Emulator 165 | ecf/ 166 | rcf/ 167 | 168 | # Microsoft Azure ApplicationInsights config file 169 | ApplicationInsights.config 170 | 171 | # Windows Store app package directory 172 | AppPackages/ 173 | BundleArtifacts/ 174 | 175 | # Visual Studio cache files 176 | # files ending in .cache can be ignored 177 | *.[Cc]ache 178 | # but keep track of directories ending in .cache 179 | !*.[Cc]ache/ 180 | 181 | # Others 182 | ClientBin/ 183 | ~$* 184 | *~ 185 | *.dbmdl 186 | *.dbproj.schemaview 187 | *.pfx 188 | *.publishsettings 189 | node_modules/ 190 | jspm_packages/ 191 | typings/ 192 | wwwroot/ 193 | apps/ 194 | webdeploy.zip 195 | orleans.codegen.cs 196 | 197 | # RIA/Silverlight projects 198 | Generated_Code/ 199 | 200 | # Backup & report files from converting an old project file 201 | # to a newer Visual Studio version. Backup files are not needed, 202 | # because we have git ;-) 203 | _UpgradeReport_Files/ 204 | Backup*/ 205 | UpgradeLog*.XML 206 | UpgradeLog*.htm 207 | 208 | # SQL Server files 209 | *.mdf 210 | *.ldf 211 | 212 | # Business Intelligence projects 213 | *.rdl.data 214 | *.bim.layout 215 | *.bim_*.settings 216 | 217 | # Microsoft Fakes 218 | FakesAssemblies/ 219 | 220 | # GhostDoc plugin setting file 221 | *.GhostDoc.xml 222 | 223 | # Node.js Tools for Visual Studio 224 | .ntvs_analysis.dat 225 | 226 | # Visual Studio 6 build log 227 | *.plg 228 | 229 | # Visual Studio 6 workspace options file 230 | *.opt 231 | 232 | # Visual Studio LightSwitch build output 233 | **/*.HTMLClient/GeneratedArtifacts 234 | **/*.DesktopClient/GeneratedArtifacts 235 | **/*.DesktopClient/ModelManifest.xml 236 | **/*.Server/GeneratedArtifacts 237 | **/*.Server/ModelManifest.xml 238 | _Pvt_Extensions 239 | 240 | # Paket dependency manager 241 | .paket/paket.exe 242 | 243 | # FAKE - F# Make 244 | .fake/ 245 | *.libz 246 | *.txt 247 | src/Gistlyn/AppHost.secrets.cs 248 | -------------------------------------------------------------------------------- /src/Gistlyn.ServiceInterface/RunScriptService.Embed.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Service Stack LLC. All Rights Reserved. 2 | // License: https://raw.github.com/ServiceStack/ServiceStack/master/license.txt 3 | 4 | #if ASPNET 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using ServiceStack; 9 | using Gistlyn.ServiceModel; 10 | using System.IO; 11 | using System.Security.Policy; 12 | using System.Text; 13 | using System.Threading; 14 | using Gistlyn.ServiceModel.Types; 15 | using Gistlyn.SnippetEngine; 16 | 17 | namespace Gistlyn.ServiceInterface 18 | { 19 | public partial class RunScriptService : Service 20 | { 21 | [AddHeader(ContentType = "text/javascript")] 22 | public object Any(GetEmbedScript request) 23 | { 24 | var scriptId = Guid.NewGuid().ToString().Replace("-", string.Empty); 25 | var url = string.Empty; 26 | int idx = Request.AbsoluteUri.IndexOf(Request.RawUrl, StringComparison.OrdinalIgnoreCase); 27 | 28 | if (idx > 0) 29 | url = Request.AbsoluteUri.Substring(0, idx); 30 | 31 | var htmlContent = VirtualFileSources.GetFile("templates/embed.html").ReadAllText(); 32 | var scriptContent = VirtualFileSources.GetFile("templates/embed.init.js").ReadAllText(); 33 | 34 | var sb = new StringBuilder(); 35 | 36 | sb.AppendFormat(scriptContent, scriptId, request.Gist, request.NoCache.ToJson(), url); 37 | 38 | htmlContent = htmlContent.Replace("\r", string.Empty).Replace("\n", "\\\n").Replace("'", "''"); 39 | htmlContent = string.Format(htmlContent, scriptId); 40 | 41 | sb.AppendFormat("document.write('{0}');\n", htmlContent); 42 | sb.AppendFormat("init_{0}();\n", scriptId); 43 | 44 | return sb.ToString(); 45 | } 46 | 47 | public object Any(RunEmbedScript request) 48 | { 49 | if (request.GistHash == null) 50 | throw new ArgumentException("GistHash"); 51 | 52 | AppData.AssertNoIllegalTokens(request.MainSource); 53 | AppData.AssertNoIllegalTokens(request.Sources.ToArray()); 54 | 55 | var result = new EmbedScriptExecutionResult(); 56 | var codeHash = GetSourceCodeHash(request); 57 | 58 | if (!request.NoCache) 59 | { 60 | var mr = AppData.GetMemoizedResult(codeHash); 61 | if (mr != null) 62 | { 63 | result = mr.Result; 64 | return new RunEmbedScriptResponse { Result = result }; 65 | } 66 | } 67 | 68 | List normalizedReferences; 69 | var addedReferences = AddReferencesFromPackages(request.References, request.Packages, out normalizedReferences); 70 | 71 | //Create domain and run script 72 | var evidence = new Evidence(AppDomain.CurrentDomain.Evidence); 73 | var setup = new AppDomainSetup 74 | { 75 | PrivateBinPath = Path.Combine(VirtualFiles.RootDirectory.RealPath, "bin"), 76 | ApplicationBase = VirtualFiles.RootDirectory.RealPath 77 | }; 78 | 79 | var domain = AppDomain.CreateDomain(Guid.NewGuid().ToString(), evidence, setup); 80 | 81 | var asm = typeof(DomainWrapper).Assembly.FullName; 82 | var type = typeof(DomainWrapper).FullName; 83 | 84 | var wrapper = (DomainWrapper)domain.CreateInstanceAndUnwrap(asm, type); 85 | wrapper.ScriptId = request.ScriptId; 86 | var writerProxy = new NotifierProxy(ServerEvents, request.ScriptId); 87 | 88 | var info = new ScriptRunnerInfo { ScriptId = request.ScriptId, ScriptDomain = domain, DomainWrapper = wrapper }; 89 | 90 | Cache.Set(request.ScriptId, info); 91 | 92 | var lockEvt = new ManualResetEvent(false); 93 | 94 | ThreadPool.QueueUserWorkItem(_ => 95 | { 96 | try 97 | { 98 | var sr = wrapper.Run(request.MainSource, request.Sources, addedReferences.Select(r => r.Path).ToList(), writerProxy); 99 | 100 | result.Exception = sr.Exception; 101 | result.Errors = sr.Errors; 102 | 103 | //get json of last variable 104 | if (sr.Variables != null && sr.Variables.Count > 0) 105 | { 106 | var value = wrapper.GetVariableValue(sr.Variables[sr.Variables.Count - 1].Name); 107 | result.LastVariableJson = ScriptUtils.ToJson(value); 108 | } 109 | } 110 | finally 111 | { 112 | lockEvt.Set(); 113 | } 114 | }); 115 | 116 | lockEvt.WaitOne(); 117 | 118 | AppData.SetMemoizedResult(new MemoizedResult { CodeHash = codeHash, Result = result }); 119 | 120 | //Unload appdomain only in synchroneous version 121 | //AppDomain.Unload(domain); 122 | 123 | return new RunEmbedScriptResponse 124 | { 125 | Result = result, 126 | References = normalizedReferences 127 | }; 128 | } 129 | } 130 | } 131 | #endif 132 | -------------------------------------------------------------------------------- /src/Gistlyn/webpack.config.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | module.exports = (env) => { 4 | 5 | const isProd = env && env.prod; 6 | const isDev = !isProd; 7 | const npmScript = process.env.npm_lifecycle_event; 8 | const isDevServer = npmScript === 'dev'; 9 | 10 | const packageConfig = require("./package.json"), 11 | path = require('path'), 12 | webpack = require('webpack'), 13 | ExtractTextPlugin = require('extract-text-webpack-plugin'), 14 | HtmlWebpackPlugin = require('html-webpack-plugin'), 15 | AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin'), 16 | CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin, 17 | Clean = require('clean-webpack-plugin'); 18 | 19 | const postcssLoader = { 20 | loader: 'postcss-loader', 21 | options: { plugins: [require('precss'), require('autoprefixer')] } 22 | }; 23 | 24 | return [{ 25 | 26 | entry: { 27 | app: [ 28 | './src/app.tsx' 29 | ] 30 | }, 31 | 32 | output: { 33 | path: root('wwwroot/dist'), 34 | publicPath: '/dist/', 35 | filename: '[name].bundle.js', 36 | chunkFilename: '[name].js', 37 | }, 38 | 39 | devServer: { 40 | port: 3000, 41 | historyApiFallback: true, 42 | inline: true, 43 | proxy: { 44 | "/": packageConfig["jest"]["globals"]["BaseUrl"] 45 | } 46 | }, 47 | 48 | devtool: isProd ? "source-map" : "inline-source-map", 49 | 50 | resolve: { 51 | extensions: [ 52 | '.webpack.js', 53 | '.web.js', 54 | '.js', 55 | '.jsx', 56 | '.ts', 57 | '.tsx' 58 | ] 59 | }, 60 | 61 | module: { 62 | rules: [ 63 | { 64 | test: /\.tsx?$/, 65 | loader: 'awesome-typescript-loader?silent=true' 66 | }, 67 | { 68 | test: /\.html$/, 69 | loader: 'html-loader' 70 | }, 71 | { 72 | enforce: "pre", 73 | test: /\.js$/, 74 | loader: "source-map-loader" 75 | }, 76 | { 77 | test: /\.(jpe?g|gif|png|ico|svg|wav|mp3)$/i, 78 | loader: 'file-loader?name=img/[name].[ext]' 79 | }, 80 | { 81 | test: /\.(eot|ttf|woff|woff2)(\?v=\d+\.\d+\.\d+)?$/, 82 | loader: 'file-loader?name=img/[name].[ext]' 83 | }, 84 | ...when(isDev, [ 85 | { 86 | test: /\.css$/, 87 | use: ['style-loader', 'css-loader', postcssLoader] 88 | }, 89 | { 90 | test: /\.(sass|scss)$/, 91 | use: ['style-loader', 'css-loader', postcssLoader, 'sass-loader'] 92 | }, 93 | ]), 94 | ...when(isProd, [ 95 | { 96 | test: /\.css$/, 97 | loader: ExtractTextPlugin.extract({ 98 | fallback: 'style-loader', 99 | use: ['css-loader?minimize', postcssLoader], 100 | }), 101 | }, 102 | { 103 | test: /\.(sass|scss)$/, 104 | loader: ExtractTextPlugin.extract({ 105 | fallback: 'style-loader', 106 | use: ['css-loader?minimize', postcssLoader, 'sass-loader'], 107 | }), 108 | } 109 | ]) 110 | ] 111 | }, 112 | 113 | plugins: [ 114 | new CheckerPlugin(), 115 | new webpack.DefinePlugin({ 'process.env.NODE_ENV': isDev ? '"development"' : '"production"' }), 116 | new webpack.WatchIgnorePlugin([root("wwwroot")]), 117 | new webpack.DllReferencePlugin({ 118 | context: __dirname, 119 | manifest: require('./wwwroot/dist/vendor-manifest.json') 120 | }), 121 | new HtmlWebpackPlugin({ 122 | template: 'index.template.ejs', 123 | filename: '../index.html', 124 | inject: true 125 | }), 126 | new AddAssetHtmlPlugin({ filepath: root('wwwroot/dist/*.dll.js') }), 127 | new AddAssetHtmlPlugin({ filepath: root('wwwroot/dist/*.dll.css'), typeOfAsset: 'css' }), 128 | ...when(isProd, [ 129 | new ExtractTextPlugin({ filename: '[name].css', allChunks: true }), 130 | new webpack.optimize.UglifyJsPlugin({ sourceMap: true }) 131 | ]), 132 | ] 133 | }]; 134 | 135 | //helpers 136 | function ensureArray(config) { 137 | return config && (Array.isArray(config) ? config : [config]) || []; 138 | } 139 | function when(condition, config, negativeConfig) { 140 | return condition ? ensureArray(config) : ensureArray(negativeConfig); 141 | } 142 | function root(args) { 143 | args = Array.prototype.slice.call(arguments, 0); 144 | return (path || (path = require("path"))).join.apply(path, [__dirname].concat(args)); 145 | } 146 | }; 147 | -------------------------------------------------------------------------------- /src/Gistlyn.AppConsole/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /src/Gistlyn.AppMac/Gistlyn.AppMac.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | {A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 7 | {6ecae23f-bb02-4eba-9fd5-b90c88792f79} 8 | Exe 9 | Gistlyn.AppMac 10 | Resources 11 | Gistlyn.AppMac 12 | v4.6.1 13 | 14 | 15 | true 16 | full 17 | false 18 | bin\Debug 19 | DEBUG; 20 | prompt 21 | 4 22 | false 23 | true 24 | true 25 | true 26 | false 27 | false 28 | Mac Developer 29 | false 30 | false 31 | 32 | 33 | full 34 | true 35 | bin\Release 36 | prompt 37 | 4 38 | false 39 | None 40 | false 41 | true 42 | true 43 | true 44 | true 45 | Developer ID Application 46 | true 47 | false 48 | 49 | 50 | 51 | 52 | 53 | 54 | ..\..\lib\Gistlyn.Resources.dll 55 | 56 | 57 | ..\..\packages\ServiceStack.Interfaces.4.5.14\lib\portable-wp80+sl5+net45+win8+wpa81+monotouch+monoandroid+xamarin.ios10\ServiceStack.Interfaces.dll 58 | 59 | 60 | ..\..\packages\ServiceStack.Text.4.5.14\lib\net45\ServiceStack.Text.dll 61 | 62 | 63 | ..\..\packages\ServiceStack.Common.4.5.14\lib\net45\ServiceStack.Common.dll 64 | 65 | 66 | ..\..\packages\ServiceStack.Client.4.5.14\lib\net45\ServiceStack.Client.dll 67 | 68 | 69 | ..\..\packages\ServiceStack.4.5.14\lib\net45\ServiceStack.dll 70 | 71 | 72 | ..\..\packages\ServiceStack.OrmLite.4.5.14\lib\net45\ServiceStack.OrmLite.dll 73 | 74 | 75 | ..\..\packages\ServiceStack.Redis.4.5.14\lib\net45\ServiceStack.Redis.dll 76 | 77 | 78 | ..\..\packages\ServiceStack.Server.4.5.14\lib\net45\ServiceStack.Server.dll 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | MainWindow.cs 89 | 90 | 91 | 92 | 93 | AppDelegate.cs 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | {582DFB0F-F84D-4E43-9BCA-2A5A86600B7A} 108 | Gistlyn.ServiceInterface 109 | 110 | 111 | {08BEF328-AB7D-48D3-800D-48ACC75C7914} 112 | Gistlyn.ServiceModel 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /src/Gistlyn.AppWinForms/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /src/Gistlyn/src/ShortcutsDialog.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | export default class ShortcutsDialog extends React.Component { 4 | render() { 5 | return (
this.props.onHide() } onKeyDown={e => e.keyCode === 27 ? this.props.onHide() : null }> 6 |
this.props.dialogRef(e) } onClick={e => e.stopPropagation()}> 7 |
8 | this.props.onHide() }>close 9 | Keyboard shortcuts 10 |
11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 28 | 29 | 30 | 36 | 39 | 40 | 41 | 45 | 48 | 49 | 50 | 54 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 70 | 73 | 74 | 75 | 81 | 84 | 85 | 86 | 92 | 95 | 96 | 97 | 103 | 106 | 107 | 108 | 112 | 115 | 116 | 117 | 121 | 124 | 125 | 126 |

Editor Shortcuts

20 | <Ctrl> 21 | + 22 | <Enter> 23 | : 24 | 26 | Run 27 |
31 | <Ctrl> 32 | + 33 | <S> 34 | : 35 | 37 | Save 38 |
42 | <F11> 43 | : 44 | 46 | Toggle Full Screen 47 |
51 | <Esc> 52 | : 53 | 55 | Exit Full Screen 56 |

Application Shortcuts

65 | <Alt> 66 | + 67 | <S> 68 | : 69 | 71 | Take Snapshot 72 |
76 | <Alt> 77 | + 78 | <C> 79 | : 80 | 82 | Console Viewer 83 |
87 | <Ctrl> 88 | + 89 | <Left> 90 | : 91 | 93 | Go to Previous tab 94 |
98 | <Ctrl> 99 | + 100 | <Right> 101 | : 102 | 104 | Go to Next tab 105 |
109 | ? 110 | : 111 | 113 | Open keyboard shortcut dialog 114 |
118 | <Esc> 119 | : 120 | 122 | Close dialog 123 |
127 |
128 |
129 |
); 130 | } 131 | } -------------------------------------------------------------------------------- /src/Gistlyn/src/assets/css/dialogs.css: -------------------------------------------------------------------------------- 1 | #dialog { 2 | position: absolute; 3 | height: 100%; 4 | width: 100%; 5 | background: rgba(0,0,0,.3); 6 | z-index: 10; 7 | top: 0; 8 | text-align: center; 9 | } 10 | .dialog { 11 | position: relative; 12 | top: 50%; 13 | -webkit-transform: translateY(-50%); 14 | -moz-transform: translateY(-50%); 15 | -ms-transform: translateY(-50%); 16 | -o-transform: translateY(-50%); 17 | transform: translateY(-50%); 18 | text-align: left; 19 | display: inline-block; 20 | background: #fff; 21 | 22 | -webkit-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3); 23 | -moz-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3); 24 | box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3); 25 | -webkit-background-clip: padding-box; 26 | -moz-background-clip: padding-box; 27 | background-clip: padding-box; 28 | 29 | /* vertical align */ 30 | -webkit-transform-style: preserve-3d; 31 | -moz-transform-style: preserve-3d; 32 | transform-style: preserve-3d; 33 | } 34 | .dialog-header { 35 | font-size: 18px; 36 | background: #0371BE; 37 | color: #fff; 38 | padding: 12px; 39 | } 40 | .dialog-body { 41 | padding: 24px; 42 | min-height: 100px; 43 | color: #444; 44 | } 45 | .dialog-footer { 46 | text-align: right; 47 | padding: 12px; 48 | } 49 | .dialog-header .close { 50 | float: right; 51 | font-size: 16px; 52 | cursor: pointer; 53 | } 54 | .dialog-header .close:hover { 55 | color: #ddd; 56 | } 57 | .dialog-body .row { 58 | margin: 0 0 10px 0; 59 | } 60 | .dialog-body label { 61 | display: inline-block; 62 | padding: 0 20px 0 0; 63 | width: 100px; 64 | } 65 | .dialog-body input[type=text] { 66 | width: 350px; 67 | padding: 8px 12px; 68 | font-size: 16px; 69 | border: solid 1px #A9A9A9; 70 | } 71 | .dialog .loading { 72 | visibility: hidden; 73 | } 74 | .dialog.disabled .loading { 75 | visibility: visible; 76 | } 77 | .dialog .info-help { 78 | cursor: pointer; 79 | color: #2a6496; 80 | margin: -12px -12px 0 0; 81 | } 82 | 83 | .btn, .btn:focus { 84 | text-transform: uppercase; 85 | border-radius: 2px; 86 | background: #0488E4; 87 | transition: box-shadow .28s cubic-bezier(.4,0,.2,1); 88 | outline: none !important; 89 | border: none; 90 | color: rgba(255,255,255,.84); 91 | display: inline-block; 92 | text-align: center; 93 | vertical-align: middle; 94 | cursor: pointer; 95 | border: 1px solid transparent; 96 | white-space: nowrap; 97 | padding: 8px 12px; 98 | font-size: 16px; 99 | line-height: 1.42857143; 100 | -webkit-user-select: none; 101 | -moz-user-select: none; 102 | -ms-user-select: none; 103 | user-select: none 104 | } 105 | .btn:hover { 106 | background: #03a9f4; 107 | box-shadow: 0 2px 6px rgba(0,0,0,0.26); 108 | color: #fff; 109 | } 110 | .disabled .btn, .btn.disabled, .btn[disabled], fieldset[disabled] .btn { 111 | cursor: not-allowed; 112 | pointer-events: none; 113 | opacity: .65; 114 | filter: alpha(opacity=65); 115 | -webkit-box-shadow: none; 116 | box-shadow: none; 117 | } 118 | 119 | #dialog.dark { 120 | background: none; 121 | } 122 | #dialog.dark .dialog { 123 | background: rgba(0,0,0,.85); 124 | border-radius: 20px; 125 | } 126 | #dialog.dark .dialog-header { 127 | background: none; 128 | margin: 0 0 0 10px; 129 | font-weight: bold; 130 | } 131 | #dialog.dark .dialog-body { 132 | color: #fff; 133 | min-width: 400px; 134 | line-height: 20px; 135 | } 136 | #dialog.dark .dialog-body>table { 137 | margin: 0 0 20px 10px; 138 | } 139 | #dialog.dark .dialog-body h4 { 140 | padding: 15px 0 5px 0; 141 | color: #dd0; 142 | font-weight: bold; 143 | } 144 | #dialog.dark .dialog-body th { 145 | text-align: right; 146 | } 147 | #dialog.dark .dialog-body th b { 148 | font-family: "Courier New"; 149 | font-size: 13px; 150 | color: #dd0; 151 | font-weight: bold; 152 | } 153 | #dialog.dark .dialog-body th i { 154 | font-family: arial; 155 | font-style: normal; 156 | font-weight: bold; 157 | padding: 0 10px 0 3px; 158 | } 159 | 160 | #dialog a, #dialog .lnk, .lnk { 161 | color: #428bca; 162 | text-decoration: none; 163 | cursor: pointer; 164 | } 165 | #dialog a:hover, #dialog .lnk:hover, .lnk:hover { 166 | color: #2a6496; 167 | } 168 | 169 | #dialog.console-viewer.dark .dialog-body td, 170 | #dialog.console-viewer.dark .dialog-body pre { 171 | font: 13px/18px monospace; 172 | color: #00FF00; 173 | } 174 | #dialog.console-viewer .dialog-header span, 175 | #dialog.console-viewer .dialog-footer span { 176 | float: right; 177 | color: #dd0; 178 | font-size: 16px; 179 | cursor: pointer; 180 | padding-left: 10px; 181 | font-weight: normal; 182 | } 183 | 184 | .linktabs { 185 | text-align: center; 186 | } 187 | .linktabs div { 188 | display: inline-block; 189 | cursor: pointer; 190 | border-bottom: 2px solid #fff; 191 | margin: 0 10px 20px 0; 192 | padding: 2px 5px; 193 | } 194 | .linktabs div.active { 195 | border-bottom: 2px solid #444; 196 | } 197 | .radiotabs div { 198 | cursor: pointer; 199 | display: inline-block; 200 | margin: 0 10px 0 0; 201 | } 202 | .radiotabs i { 203 | vertical-align: bottom; 204 | margin-right: 5px; 205 | font-size: 20px; 206 | } 207 | .gist-links-body { 208 | max-height: 400px; 209 | overflow: auto; 210 | } 211 | #insert-link-dialog dt { 212 | font-weight: bold; 213 | margin: 10px 0; 214 | } 215 | #insert-link-dialog dd { 216 | font-size: 14px; 217 | cursor: pointer; 218 | color: #428bca; 219 | line-height: 20px; 220 | padding: 0 0 0 10px; 221 | } 222 | #insert-link-dialog dd:hover { 223 | color: #2a6496; 224 | } 225 | .insert-link-new { 226 | margin: 20px 0px 10px 0px; 227 | } 228 | #nosse-dialog a { 229 | color: #428bca; 230 | text-decoration: none; 231 | padding: 0 6px; 232 | } 233 | #nosse-dialog a:hover { 234 | color: #2a6496; 235 | } 236 | .material-icons.close { 237 | color: #fff; 238 | text-shadow: none; 239 | } -------------------------------------------------------------------------------- /src/Gistlyn/src/codemirror.js: -------------------------------------------------------------------------------- 1 | // Keeping a local fork of react-codemirror since it's now broken and unmaintained, in order to revert this change: 2 | // https://github.com/JedWatson/react-codemirror/commit/339b5975724cde338301f4c6842f2d52b4773e76 3 | // from issue: https://github.com/JedWatson/react-codemirror/issues/121#issuecomment-316307312 4 | 5 | 'use strict'; 6 | 7 | var React = require('react'); 8 | var ReactDOM = require('react-dom'); 9 | var PropTypes = require('prop-types'); 10 | var className = require('classnames'); 11 | var debounce = require('lodash.debounce'); 12 | var isEqual = require('lodash.isequal'); 13 | var createReactClass = require('create-react-class'); 14 | 15 | function normalizeLineEndings(str) { 16 | if (!str) return str; 17 | return str.replace(/\r\n|\r/g, '\n'); 18 | } 19 | 20 | var CodeMirror = createReactClass({ 21 | propTypes: { 22 | autoFocus: PropTypes.bool, 23 | className: PropTypes.any, 24 | codeMirrorInstance: PropTypes.func, 25 | defaultValue: PropTypes.string, 26 | name: PropTypes.string, 27 | onChange: PropTypes.func, 28 | onCursorActivity: PropTypes.func, 29 | onFocusChange: PropTypes.func, 30 | onScroll: PropTypes.func, 31 | options: PropTypes.object, 32 | path: PropTypes.string, 33 | value: PropTypes.string, 34 | preserveScrollPosition: PropTypes.bool 35 | }, 36 | getDefaultProps: function getDefaultProps() { 37 | return { 38 | preserveScrollPosition: false 39 | }; 40 | }, 41 | getCodeMirrorInstance: function getCodeMirrorInstance() { 42 | return this.props.codeMirrorInstance || require('codemirror'); 43 | }, 44 | getInitialState: function getInitialState() { 45 | return { 46 | isFocused: false 47 | }; 48 | }, 49 | componentWillMount: function componentWillMount() { 50 | this.componentWillReceiveProps = debounce(this.componentWillReceiveProps, 0); 51 | if (this.props.path) { 52 | console.error('Warning: react-codemirror: the `path` prop has been changed to `name`'); 53 | } 54 | }, 55 | componentDidMount: function componentDidMount() { 56 | var codeMirrorInstance = this.getCodeMirrorInstance(); 57 | this.codeMirror = codeMirrorInstance.fromTextArea(this.textareaNode, this.props.options); 58 | this.codeMirror.on('change', this.codemirrorValueChanged); 59 | this.codeMirror.on('cursorActivity', this.cursorActivity); 60 | this.codeMirror.on('focus', this.focusChanged.bind(this, true)); 61 | this.codeMirror.on('blur', this.focusChanged.bind(this, false)); 62 | this.codeMirror.on('scroll', this.scrollChanged); 63 | this.codeMirror.setValue(this.props.defaultValue || this.props.value || ''); 64 | }, 65 | componentWillUnmount: function componentWillUnmount() { 66 | // is there a lighter-weight way to remove the cm instance? 67 | if (this.codeMirror) { 68 | this.codeMirror.toTextArea(); 69 | } 70 | }, 71 | componentWillReceiveProps: function componentWillReceiveProps(nextProps) { 72 | if (this.codeMirror && nextProps.value !== undefined && normalizeLineEndings(this.codeMirror.getValue()) !== normalizeLineEndings(nextProps.value)) { 73 | if (this.props.preserveScrollPosition) { 74 | var prevScrollPosition = this.codeMirror.getScrollInfo(); 75 | this.codeMirror.setValue(nextProps.value); 76 | this.codeMirror.scrollTo(prevScrollPosition.left, prevScrollPosition.top); 77 | } else { 78 | this.codeMirror.setValue(nextProps.value); 79 | } 80 | } 81 | if (typeof nextProps.options === 'object') { 82 | for (var optionName in nextProps.options) { 83 | if (nextProps.options.hasOwnProperty(optionName)) { 84 | this.setOptionIfChanged(optionName, nextProps.options[optionName]); 85 | } 86 | } 87 | } 88 | }, 89 | setOptionIfChanged: function setOptionIfChanged(optionName, newValue) { 90 | var oldValue = this.codeMirror.getOption(optionName); 91 | if (!isEqual(oldValue, newValue)) { 92 | this.codeMirror.setOption(optionName, newValue); 93 | } 94 | }, 95 | getCodeMirror: function getCodeMirror() { 96 | return this.codeMirror; 97 | }, 98 | focus: function focus() { 99 | if (this.codeMirror) { 100 | this.codeMirror.focus(); 101 | } 102 | }, 103 | focusChanged: function focusChanged(focused) { 104 | this.setState({ 105 | isFocused: focused 106 | }); 107 | this.props.onFocusChange && this.props.onFocusChange(focused); 108 | }, 109 | cursorActivity: function cursorActivity(cm) { 110 | this.props.onCursorActivity && this.props.onCursorActivity(cm); 111 | }, 112 | scrollChanged: function scrollChanged(cm) { 113 | this.props.onScroll && this.props.onScroll(cm.getScrollInfo()); 114 | }, 115 | codemirrorValueChanged: function codemirrorValueChanged(doc, change) { 116 | if (this.props.onChange && change.origin !== 'setValue') { 117 | this.props.onChange(doc.getValue(), change); 118 | } 119 | }, 120 | render: function render() { 121 | var _this = this; 122 | 123 | var editorClassName = className('ReactCodeMirror', this.state.isFocused ? 'ReactCodeMirror--focused' : null, this.props.className); 124 | return React.createElement( 125 | 'div', 126 | { className: editorClassName }, 127 | React.createElement('textarea', { 128 | ref: function (ref) { 129 | return _this.textareaNode = ref; 130 | }, 131 | name: this.props.name || this.props.path, 132 | defaultValue: this.props.value, 133 | autoComplete: 'off', 134 | autoFocus: this.props.autoFocus 135 | }) 136 | ); 137 | } 138 | }); 139 | 140 | module.exports = CodeMirror; -------------------------------------------------------------------------------- /src/Gistlyn/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | --------------------------------------------------------------------------------