Skip to content

Commit

Permalink
Merge pull request #15 from brooksyd2/master
Browse files Browse the repository at this point in the history
Amended for use with v3 of 51 Degrees API
  • Loading branch information
adoprog committed Aug 28, 2014
2 parents 7c380f0 + b9cf620 commit 8ac4ad5
Show file tree
Hide file tree
Showing 59 changed files with 4,981 additions and 467 deletions.
6 changes: 6 additions & 0 deletions .nuget/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
</configuration>
Binary file added .nuget/NuGet.exe
Binary file not shown.
144 changes: 144 additions & 0 deletions .nuget/NuGet.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>

<!-- Enable the restore command to run before builds -->
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>

<!-- Property that enables building a package from a project -->
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>

<!-- Determines if package restore consent is required to restore packages -->
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>

<!-- Download NuGet.exe if it does not already exist -->
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
</PropertyGroup>

<ItemGroup Condition=" '$(PackageSources)' == '' ">
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
<!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
<!--
<PackageSource Include="https://www.nuget.org/api/v2/" />
<PackageSource Include="https://my-nuget-source/nuget/" />
-->
</ItemGroup>

<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
<!-- Windows specific commands -->
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
</PropertyGroup>

<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
</PropertyGroup>

<PropertyGroup>
<PackagesProjectConfig Condition=" '$(OS)' == 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config</PackagesProjectConfig>
<PackagesProjectConfig Condition=" '$(OS)' != 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config</PackagesProjectConfig>
</PropertyGroup>

<PropertyGroup>
<PackagesConfig Condition="Exists('$(MSBuildProjectDirectory)\packages.config')">$(MSBuildProjectDirectory)\packages.config</PackagesConfig>
<PackagesConfig Condition="Exists('$(PackagesProjectConfig)')">$(PackagesProjectConfig)</PackagesConfig>
</PropertyGroup>

<PropertyGroup>
<!-- NuGet command -->
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>

<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 "$(NuGetExePath)"</NuGetCommand>

<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>

<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>

<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>

<!-- Commands -->
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>

<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
RestorePackages;
$(BuildDependsOn);
</BuildDependsOn>

<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
$(BuildDependsOn);
BuildPackage;
</BuildDependsOn>
</PropertyGroup>

<Target Name="CheckPrerequisites">
<!-- Raise an error if we're unable to locate nuget.exe -->
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
<!--
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
This effectively acts as a lock that makes sure that the download operation will only happen once and all
parallel builds will have to wait for it to complete.
-->
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
</Target>

<Target Name="_DownloadNuGet">
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
</Target>

<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(RestoreCommand)"
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />

<Exec Command="$(RestoreCommand)"
LogStandardErrorAsError="true"
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
</Target>

<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(BuildCommand)"
Condition=" '$(OS)' != 'Windows_NT' " />

<Exec Command="$(BuildCommand)"
LogStandardErrorAsError="true"
Condition=" '$(OS)' == 'Windows_NT' " />
</Target>

