Skip to content
This repository was archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
azure cdn - Fixes #51
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdeafcafe committed Oct 8, 2014
1 parent ccb873d commit e8208f0
Show file tree
Hide file tree
Showing 19 changed files with 80 additions and 164 deletions.
18 changes: 11 additions & 7 deletions Branch.App/App_Start/BundleConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,33 @@ public class BundleConfig
// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{
#if !DEBUG
bundles.UseCdn = true;
#endif

// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
bundles.Add(new AzureScriptBundle("~/bundles/modernizr", "cdn", "http://cdn.branchapp.co/cdn/").Include(
bundles.Add(new AzureScriptBundle("~/bundles/modernizr", "cdn", "http://cdn.branchapp.co").Include(
"~/Scripts/modernizr-*"));

bundles.Add(new AzureScriptBundle("~/bundles/flash", "cdn", "http://cdn.branchapp.co/cdn/").Include(
bundles.Add(new AzureScriptBundle("~/bundles/flash", "cdn", "http://cdn.branchapp.co").Include(
"~/Scripts/flash-cookie.js"));

bundles.Add(new AzureScriptBundle("~/bundles/jbclock", "cdn", "http://cdn.branchapp.co/cdn/").Include(
bundles.Add(new AzureScriptBundle("~/bundles/jbclock", "cdn", "http://cdn.branchapp.co").Include(
"~/Scripts/jbclock.js"));
bundles.Add(new AzureStyleBundle("~/bundles/jbclock-styles", "cdn", "http://cdn.branchapp.co/cdn/").Include(
bundles.Add(new AzureStyleBundle("~/bundles/jbclock-styles", "cdn", "http://cdn.branchapp.co").Include(
"~/Content/Styles/jbclock.css"));

// Bootstrap Stuff
bundles.Add(new AzureStyleBundle("~/bundles/bootstrap-custom", "cdn", "http://cdn.branchapp.co/cdn/").Include(new[] {
bundles.Add(new AzureStyleBundle("~/bundles/bootstrap-custom", "cdn", "http://cdn.branchapp.co").Include(new[] {
"~/Content/Styles/bootstrap-custom.min.css",
"~/Content/Styles/bootstrap-branch.css"
}));
bundles.Add(new AzureScriptBundle("~/bundles/bootstrap-scripts", "cdn", "http://cdn.branchapp.co/cdn/").Include(
bundles.Add(new AzureScriptBundle("~/bundles/bootstrap-scripts", "cdn", "http://cdn.branchapp.co").Include(
"~/Scripts/bootstrap-3.0.0.js"));

// branch specific styles
bundles.Add(new AzureStyleBundle("~/bundles/branch-specific", "cdn", "http://cdn.branchapp.co/cdn/").Include(
bundles.Add(new AzureStyleBundle("~/bundles/branch-specific", "cdn", "http://cdn.branchapp.co").Include(
"~/Content/Styles/application.css"
));
}
Expand Down
4 changes: 2 additions & 2 deletions Branch.App/Areas/Halo4/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@
</div>

<div class="stats-marketing spacing">
<div class="container auntie-dot">
<div class="container auntie-dot" style="background-image: url('@CdnHelpers.GetAssetLocale(false)Content/Images/Area/Halo4/auntiediag.png');">

</div>
</div>

Expand Down
22 changes: 2 additions & 20 deletions Branch.App/Areas/Reach/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,16 @@
using System.Web.Mvc;
using Branch.App.Areas.Reach.Filters;
using Branch.App.Areas.Reach.Models;
using Branch.Core.Game.HaloReach.Models.Branch;
using Branch.Models.Services.Branch;

namespace Branch.App.Areas.Reach.Controllers
{
public class HomeController : Controller
{
//
// GET: /360/Reach/
// GET: /Game/Reach/
[ValidateReachApiStatus]
public ActionResult Index()
{
var total = GlobalStorage.AzureStorage.Table.QueryAndRetrieveCount<GamerIdEntity>("",
GlobalStorage.AzureStorage.Table.BranchCloudTable);

var reachTotal = GlobalStorage.AzureStorage.Table.QueryAndRetrieveCount<ServiceRecordEntity>("",
GlobalStorage.AzureStorage.Table.HReachCloudTable);

//var replacement =
//storage.Table.QueryAndRetrieveSingleEntity<GamerIdReplacementEntity>(
// TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, GamerIdReplacementEntity.PartitionKeyString),
// TableOperators.And,
// TableQuery.GenerateFilterConditionForInt("TypeInt", QueryComparisons.Equal, (int)gamerIdType),
// TableOperators.And,
// TableQuery.GenerateFilterCondition("SafeReplacementId", QueryComparisons.Equal, gamerId.ToLowerInvariant()),
// storage.Table.BranchCloudTable);

return View(new HomeViewModel { TotalPlayers = total, TotalReachPlayers = reachTotal });
return View();
}
}
}
9 changes: 0 additions & 9 deletions Branch.App/Areas/Reach/Models/HomeViewModel.cs

This file was deleted.

47 changes: 2 additions & 45 deletions Branch.App/Areas/Reach/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
@using Branch.App.Helpers.Razor
@using Branch.App.Areas.Reach.Models
@model HomeViewModel
@{
ViewBag.Title = "Halo: Reach";
Layout = "~/Views/Shared/_Layout.cshtml";
Expand All @@ -19,26 +17,9 @@
</div>
</div>

<div class="stats-marketing">
<div class="stats-marketing" style="height: 350px;">
<div class="container">
<div class="row central">
<div class="col-md-offset-1 col-md-4">
<canvas id="all-branch-players" width="140" height="140"></canvas>

<h2>Branch Players</h2>
<p>
@(BranchHelpers.NumberWithDelimiter(Model.TotalPlayers)) players have assosiated their gamertags with Branch
</p>
</div>
<div class="col-md-offset-2 col-md-4">
<canvas id="all-reach-players" width="140" height="140"></canvas>

<h2>Halo: Reach Players</h2>
<p>
@(BranchHelpers.NumberWithDelimiter(Model.TotalReachPlayers)) of those players have played Halo: Reach
</p>
</div>
</div>
</div>
</div>

Expand All @@ -53,36 +34,12 @@
</div>

<div class="stats-marketing spacing">
<div class="container auntie-dot">
<div class="container auntie-dot" style="background-image: url('@CdnHelpers.GetAssetLocale(false)Content/Images/Area/Halo4/auntiediag.png');">

</div>
</div>

@section scripts {
<!-- Playlist Stats -->
<script>
ctx = document.getElementById("all-branch-players").getContext("2d");
new Chart(ctx).Doughnut(
[
{
value: 69,
color: '#F7464A'
}
]);
ctx = document.getElementById("all-reach-players").getContext("2d");
new Chart(ctx).Doughnut(
[
{
value: @(Model.TotalReachPlayers),
color: '#F7464A'
},
{
value: @(Model.TotalPlayers),
color: '#4D5360'
}
]);
</script>

<!-- Background Images -->
<script>
var imagesCount = 4;
Expand Down
1 change: 0 additions & 1 deletion Branch.App/Branch.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@
<Compile Include="Areas\Reach\Models\GameDetailsTeamViewModel.cs" />
<Compile Include="Areas\Reach\Models\GameViewModel.cs" />
<Compile Include="Areas\Reach\Models\HistoryViewModel.cs" />
<Compile Include="Areas\Reach\Models\HomeViewModel.cs" />
<Compile Include="Areas\Reach\Models\ServiceRecordViewModel.cs" />
<Compile Include="Areas\Reach\ReachAreaRegistration.cs" />
<Compile Include="Controllers\ErrorController.cs" />
Expand Down
12 changes: 9 additions & 3 deletions Branch.App/Content/Styles/Areas/Halo4/_home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ body.halo4_homepage {
padding: 40px 0;

> .auntie-dot {
background: url('../Images/Area/Halo4/auntiediag.png') center no-repeat;
background-position: center;
background-repeat: no-repeat;
background-size: 100px;
height: 250px;
}
Expand Down Expand Up @@ -161,15 +162,20 @@ body.halo4_homepage {
}

&.page-bg-backup-cover {
background: url('../Images/Home/Covers/Halo4/cover1.jpg') no-repeat center 0 fixed;
background-repeat: no-repeat;
background-position: center 0;
background-attachment: fixed;
background-size: cover;
width: 100%;
height: 100%;
top: 0;
left: 0;

.page-bg-cover {
background: url('../Images/Home/Covers/Halo4/cover1.jpg') no-repeat center 0 fixed;
background-repeat: no-repeat;
background-position: center 0;
background-attachment: fixed;
background-size: cover;
background-size: cover;
width: 100%;
min-height: 100%;
Expand Down
17 changes: 8 additions & 9 deletions Branch.App/Content/Styles/Areas/Reach/_home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ body.reach {
padding: 0;
margin: 0;
background-attachment: fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;

@media (max-width: 767px) {
Expand Down Expand Up @@ -73,9 +70,6 @@ body.reach {
height: 321px;
width: 300px;
background-repeat: no-repeat;
-moz-transform: scaleX(-1);
-o-transform: scaleX(-1);
-webkit-transform: scaleX(-1);
transform: scaleX(-1);
filter: FlipH;
-ms-filter: "FlipH";
Expand Down Expand Up @@ -124,7 +118,8 @@ body.reach_homepage {
padding: 40px 0;

> .auntie-dot {
background: url('../Images/Area/Halo4/auntiediag.png') center no-repeat;
background-repeat: no-repeat;
background-position: center;
background-size: 100px;
height: 250px;
}
Expand Down Expand Up @@ -157,15 +152,19 @@ body.reach_homepage {
}

&.page-bg-backup-cover {
background: url('../Images/Home/Covers/Reach/cover1.jpg') no-repeat center 0 fixed;
background-repeat: no-repeat;
background-position: center 0;
background-attachment: fixed;
background-size: cover;
width: 100%;
height: 100%;
top: 0;
left: 0;

.page-bg-cover {
background: url('../Images/Home/Covers/Reach/cover1.jpg') no-repeat center 0 fixed;
background-repeat: no-repeat;
background-position: center 0;
background-attachment: fixed;
background-size: cover;
width: 100%;
min-height: 100%;
Expand Down
29 changes: 17 additions & 12 deletions Branch.App/Content/Styles/application.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Branch.App/Content/Styles/application.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Branch.App/Content/Styles/application.min.css

Large diffs are not rendered by default.

18 changes: 7 additions & 11 deletions Branch.App/Extentions/BundleExtentions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
using System.Text;
using System.Web;
using System.Web.Optimization;
using Microsoft.WindowsAzure.Storage;
#if !DEBUG && !LOCALRELEASE
using Microsoft.WindowsAzure;
#endif
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;

namespace Branch.App.Extentions
{
Expand Down Expand Up @@ -54,6 +53,7 @@ public AzureStyleBundle(string virtualPath, string containerName, string cdnHost
public class AzureBlobUpload : IBundleTransform
{
public string ContainerName { get; set; }

public string CdnHost { get; set; }

public virtual void Process(BundleContext context, BundleResponse response)
Expand All @@ -69,21 +69,17 @@ public virtual void Process(BundleContext context, BundleResponse response)
throw new Exception("ContainerName Not Set");
}

#if DEBUG || LOCALRELEASE
const string connectionString = "UseDevelopmentStorage=true";
#else
var connectionString = CloudConfigurationManager.GetSetting("StorageConnectionString");
#endif

var conn = CloudStorageAccount.Parse(connectionString);
var blob = conn.CreateCloudBlobClient()
.GetContainerReference(ContainerName)
.GetBlockBlobReference(file);
var cont = conn.CreateCloudBlobClient().GetContainerReference(ContainerName);
cont.CreateIfNotExists(BlobContainerPublicAccessType.Blob);
var blob = cont.GetBlockBlobReference(file);

blob.Properties.ContentType = response.ContentType;
blob.UploadText(response.Content);

var uri = string.IsNullOrWhiteSpace(CdnHost) ? blob.Uri.AbsoluteUri.Replace("http:", "").Replace("https:", "") : string.Format("//{0}/{1}/{2}", CdnHost, ContainerName, file);
var uri = string.IsNullOrWhiteSpace(CdnHost) ? blob.Uri.AbsoluteUri.Replace("http:", "").Replace("https:", "") : string.Format("{0}/{1}/{2}", CdnHost, ContainerName, file);

using (var hashAlgorithm = CreateHashAlgorithm())
{
Expand Down
Loading

0 comments on commit e8208f0

Please sign in to comment.