Skip to content

Commit cc62112

Browse files
committed
Add support for preset-urls, add link to photography
1 parent 0690d28 commit cc62112

File tree

5 files changed

+45
-5
lines changed

5 files changed

+45
-5
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ release/*
3838
*.DS_Store
3939
*.dotCover
4040
packages/*
41-
node-modules/*
41+
node-modules/*
42+
uploads/*

ImageResizer/Global.asax.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class ImageService : Service
4242
const int ThumbnailSize = 100;
4343
readonly string UploadsDir = "~/uploads".MapHostAbsolutePath();
4444
readonly string ThumbnailsDir = "~/uploads/thumbnails".MapHostAbsolutePath();
45-
45+
4646
public object Get(Images request)
4747
{
4848
return Directory.GetFiles(UploadsDir).SafeConvertAll(x => x.SplitOnLast(Path.DirectorySeparatorChar).Last());
@@ -179,8 +179,15 @@ public static Image Crop(Image Image, int newWidth, int newHeight, int startX =
179179

180180
public object Any(Reset request)
181181
{
182+
if (!Directory.Exists(UploadsDir))
183+
Directory.CreateDirectory(UploadsDir);
184+
if (!Directory.Exists(ThumbnailsDir))
185+
Directory.CreateDirectory(ThumbnailsDir);
186+
182187
Directory.GetFiles(UploadsDir).ToList().ForEach(File.Delete);
183-
Directory.GetFiles(ThumbnailsDir).ToList().ForEach(File.Delete);
188+
Directory.GetFiles(ThumbnailsDir).ToList().ForEach(File.Delete);
189+
File.ReadAllLines("~/preset-urls.txt".MapHostAbsolutePath()).ToList()
190+
.ForEach(url => WriteImage(new MemoryStream(url.Trim().GetBytesFromUrl())));
184191
return HttpResult.Redirect("/");
185192
}
186193
}

ImageResizer/ImageResizer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
<ItemGroup>
8989
<Content Include="default.html" />
9090
<Content Include="Global.asax" />
91+
<Content Include="preset-urls.txt" />
9192
<Content Include="Web.config" />
9293
</ItemGroup>
9394
<ItemGroup>

ImageResizer/default.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
padding: 0 50px 0 0;
1919
}
2020
input[type=text] {
21-
width: 300px;
21+
width: 360px;
2222
}
2323
ul, li {
2424
margin: 0;
@@ -55,7 +55,8 @@
5555
<body>
5656
<p class="links">
5757
<a href="https://github.com/ServiceStack/ServiceStack.UseCases/blob/master/ImageResizer/Global.asax.cs">1 Page C#</a> /
58-
<a href="https://github.com/ServiceStack/ServiceStack.UseCases/blob/master/ImageResizer/default.html">1 HTML</a>
58+
<a href="https://github.com/ServiceStack/ServiceStack.UseCases/blob/master/ImageResizer/default.html">1 HTML</a> /
59+
<a href="http://stuckincustoms.smugmug.com/">photography</a>
5960
<a href="http://www.servicestack.net"><img src="http://mythz.servicestack.net/favicon.png" title="ServiceStack" height="16" align="absmiddle" /></a>
6061
</p>
6162

ImageResizer/preset-urls.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
http://www.servicestack.net/files/bg-batman.jpg
2+
http://www.servicestack.net/files/bg-whitehouse.jpg
3+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-rqtfDTH/3/X3/4070581709_a1c668a779_o-X3.jpg
4+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-r69c4Dw/1/X3/2035748576_c051526ca4_o-X3.jpg
5+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-HZT8VDH/0/X3/Trey%20Ratcliff%20-%20Aurora%20Australis%20-%20Landing%20on%20the%20River%20-%20Queenstown%20-%20New%20Zealand-X3.jpg
6+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-NK5mrcw/0/X3/Trey%20Ratcliff%20-%20New%20York%20Grand%20Central%201-X3.jpg
7+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-MFzLngb/1/X3/The%20gentle%20path%204-X3.jpg
8+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-xxgv8FG/0/X3/Portofino2-X3.jpg
9+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-F2FbzQg/2/X3/799314036_331bef450a_o-X3.jpg
10+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-zdp4tDq/1/X3/The%20last%20photo%20of%20the%20Eiffel%20Tower-X3.jpg
11+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-936S5Nk/0/X3/Trey%20Ratcliff%20-%20New%20York%20-%20Inception-X3.jpg
12+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-66M7Njr/0/X3/The%20Solstice%20Horse-X3.jpg
13+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-zKmqTqj/1/X3/182191565_11129fc8df_o-X3.jpg
14+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-khJF5DB/0/X3/Trey%20Ratcliff%20-%20China%202011%20-%20A%20Great%20Wall%20at%20Sunset-X3.jpg
15+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-4pbcM4F/0/X3/387019269_068fd16670_o-X3.jpg
16+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-VmLgtDK/0/X3/3792320953_d5b5c4f4f9_o-X3.jpg
17+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-Xf65QHX/1/X3/Beijing%20at%20Night-X3.jpg
18+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-RQ76Wtw/0/X3/Warm%20Fisherman%20in%20Guilin-X3.jpg
19+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-RKW4FVs/2/X3/trey-ratcliff-morning-river-new-zealand-X3.jpg
20+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-z4fxHJQ/0/X3/Trey%20Ratcliff%20-%20Queenstown%20Rocks-X3.jpg
21+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-Z3HcnKv/0/X3/2049233526_19f97ff57f_o-X3.jpg
22+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-DRGqgTV/0/X3/Approaching%20Yosemite-X3.jpg
23+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-DcFC4mH/0/X3/Sleeping%20In-X3.jpg
24+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-zXS6bLv/0/X3/The%20Mothership-X3.jpg
25+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-RT8zP8V/0/X3/The%20Secret%20Lair%20of%20Jules%20Verne-X3.jpg
26+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-xRDBbM4/0/X3/tekapo-new-zealand-trey-ratcliff-2-X3.jpg
27+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-bsMJnLk/0/X3/thepark-X3.jpg
28+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-CtdM3LS/0/X3/hearst-X3.jpg
29+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-8mFWsjn/1/X3/953669278_349a6a9897_o-X3.jpg
30+
http://stuckincustoms.smugmug.com/Portfolio-The-Best/your-favorites/i-mdtc48x/0/X3/trey-ratcliff-paris-opera-X3.jpg

0 commit comments

Comments
 (0)