<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Net" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
OutputFilename = Path.GetFullPath(OutputFilename);
Log.LogMessage("Downloading latest version of NuGet.exe...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
return true;
}
catch (Exception ex) {
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
</Project>
Binary file added Mobile Device Detector.update
Binary file not shown.
104 changes: 78 additions & 26 deletions MobileDeviceDetector/51Degrees.mobi.config
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<?xml version="1.0"?>
<configuration>
<!-- Necessary to get the sections below read properly.-->
<!-- These configuration sections tell .NET how to handle the FiftyOne.Foundation.Mobile
configuration settings further down the web.config file -->
<configSections>
<sectionGroup name="fiftyOne">
<section name="log" type="FiftyOne.Foundation.Mobile.Configuration.LogSection, FiftyOne.Foundation" requirePermission="false" allowDefinition="Everywhere" restartOnExternalChanges="false" allowExeDefinition="MachineToApplication"/>
<section name="redirect" type="FiftyOne.Foundation.Mobile.Configuration.RedirectSection, FiftyOne.Foundation" requirePermission="false" allowDefinition="Everywhere" restartOnExternalChanges="false" allowExeDefinition="MachineToApplication"/>
<section name="detection" type="FiftyOne.Foundation.Mobile.Detection.Configuration.DetectionSection, FiftyOne.Foundation" requirePermission="false" allowDefinition="Everywhere" restartOnExternalChanges="false" allowExeDefinition="MachineToApplication"/>
</sectionGroup>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Detector.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="imageOptimisation" type="FiftyOne.Foundation.Mobile.Configuration.ImageOptimisationSection, FiftyOne.Foundation" requirePermission="false" allowDefinition="Everywhere" restartOnExternalChanges="false" allowExeDefinition="MachineToApplication"/>
</sectionGroup>
</configSections>
<fiftyOne>

<!--<redirect> element controls how requests from mobile devices are handled.
mobileHomePageUrl Previously mobileRedirectUrl under the mobile/toolkit element.
A url to direct mobile devices to instead of the normal web sites
Expand All @@ -30,7 +29,8 @@
request. Needed to ensure multiple worker processes have a consistent
view of previous activity. (Optional – random behaviour will be
experienced if not specified on web sites with more than one worker
processes)
processes). In Windows Azure this value becomes the name of devices
cloud table that will be used instead of a file.
mobilePagesRegex A regular expression that when applied to the current request Path
(context.Request.AppRelativeCurrentExecutionFilePath) or the requesting
Urlwill return true if it should be considered a mobile page. Use
Expand All @@ -49,47 +49,99 @@
locations/location Provides details of different locations requests can be directed to based
on the values of defined properties associated with the device or request.
(Optional)
name A unique identifier for the location. Used for debugging in the log file.(Mandatory)
url the URL of the redirect location to use if all the properties in the
collection match. (Mandatory)
matchExpression can be used to provide a regular expression which will take the requesting
URL as input match segments to be used in place of numeric parameters contained
within {} in the url attribute. (Optional)
The location element contains a collection of criteria that all need to match
for the location to be used. Two attributes must be specified with each entry.
property the property of HttpRequest, HttpRequest.Browser or WURFL capability to
property the property of HttpRequest, HttpRequest.Browser or 51Degrees.mobi property to
use when evaluating the matchExpression attribute. (Mandatory)
matchExpression a regular expression used to evaluate the value of the property. (Mandatory)
-->
<redirect firstRequestOnly="false"
mobileHomePageUrl="~/mobile/default.aspx"
timeout="20"
devicesFile="~/App_Data/Devices.dat"
mobilePagesRegex="mobile">

<redirect devicesFile="" timeout="20" firstRequestOnly="true"
originalUrlAsQueryString="false" mobileHomePageUrl="~/Mobile/Default.aspx"
mobilePagesRegex="/(Mobile|Tablet)/">
<locations>
<clear />
<location name="noredirect" url="" matchExpression="" enabled="true">
<add property="Url" matchExpression="[&amp;|\?]noredirect" enabled="true" />
</location>
<location name="Mobile" url="~/Mobile/Default.aspx" matchExpression=""
enabled="true">
<add property="IsMobile" matchExpression="True" enabled="true" />
<add property="IsTablet" matchExpression="False" enabled="true" />
</location>
<location name="Tablet" url="~/Tablet/Default.aspx" matchExpression=""
enabled="true">
<add property="IsTablet" matchExpression="True" enabled="true" />
</location>
</locations>
</redirect>

<!--<log> element controls where and how much information should be recorded in the log.
logFile The location of the log file. (Mandatory)
logFile The location of the log file in ASP.NET or the name of the log table in
Windows Azure. (Mandatory)
logLevel Values include Debug|Info|Warn|Fatal and control the level of information
logged. Defauls to Fatal if not specified. (Optional)-->
<log logFile="~/App_Data/Log.txt" logLevel="Info"/>
logged. Defaults to Fatal if not specified. (Optional)-->

