Skip to content

Commit c9ad106

Browse files
committed
almost complete, added nice animations, fileuploading, create folder, etc
1 parent a64d8b7 commit c9ad106

10 files changed

Lines changed: 547 additions & 48 deletions

File tree

src/RedisStackOverflow/RedisStackOverflow/default.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ H4 EM
422422
{
423423
display: block;
424424
float: right;
425-
margin: 0 20px 0 0;
425+
margin: 7px 20px 0 0;
426426
}
427427
#trivia
428428
{

src/RestFiles/RestFiles.ServiceInterface/FilesService.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,18 @@ private FileInfo GetAndValidateExistingPath(Files request)
138138
return targetFile;
139139
}
140140

141-
private FileResult GetFileResult(FileSystemInfo fileInfo)
141+
private FileResult GetFileResult(FileInfo fileInfo)
142142
{
143143
var isTextFile = this.Config.TextFileExtensions.Contains(fileInfo.Extension);
144144

145145
return new FileResult
146146
{
147+
Name = fileInfo.Name,
148+
Extension = fileInfo.Extension,
149+
FileSizeBytes = fileInfo.Length,
150+
IsTextFile = isTextFile,
147151
Contents = isTextFile ? File.ReadAllText(fileInfo.FullName) : null,
148-
CreatedDate = fileInfo.CreationTime,
149-
LastModifiedDate = fileInfo.LastWriteTime,
152+
ModifiedDate = fileInfo.LastWriteTimeUtc,
150153
};
151154
}
152155

src/RestFiles/RestFiles.ServiceInterface/ResetFilesService.cs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class ResetFilesService
1010
{
1111
public AppConfig Config { get; set; }
1212

13-
public override object OnGet(ResetFiles request)
13+
public override object OnPost(ResetFiles request)
1414
{
1515
var rootDir = Config.RootDirectory;
1616

@@ -23,30 +23,29 @@ public override object OnGet(ResetFiles request)
2323

2424
foreach (var filePath in Directory.GetFiles("~/".MapHostAbsolutePath()))
2525
{
26-
if (filePath.EndsWith(".cs") || filePath.EndsWith(".htm"))
27-
{
28-
File.Copy(filePath, Path.Combine(rootDir, Path.GetFileName(filePath)));
29-
}
26+
if (!filePath.EndsWith(".cs") && !filePath.EndsWith(".htm")) continue;
27+
28+
var fileName = Path.GetFileName(filePath);
29+
if (filePath.EndsWith(".cs")) fileName += ".txt";
30+
File.Copy(filePath, Path.Combine(rootDir, fileName));
3031
}
3132

3233
var servicesDir = Path.Combine(rootDir, "services");
3334
Directory.CreateDirectory(servicesDir);
3435
foreach (var filePath in Directory.GetFiles("~/../RestFiles.ServiceInterface/".MapHostAbsolutePath()))
3536
{
36-
if (filePath.EndsWith("Service.cs"))
37-
{
38-
File.Copy(filePath, Path.Combine(servicesDir, Path.GetFileName(filePath)));
39-
}
37+
if (!filePath.EndsWith("Service.cs")) continue;
38+
39+
File.Copy(filePath, Path.Combine(servicesDir, Path.GetFileName(filePath) + ".txt"));
4040
}
4141

4242
var testsDir = Path.Combine(rootDir, "tests");
4343
Directory.CreateDirectory(testsDir);
4444
foreach (var filePath in Directory.GetFiles("~/../RestFiles.Tests/".MapHostAbsolutePath()))
4545
{
46-
if (filePath.EndsWith(".cs"))
47-
{
48-
File.Copy(filePath, Path.Combine(testsDir, Path.GetFileName(filePath)));
49-
}
46+
if (!filePath.EndsWith(".cs")) continue;
47+
48+
File.Copy(filePath, Path.Combine(testsDir, Path.GetFileName(filePath) + ".txt"));
5049
}
5150

5251
var dtosDir = Path.Combine(rootDir, "dtos");
@@ -55,13 +54,13 @@ public override object OnGet(ResetFiles request)
5554
Directory.CreateDirectory(opsDtoPath);
5655
foreach (var filePath in Directory.GetFiles("~/../RestFiles.ServiceModel/Operations/".MapHostAbsolutePath()))
5756
{
58-
File.Copy(filePath, Path.Combine(opsDtoPath, Path.GetFileName(filePath)));
57+
File.Copy(filePath, Path.Combine(opsDtoPath, Path.GetFileName(filePath) + ".txt"));
5958
}
6059
var typesDtoPath = Path.Combine(dtosDir, "Types");
6160
Directory.CreateDirectory(typesDtoPath);
6261
foreach (var filePath in Directory.GetFiles("~/../RestFiles.ServiceModel/Types/".MapHostAbsolutePath()))
6362
{
64-
File.Copy(filePath, Path.Combine(typesDtoPath, Path.GetFileName(filePath)));
63+
File.Copy(filePath, Path.Combine(typesDtoPath, Path.GetFileName(filePath) + ".txt"));
6564
}
6665

6766
return new ResetFilesResponse();

src/RestFiles/RestFiles.ServiceModel/Types/FileResult.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,21 @@ namespace RestFiles.ServiceModel.Types
77
public class FileResult
88
{
99
[DataMember]
10-
public string Contents { get; set; }
10+
public string Name { get; set; }
11+
12+
[DataMember]
13+
public string Extension { get; set; }
14+
15+
[DataMember]
16+
public long FileSizeBytes { get; set; }
17+
18+
[DataMember]
19+
public DateTime ModifiedDate { get; set; }
1120

1221
[DataMember]
13-
public DateTime CreatedDate { get; set; }
22+
public bool IsTextFile { get; set; }
1423

1524
[DataMember]
16-
public DateTime LastModifiedDate { get; set; }
25+
public string Contents { get; set; }
1726
}
1827
}

src/RestFiles/RestFiles/RestFiles.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,18 @@
8282
<Content Include="img\bg_gradient.gif" />
8383
<Content Include="img\btn-github.png" />
8484
<Content Include="img\dir.png" />
85+
<Content Include="img\file_head.gif" />
8586
<Content Include="img\logo-24x24.png" />
8687
<Content Include="img\logo-32x32.png" />
8788
<Content Include="img\logo-txt-small.png" />
8889
<Content Include="img\public.png" />
8990
<Content Include="img\row_bg.png" />
9091
<Content Include="img\txt.png" />
92+
<Content Include="js\ajaxfileupload.js" />
9193
<Content Include="Web.config" />
9294
</ItemGroup>
9395
<ItemGroup>
9496
<Folder Include="App_Data\" />
95-
<Folder Include="js\" />
9697
</ItemGroup>
9798
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
9899
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />

src/RestFiles/RestFiles/Web.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
<appSettings>
2020
<add key="RootDirectory" value="~/App_Data/files/"/>
2121
<add key="ExcludeDirectories" value=".svn,bin,Properties"/>
22-
<add key="TextFileExtensions" value=".txt,.sln,.proj,.cs,.config,.asax"/>
22+
<add key="TextFileExtensions" value=".txt,.sln,.proj,.cs,.config,.asax,.css,.htm,.html,.xml,.js"/>
2323
</appSettings>
2424

2525
<connectionStrings/>
2626
<system.web>
2727
<!--
2828
Set compilation debug="true" to insert debugging
29-
symbols into the compiled page. Because this
29+
symbols into the compiled page. Because this
3030
affects performance, set this value to true only
3131
during development.
3232
-->

0 commit comments

Comments
 (0)