mirror of
https://gitlab.com/buildfeed/BuildFeed.git
synced 2024-03-22 21:10:34 +08:00
Twitter Cards update
Reformat; Add backgrounds for Threshold and Redstone
This commit is contained in:
parent
c4e3b84199
commit
8b35e3733e
|
@ -778,6 +778,7 @@
|
|||
<Compile Include="Models\Build\BuildModel.cs" />
|
||||
<Compile Include="Models\Build\BuildVersion.cs" />
|
||||
<Compile Include="Models\Build\LevelOfFlight.cs" />
|
||||
<Compile Include="Models\Build\ProjectFamily.cs" />
|
||||
<Compile Include="Models\Build\TypeOfSource.cs" />
|
||||
<Compile Include="Models\MetaItem.cs" />
|
||||
<Compile Include="Models\ViewModel\Front\FrontBuildGroup.cs" />
|
||||
|
@ -791,6 +792,8 @@
|
|||
<ItemGroup>
|
||||
<Content Include="BingSiteAuth.xml" />
|
||||
<Content Include="browserconfig.xml" />
|
||||
<Content Include="content\card\Threshold2.png" />
|
||||
<Content Include="content\card\Threshold.png" />
|
||||
<Content Include="content\icons-2x.png" />
|
||||
<Content Include="content\icons.png" />
|
||||
<Content Include="content\tile\wide.png" />
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Drawing.Text;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Mvc;
|
||||
|
@ -92,7 +93,7 @@ public async Task<ActionResult> viewBuild(long id)
|
|||
|
||||
[Route("twitter/{id:guid}/", Name = "Twitter")]
|
||||
#if !DEBUG
|
||||
// [OutputCache(Duration = 600, VaryByParam = "none")]
|
||||
[OutputCache(Duration = 600, VaryByParam = "none")]
|
||||
[CustomContentType(ContentType = "image/png", Order = 2)]
|
||||
#endif
|
||||
public async Task<ActionResult> twitterCard(Guid id)
|
||||
|
@ -100,7 +101,10 @@ public async Task<ActionResult> twitterCard(Guid id)
|
|||
BuildModel b = await bModel.SelectById(id);
|
||||
if (b == null) return new HttpNotFoundResult();
|
||||
|
||||
using (Bitmap bm = new Bitmap(560, 300))
|
||||
string path = Path.Combine(Server.MapPath("~/content/card/"), $"{b.Family}.png");
|
||||
bool backExists = System.IO.File.Exists(path);
|
||||
|
||||
using (Bitmap bm = backExists ? new Bitmap(path) : new Bitmap(1120, 600))
|
||||
{
|
||||
using (Graphics gr = Graphics.FromImage(bm))
|
||||
{
|
||||
|
@ -112,11 +116,15 @@ public async Task<ActionResult> twitterCard(Guid id)
|
|||
gr.SmoothingMode = SmoothingMode.HighQuality;
|
||||
gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
|
||||
gr.FillRectangle(new SolidBrush(Color.FromArgb(0x27, 0x2b, 0x30)), 0, 0, 560, 300);
|
||||
gp.AddString("BUILDFEED", new FontFamily("Segoe UI"), (int)FontStyle.Bold, 16, new Point(20, 20), StringFormat.GenericTypographic);
|
||||
gp.AddString($"Windows NT {b.MajorVersion}.{b.MinorVersion} build", new FontFamily("Segoe UI"), 0, 24, new Point(20, 40), StringFormat.GenericTypographic);
|
||||
gp.AddString(b.Number.ToString(), new FontFamily("Segoe UI Light"), 0, 180, new Point(12, 20), StringFormat.GenericTypographic);
|
||||
gp.AddString($"{b.Lab}", new FontFamily("Segoe UI"), 0, 40, new Point(16, 220), StringFormat.GenericTypographic);
|
||||
if (!backExists)
|
||||
{
|
||||
gr.FillRectangle(new SolidBrush(Color.FromArgb(0x27, 0x2b, 0x30)), 0, 0, 1120, 600);
|
||||
}
|
||||
|
||||
gp.AddString("BUILDFEED", new FontFamily("Segoe UI"), (int)FontStyle.Bold, 32, new Point(40, 32), StringFormat.GenericTypographic);
|
||||
gp.AddString($"{DisplayHelpers.GetDisplayTextForEnum(b.Family)} (WinNT {b.MajorVersion}.{b.MinorVersion})", new FontFamily("Segoe UI"), 0, 48, new Point(40, 80), StringFormat.GenericTypographic);
|
||||
gp.AddString(b.Number.ToString(), new FontFamily("Segoe UI Light"), 0, 280, new Point(32, 96), StringFormat.GenericTypographic);
|
||||
gp.AddString(b.BuildTime.HasValue ? $"{b.Lab}\r\n{b.BuildTime.Value:yyyy/MM/dd HH:mm}" : $"{b.Lab}", new FontFamily("Segoe UI"), 0, 44, new Point(40, 440), StringFormat.GenericTypographic);
|
||||
gr.FillPath(Brushes.White, gp);
|
||||
|
||||
Response.ContentType = "image/png";
|
||||
|
|
|
@ -80,7 +80,7 @@ public async Task<ActionResult> added()
|
|||
IsPermaLink = true,
|
||||
Value = $"{Request.Url.Scheme}://{Request.Url.Authority}{Url.Action("viewBuild", new { controller = "front", id = build.Id })}"
|
||||
},
|
||||
Category = GetCategoryForBuild(build),
|
||||
Category = new RssCategory() { Text = build.Family.ToString() },
|
||||
InternalPubDate = new RssDate(build.Added).DateStringISO8601 // bit of a dirty hack to work around problem in X.Web.RSS with the date format.
|
||||
}).ToList()
|
||||
}
|
||||
|
@ -244,23 +244,5 @@ public async Task<ActionResult> lab(string lab)
|
|||
|
||||
return new EmptyResult();
|
||||
}
|
||||
|
||||
private static RssCategory GetCategoryForBuild(BuildModel b)
|
||||
{
|
||||
if(b.Number >= 11000)
|
||||
{
|
||||
return new RssCategory() { Text = "Redstone" };
|
||||
}
|
||||
else if(b.Number >= 10500)
|
||||
{
|
||||
return new RssCategory() { Text = "Threshold2" };
|
||||
}
|
||||
else if (b.Number >= 9700)
|
||||
{
|
||||
return new RssCategory() { Text = "Threshold" };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -111,6 +111,42 @@ public string FullBuildString
|
|||
}
|
||||
}
|
||||
|
||||
public ProjectFamily Family
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Number >= 11000)
|
||||
{
|
||||
return ProjectFamily.Redstone;
|
||||
}
|
||||
else if (Number >= 10500)
|
||||
{
|
||||
return ProjectFamily.Threshold2;
|
||||
}
|
||||
else if (Number >= 9700)
|
||||
{
|
||||
return ProjectFamily.Threshold;
|
||||
}
|
||||
else if (Number >= 9250)
|
||||
{
|
||||
return ProjectFamily.Windows81;
|
||||
}
|
||||
else if (Number >= 7650)
|
||||
{
|
||||
return ProjectFamily.Windows8;
|
||||
}
|
||||
else if(Number >= 6020)
|
||||
{
|
||||
return ProjectFamily.Windows7;
|
||||
}
|
||||
else if(MajorVersion == 6)
|
||||
{
|
||||
return ProjectFamily.Longhorn;
|
||||
}
|
||||
return ProjectFamily.None;
|
||||
}
|
||||
}
|
||||
|
||||
public string GenerateLabUrl() => (Lab ?? "").Replace('/', '-').ToLower();
|
||||
}
|
||||
}
|
33
BuildFeed/Models/Build/ProjectFamily.cs
Normal file
33
BuildFeed/Models/Build/ProjectFamily.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace BuildFeed.Models
|
||||
{
|
||||
public enum ProjectFamily
|
||||
{
|
||||
None,
|
||||
|
||||
[Display(Name = "Whistler")]
|
||||
Whistler,
|
||||
|
||||
[Display(Name = "Longhorn")]
|
||||
Longhorn,
|
||||
|
||||
[Display(Name = "Windows 7")]
|
||||
Windows7,
|
||||
|
||||
[Display(Name = "Windows 8")]
|
||||
Windows8,
|
||||
|
||||
[Display(Name = "Windows 8.1")]
|
||||
Windows81,
|
||||
|
||||
[Display(Name = "Threshold")]
|
||||
Threshold,
|
||||
|
||||
[Display(Name = "Threshold 2")]
|
||||
Threshold2,
|
||||
|
||||
[Display(Name = "Redstone")]
|
||||
Redstone
|
||||
}
|
||||
}
|
BIN
BuildFeed/content/card/Redstone.png
Normal file
BIN
BuildFeed/content/card/Redstone.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 334 KiB |
BIN
BuildFeed/content/card/Threshold.png
Normal file
BIN
BuildFeed/content/card/Threshold.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 473 KiB |
BIN
BuildFeed/content/card/Threshold2.png
Normal file
BIN
BuildFeed/content/card/Threshold2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 473 KiB |
Loading…
Reference in New Issue
Block a user