Permalink
Browse files

Merge pull request #7 from mdavid/merge-select-commits-from-toptensof…

…tware-master

Merge select commits from toptensoftware master
  • Loading branch information...
2 parents 99087c6 + 9b65ef3 commit c441fcdbfa607d5f19a314a4086702c0319f3711 @mdavid committed May 14, 2012
@@ -9,7 +9,6 @@
<OutputType>Library</OutputType>
<RootNamespace>Manos.Tests</RootNamespace>
<AssemblyName>Manos.Tests</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
@@ -43,8 +42,7 @@
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath>
</Reference>
- <Reference Include="System">
- </Reference>
+ <Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
@@ -70,9 +68,9 @@
<Compile Include="Manos.Routing\HtmlFormDataTypeConverterTest.cs" />
</ItemGroup>
<ItemGroup />
- <Target Name="ListSources">
- <Message Text="@(Compile)" Importance="High" />
- </Target>
+ <Target Name="ListSources">
+ <Message Text="@(Compile)" Importance="High" />
+ </Target>
<ItemGroup>
<ProjectReference Include="..\Manos\Manos.csproj">
<Project>{2548B25A-2E1F-4E21-BC43-7E39B1F6F23F}</Project>
@@ -209,7 +209,7 @@ public RouteHandler Route (string pattern, MatchType matchType, ManosAction acti
return AddRouteHandler (action, ops, HttpMethods.GetMethods);
}
- public RouteHandler Route (ManosAction action, params string [] patterns)
+ public RouteHandler Route(ManosAction action, params string[] patterns)
{
return AddRouteHandler (action, patterns, HttpMethods.RouteMethods);
}
@@ -219,6 +219,14 @@ public RouteHandler Route (IManosModule module, params string [] patterns)
return AddRouteHandler (module, patterns, HttpMethods.RouteMethods);
}
+ // Used by Manos.Mvc
+ public RouteHandler Route(string pattern, MatchType matchType, ManosAction action, HttpMethod[] methods)
+ {
+ IMatchOperation[] ops = OpsForPatterns(new string[] { pattern }, matchType);
+
+ return AddRouteHandler(action, ops, methods);
+ }
+
public RouteHandler Get (string pattern, IManosModule module)
{
return AddRouteHandler (module, new string [] { pattern }, HttpMethods.GetMethods);
@@ -91,7 +91,9 @@ public BuildCommand (Environment env)
public void Run ()
{
- if (RunXBuild ())
+ ManosConfig.Load();
+
+ if (RunXBuild())
return;
if (RunMake ())
return;
@@ -169,13 +171,42 @@ private void FindCSFilesRecurse (string dir, List<string> sources)
AddDefaultReferences (libs);
+ // Find any additional dlls in project file
foreach (string lib in Directory.GetFiles (Directory.GetCurrentDirectory ())) {
if (!lib.EndsWith (".dll", StringComparison.InvariantCultureIgnoreCase))
continue;
if (Path.GetFileName (lib) == OutputAssembly)
continue;
libs.Add (lib);
}
+
+ // Read additional referenced assemblies from manos.config in project folder:
+ // eg:
+ //
+ // [manos]
+ // ReferencedAssemblies=System.Core.dll Microsoft.CSharp.dll Manos.Mvc.dll
+ //
+ if (ManosConfig.Main != null)
+ {
+ var strReferencedAssemblies = ManosConfig.GetExpanded ("ReferencedAssemblies");
+ if (strReferencedAssemblies != null)
+ {
+ var referencedAssemblies = strReferencedAssemblies.Split (' ', ',');
+ foreach (var a in referencedAssemblies)
+ {
+ string ManosFile = System.IO.Path.Combine (Environment.ManosDirectory, a);
+ if (System.IO.File.Exists (ManosFile))
+ {
+ libs.Add (ManosFile);
+ }
+ else
+ {
+ libs.Add (a);
+ }
+
+ }
+ }
+ }
return libs.ToArray ();
}
View
@@ -127,32 +127,44 @@ private static void SetOutput (string file)
private static int Init (IList<string> args)
{
- if (args.Count < 1) {
- Console.WriteLine ("manos --init <AppName>");
- Console.WriteLine ("This will initialize a new application with the supplied name.");
- return 1;
- }
-
+ string layout = null;
+ var p = new OptionSet() {
+ { "-l|layout=", v => layout = v },
+ };
+
+
Driver d = new Driver ();
try {
- Console.WriteLine ("initing: {0}", args [0]);
- d.Init (args [0]);
- } catch (Exception e) {
+
+ List<string> extra = p.Parse(args);
+
+ if (extra.Count < 1)
+ {
+ Console.WriteLine("manos [--layout=<LayoutName>] --init <AppName>");
+ Console.WriteLine("This will initialize a new application with the supplied name.");
+ }
+
+ if (layout == null)
+ layout = "default";
+ string appname = extra[0];
+
+ Console.WriteLine("initing: {0} with layout {1}", appname, layout);
+
+ InitCommand initer = new InitCommand(Environment, appname);
+ initer.Layout = layout;
+
+ initer.Run();
+ }
+ catch (Exception e)
+ {
Console.WriteLine ("error while initializing application:");
Console.WriteLine (e);
return 1;
}
return 0;
}
-
- public void Init (string name)
- {
- InitCommand initer = new InitCommand (Environment, name);
-
- initer.Run ();
- }
private static int Server (IList<string> args)
{
@@ -179,6 +191,8 @@ public void RunServer (IList<string> args)
string user = null;
string assembly = null;
string ipaddress = null;
+ string browse = null;
+ string docroot = null;
var p = new OptionSet () {
{ "p|port=", v => port = v },
@@ -187,7 +201,9 @@ public void RunServer (IList<string> args)
{ "k|keyfile=", v => keyFile = v },
{ "u|user=", v => user = v },
{ "a|assembly=", v=> assembly = v},
- { "l|listen=", v => ipaddress = v }
+ { "l|listen=", v => ipaddress = v },
+ { "b|browse=", v => browse = v },
+ { "d|docroot=", v => docroot = v}
};
args = p.Parse(args);
@@ -228,6 +244,12 @@ public void RunServer (IList<string> args)
if (ipaddress != null)
cmd.IPAddress = ipaddress;
+ if (docroot != null)
+ cmd.DocumentRoot = docroot;
+
+ if (browse != null)
+ cmd.Browse = browse;
+
cmd.Run ();
}
@@ -77,8 +77,9 @@ public InitCommand (Environment env, string name)
get {
if (layout == null)
return "default";
- return Layout;
+ return layout;
}
+
set {
if (value == null) {
layout = null;
@@ -125,7 +126,7 @@ public void Run ()
string dest = Path.Combine (target.FullName, file.Name);
file.CopyTo (dest);
- if (file.Extension == ".cs")
+ if (file.Extension == ".cs" || file.Extension==".cshtml" || file.Extension == ".sln" || file.Extension ==".csproj" || file.Extension == ".user")
ConvertCSFile (dest);
ConvertFileName (dest);
@@ -151,7 +152,9 @@ private void ConvertFileName (string name)
private string Convert (string src)
{
- return src.Replace ("$APPNAME", ApplicationName);
+ src = src.Replace ("$APPNAME", ApplicationName);
+ src = src.Replace ("$MANOSDIR", System.IO.Path.GetDirectoryName(GetType().Assembly.Location));
+ return src;
}
public bool IsLegalApplicationName (string name)
@@ -122,9 +122,25 @@ public ServerCommand (Environment env, IList<string> args)
get;
set;
}
+
+ public string Browse {
+ get;
+ set;
+ }
+
+ public string DocumentRoot {
+ get;
+ set;
+ }
public void Run ()
{
+ // Setup the document root
+ if (DocumentRoot != null)
+ {
+ System.IO.Directory.SetCurrentDirectory(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), DocumentRoot));
+ }
+
// Load the config.
ManosConfig.Load ();
@@ -146,9 +162,38 @@ public void Run ()
AppHost.SecureListenAt (new Manos.IO.IPEndPoint (listenAddress, SecurePort.Value), CertificateFile, KeyFile);
Console.WriteLine ("Running {0} on secure port {1}.", app, SecurePort);
}
+
+ if (Browse != null)
+ {
+ var hostname = IPAddress == null ? "http://localhost" : "http://" + IPAddress;
+ if (Port != 80)
+ hostname += ":" + Port.ToString();
+
+ if (Browse == "")
+ {
+ Browse = hostname;
+ }
+ if (Browse.StartsWith("/"))
+ {
+ Browse = hostname + Browse;
+ }
+
+ if (!Browse.StartsWith("http://") && !Browse.StartsWith("https://"))
+ Browse = "http://" + Browse;
+
+ AppHost.AddTimeout(TimeSpan.FromMilliseconds(10), RepeatBehavior.Single, Browse, DoBrowse);
+ }
+
AppHost.Start (app);
}
-
+
+ private static void DoBrowse(ManosApp app, object user_data)
+ {
+ string BrowseTo = user_data as string;
+ Console.WriteLine("Launching {0}", BrowseTo);
+ System.Diagnostics.Process.Start(BrowseTo);
+ }
+
public void SetServerUser (string user)
{
if (user == null)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -9,7 +9,6 @@
<OutputType>Exe</OutputType>
<RootNamespace>manostool</RootNamespace>
<AssemblyName>manostool</AssemblyName>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
@@ -37,15 +36,14 @@
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="Mono.Posix">
<HintPath>..\..\dependencies\Mono.Posix.dll</HintPath>
</Reference>
- <Reference Include="Nini, Version=1.1.0.0, Culture=neutral, PublicKeyToken=691faec150a7fa7b, processorArchitecture=MSIL">
+ <Reference Include="Nini">
<HintPath>..\packages\Trove.Nini.1.1.0.0\lib\net20\Nini.dll</HintPath>
</Reference>
- <Reference Include="System" />
- <Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Driver.cs" />

0 comments on commit c441fcd

Please sign in to comment.