59 |
60 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/src/Default.aspx.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Net;
6 | using System.ServiceModel.Syndication;
7 | using System.Text.RegularExpressions;
8 | using System.Threading.Tasks;
9 | using System.Web.Hosting;
10 | using System.Web.UI;
11 | using System.Xml;
12 | using config = System.Configuration.ConfigurationManager;
13 |
14 | public partial class _Default : Page
15 | {
16 | private static string _masterFile = HostingEnvironment.MapPath("~/master.xml");
17 | private static string _feedFile = HostingEnvironment.MapPath("~/feed.xml");
18 | protected int _page;
19 |
20 | protected void Page_Load(object sender, EventArgs e)
21 | {
22 | _page = int.Parse(Request.QueryString["page"] ?? "1");
23 | Task task = Task.Run(() => DownloadFeeds());
24 |
25 | if (!File.Exists(_masterFile))
26 | task.Wait();
27 | }
28 |
29 | private async Task DownloadFeeds()
30 | {
31 | var rss = new SyndicationFeed(config.AppSettings["title"], config.AppSettings["description"], null);
32 |
33 | foreach (var key in config.AppSettings.AllKeys.Where(key => key.StartsWith("feed:")))
34 | {
35 | SyndicationFeed feed = await DownloadFeed(config.AppSettings[key]);
36 | rss.Items = rss.Items.Union(feed.Items).GroupBy(i => i.Title.Text).Select(i => i.First()).OrderByDescending(i => i.PublishDate.Date);
37 | }
38 |
39 | using (XmlWriter writer = XmlWriter.Create(_masterFile))
40 | rss.SaveAsRss20(writer);
41 |
42 | using (XmlWriter writer = XmlWriter.Create(_feedFile))
43 | {
44 | rss.Items = rss.Items.Take(10);
45 | rss.SaveAsRss20(writer);
46 | }
47 | }
48 |
49 | private async Task DownloadFeed(string url)
50 | {
51 | try
52 | {
53 | using (WebClient client = new WebClient())
54 | {
55 | var stream = await client.OpenReadTaskAsync(url);
56 | return SyndicationFeed.Load(XmlReader.Create(stream));
57 | }
58 | }
59 | catch (Exception ex)
60 | {
61 | Trace.Warn("Feed Collector", "Couldn't download: " + url, ex);
62 | return new SyndicationFeed();
63 | }
64 | }
65 |
66 | public IEnumerable GetData()
67 | {
68 | using (XmlReader reader = XmlReader.Create(_masterFile))
69 | {
70 | var count = int.Parse(config.AppSettings["postsPerPage"]);
71 | var items = SyndicationFeed.Load(reader).Items.Skip((_page - 1) * count).Take(count);
72 | return items.Select(item => { CleanItem(item); return item; });
73 | }
74 | }
75 |
76 | private static void CleanItem(SyndicationItem item)
77 | {
78 | string summary = item.Summary != null ? item.Summary.Text : ((TextSyndicationContent)item.Content).Text;
79 | summary = Regex.Replace(summary, "<[^>]*>", ""); // Strips out HTML
80 | item.Summary = new TextSyndicationContent(string.Join("", summary.Take(300)) + "...");
81 | }
82 | }
--------------------------------------------------------------------------------
/src/themes/default/site.css:
--------------------------------------------------------------------------------
1 | body {
2 | font: 16px/1.3em "Segoe UI","Segoe WP Light","Segoe WP",Tahoma,Arial,sans-serif;
3 | margin: 0;
4 | color: #505050;
5 | background: #fff;
6 | }
7 |
8 | h1, h2{
9 | font-family: "Segoe UI Light","Segoe WP Light","Segoe UI","Segoe WP",Tahoma,Arial,sans-serif;
10 | font-weight: 400;
11 | margin: 25px 0;
12 | }
13 |
14 | h2 {
15 | font-size: 1.3em;
16 | margin: 0;
17 | }
18 |
19 | h2 a {
20 | color: inherit;
21 | text-decoration: none;
22 | }
23 |
24 | header {
25 | text-align: left;
26 | height: 60px;
27 | line-height: 60px;
28 | background: #68217a;
29 | }
30 |
31 | header h1{
32 | font-size: 22px;
33 | font-weight: bold;
34 | max-width: 960px;
35 | margin: 0 auto;
36 | padding: 0 1em;
37 | }
38 |
39 | header a {
40 | color: #fff;
41 | text-decoration: none;
42 | }
43 |
44 | div[role=main] {
45 | max-width: 960px;
46 | margin: 0 auto;
47 | padding: 1em;
48 | }
49 |
50 | span[itemprop=description] {
51 | font-size: 1.2em;
52 | }
53 |
54 | .feed {
55 | text-indent: -5000px;
56 | background: url('rss.png');
57 | height: 32px;
58 | width: 32px;
59 | float: right;
60 | margin-bottom: 2em;
61 | }
62 |
63 | article {
64 | clear: both;
65 | position: relative;
66 | padding-left: 75px;
67 | margin-bottom: 2.5em;
68 | }
69 |
70 | article p {
71 | margin: .5em 0;
72 | }
73 |
74 | time {
75 | position: absolute;
76 | left: 0;
77 | top: 5px;
78 | text-align: center;
79 | width: 50px;
80 | }
81 |
82 | time span {
83 | padding: 2px 0;
84 | display: block;
85 | }
86 |
87 | time .month {
88 | border-radius: 2px 2px 0 0;
89 | background-color: #752767;
90 | color: #fff;
91 | }
92 |
93 | time .day{
94 | font-weight: bold;
95 | }
96 |
97 | #paging {
98 | text-align: center;
99 | margin-top: 1em;
100 | }
101 |
102 | #paging a {
103 | color: #000;
104 | padding: 0 .5em;
105 | }
106 |
107 | footer p {
108 | text-align: center;
109 | padding: 1.5em 0;
110 | margin: 3em 0 0 0;
111 | background: #333;
112 | color: #fff;
113 | }
114 |
115 | footer p a {
116 | color: #fff;
117 | }
118 |
119 | @media screen and (orientation: landscape) {
120 | @-ms-viewport {
121 | width: device-width;
122 | }
123 | }
124 |
125 | @media screen and (orientation: portrait) {
126 | @-ms-viewport {
127 | width: 800px;
128 | }
129 |
130 | body {
131 | -ms-text-size-adjust: 160%;
132 | }
133 | }
134 |
135 | @media only screen and (max-width: 600px) {
136 |
137 | article {
138 | padding-left: 0;
139 | }
140 |
141 | time {
142 | border: none;
143 | width: auto;
144 | position: relative;
145 | }
146 |
147 | time:after {
148 | content: attr(datetime);
149 | }
150 |
151 | time span {
152 | display: none;
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/src/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | feed.xml
2 | master.xml
3 |
4 | ## Ignore Visual Studio temporary files, build results, and
5 | ## files generated by popular Visual Studio add-ons.
6 |
7 | # User-specific files
8 | *.suo
9 | *.user
10 | *.sln.docstates
11 |
12 | # Build results
13 | [Dd]ebug/
14 | [Dd]ebugPublic/
15 | [Rr]elease/
16 | [Rr]eleases/
17 | x64/
18 | x86/
19 | build/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 |
24 | # Roslyn cache directories
25 | *.ide/
26 |
27 | # MSTest test Results
28 | [Tt]est[Rr]esult*/
29 | [Bb]uild[Ll]og.*
30 |
31 | #NUNIT
32 | *.VisualState.xml
33 | TestResult.xml
34 |
35 | # Build Results of an ATL Project
36 | [Dd]ebugPS/
37 | [Rr]eleasePS/
38 | dlldata.c
39 |
40 | *_i.c
41 | *_p.c
42 | *_i.h
43 | *.ilk
44 | *.meta
45 | *.obj
46 | *.pch
47 | *.pdb
48 | *.pgc
49 | *.pgd
50 | *.rsp
51 | *.sbr
52 | *.tlb
53 | *.tli
54 | *.tlh
55 | *.tmp
56 | *.tmp_proj
57 | *.log
58 | *.vspscc
59 | *.vssscc
60 | .builds
61 | *.pidb
62 | *.svclog
63 | *.scc
64 |
65 | # Chutzpah Test files
66 | _Chutzpah*
67 |
68 | # Visual C++ cache files
69 | ipch/
70 | *.aps
71 | *.ncb
72 | *.opensdf
73 | *.sdf
74 | *.cachefile
75 |
76 | # Visual Studio profiler
77 | *.psess
78 | *.vsp
79 | *.vspx
80 |
81 | # TFS 2012 Local Workspace
82 | $tf/
83 |
84 | # Guidance Automation Toolkit
85 | *.gpState
86 |
87 | # ReSharper is a .NET coding add-in
88 | _ReSharper*/
89 | *.[Rr]e[Ss]harper
90 | *.DotSettings.user
91 |
92 | # JustCode is a .NET coding addin-in
93 | .JustCode
94 |
95 | # TeamCity is a build add-in
96 | _TeamCity*
97 |
98 | # DotCover is a Code Coverage Tool
99 | *.dotCover
100 |
101 | # NCrunch
102 | _NCrunch_*
103 | .*crunch*.local.xml
104 |
105 | # MightyMoose
106 | *.mm.*
107 | AutoTest.Net/
108 |
109 | # Web workbench (sass)
110 | .sass-cache/
111 |
112 | # Installshield output folder
113 | [Ee]xpress/
114 |
115 | # DocProject is a documentation generator add-in
116 | DocProject/buildhelp/
117 | DocProject/Help/*.HxT
118 | DocProject/Help/*.HxC
119 | DocProject/Help/*.hhc
120 | DocProject/Help/*.hhk
121 | DocProject/Help/*.hhp
122 | DocProject/Help/Html2
123 | DocProject/Help/html
124 |
125 | # Click-Once directory
126 | publish/
127 |
128 | # Publish Web Output
129 | *.[Pp]ublish.xml
130 | *.azurePubxml
131 | # TODO: Comment the next line if you want to checkin your web deploy settings
132 | # but database connection strings (with potential passwords) will be unencrypted
133 | *.pubxml
134 | *.publishproj
135 |
136 | # NuGet Packages
137 | *.nupkg
138 | # The packages folder can be ignored because of Package Restore
139 | **/packages/*
140 | # except build/, which is used as an MSBuild target.
141 | !**/packages/build/
142 | # If using the old MSBuild-Integrated Package Restore, uncomment this:
143 | #!**/packages/repositories.config
144 |
145 | # Windows Azure Build Output
146 | csx/
147 | *.build.csdef
148 |
149 | # Windows Store app package directory
150 | AppPackages/
151 |
152 | # Others
153 | sql/
154 | *.Cache
155 | ClientBin/
156 | [Ss]tyle[Cc]op.*
157 | ~$*
158 | *~
159 | *.dbmdl
160 | *.dbproj.schemaview
161 | *.pfx
162 | *.publishsettings
163 | node_modules/
164 |
165 | # RIA/Silverlight projects
166 | Generated_Code/
167 |
168 | # Backup & report files from converting an old project file
169 | # to a newer Visual Studio version. Backup files are not needed,
170 | # because we have git ;-)
171 | _UpgradeReport_Files/
172 | Backup*/
173 | UpgradeLog*.XML
174 | UpgradeLog*.htm
175 |
176 | # SQL Server files
177 | *.mdf
178 | *.ldf
179 |
180 | # Business Intelligence projects
181 | *.rdl.data
182 | *.bim.layout
183 | *.bim_*.settings
184 |
185 | # Microsoft Fakes
186 | FakesAssemblies/
187 |
188 | # =========================
189 | # Operating System Files
190 | # =========================
191 |
192 | # OSX
193 | # =========================
194 |
195 | .DS_Store
196 | .AppleDouble
197 | .LSOverride
198 |
199 | # Icon must end with two \r
200 | Icon
201 |
202 | # Thumbnails
203 | ._*
204 |
205 | # Files that might appear on external disk
206 | .Spotlight-V100
207 | .Trashes
208 |
209 | # Directories potentially created on remote AFP share
210 | .AppleDB
211 | .AppleDesktop
212 | Network Trash Folder
213 | Temporary Items
214 | .apdisk
215 |
216 | # Windows
217 | # =========================
218 |
219 | # Windows image file caches
220 | Thumbs.db
221 | ehthumbs.db
222 |
223 | # Folder config file
224 | Desktop.ini
225 |
226 | # Recycle Bin used on file shares
227 | $RECYCLE.BIN/
228 |
229 | # Windows Installer files
230 | *.cab
231 | *.msi
232 | *.msm
233 | *.msp
234 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2021 Mads Kristensen
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------