<log logFile="~/App_Data/Log.txt" logLevel="Warn"/>

<!--<detection> element controls where the data files used are provided. If it is not present
the embedded device data will be used. This is the default behaviour.
If a Premium Data license key is present in a file with the extension .lic in the bin folder,
or provided in the FiftyOne.Foundation.Mobile.Detection.Constants.PremiumLicenceKey constant the
binaryFilePath attribute of the detection element must be provided and the worker process must have
modify access to the file to enable automatic updates to be downloaded.
If a Premium/Ultimate Data license key is present in a file with the extension .lic in the bin
folder, or provided in the FiftyOne.Foundation.Mobile.Detection.Constants.PremiumLicenceKey
constant the binaryFilePath attribute of the detection element must be provided and the worker
process must have modify access to the file to enable automatic updates to be downloaded.
binaryFilePath Path to the binary data file. (Optional - Lite / Mandatory - Premium)
enabled Controls whether device detection is enabled. Defaults to true. (Optional)
autoUpdate When set to true enables automatic updating of device data when licence keys
are provided. Defaults to true. (Optional)
binaryFilePath Path to the binary data file. (Optional - Lite / Mandatory - Premium / Enterprise)
shareUsage Set to true to share usage information with 51Degrees.mobi. Read the Usage Data FAQ
to learn more. Defaults to True if not specified. (Optional)
xmlFiles/add Provides one or more data files in XML form to use for detection.
name The unique internal name of the XML file. (Mandatory)
filePath Path to the xml format file. (Mandatory)
enabled True or false to enable or disable processing the file. Default true. (Optional)
memoryMode True if the data set should be loaded into memory. Detection performance will be
significantly faster at the expense of a longer startup time and increased memory
usage. Defaults to False if not specified. (Optional)
bandwidthMonitoringEnabled When set to true enables bandwidth monitoring. Also requires the data
set specified in the binaryFilePath attribute to support bandwidth
monitoring. Defaults to True if not specified. (Optional)
featureDetectionEnabled When set to true enables feature detection. Also requires the data set
specified in the binaryFilePath attribute to support feature detection.
Defaults to True if not specified. (Optional)
-->

<detection binaryFilePath="~/App_Data/51Degrees.mobi-Lite.dat"/>
<!-- IMPORTANT - Ensure this link is uncomment after purchasing Enhanced Device Data. -->
<!-- <detection enabled="true" autoUpdate="true" binaryFilePath="~/App_Data/51Degrees.dat" /> -->

<!-- <imageOptimisation> elements controls the operation of the image optimiser. If not specified
the functionality is disabled.
enabled Controls whether image optimisation is enabled. Defaults to true. Device detection must
also be enabled for image optimisation. (Optional)
factor The request image dimensions of height and width are divided by this value and remainder
subtracted from the requests height and width. The value can be used to limit the number
of images that can be generated and stored in the cache. For example; a value of 50
would result in images of width 50, 100, 150, 250, 300, etc pixels being generated.
Optional default to 1.
heightParam The name used when specifying the height of the image to return.
Optional defaults to "h"
maxHeight The maximum height in pixels the image optimiser is allowed to render. A value of 0
indicates there is no maximum height. Optional defaults to 0.
maxWidth The maximum width in pixels the image optimiser is allowed to render. A value of 0
indicates there is no maximum width. Optional defaults to 0.
widthParam The name used when specifying the width of the image to return.
Optional defaults to "w"
defaultAuto If an image is requested with a width or height set to "auto", the parameter will be
changed to the value set in ‘defaultAuto’. This is most useful for clients without
javascript that should still be served images, such as search crawlers.
Optional, defaults to 50.
-->
<imageOptimisation enabled="true" maxWidth="1000" maxHeight="1000"
widthParam="w" heightParam="h" factor="1" defaultAuto="50"/>

</fiftyOne>
</configuration>
Binary file not shown.
Loading

0 comments on commit 8ac4ad5

Please sign in to comment.