Revisão | 100 (tree) |
---|---|
Hora | 2021-09-30 15:17:02 |
Autor | ![]() |
* catalpa 0.8.7
ブログ形式での固定ページ対応のバグを修正しました。
@@ -118,11 +118,9 @@ | ||
118 | 118 | factory = createFactory(inputPath, outputPath); |
119 | 119 | if(factory.hasDraft) { |
120 | 120 | //draft template |
121 | - context.getSystemDataModel().put("template", "draft.ftl"); | |
122 | 121 | options.put("_DRAFT", true); |
123 | 122 | } else { |
124 | 123 | //default template |
125 | - context.getSystemDataModel().put("template", "post.ftl"); | |
126 | 124 | options.remove("_DRAFT"); |
127 | 125 | } |
128 | 126 | options.remove("_DEFAULT_URL"); |
@@ -180,16 +178,26 @@ | ||
180 | 178 | */ |
181 | 179 | @Override |
182 | 180 | public void execute(Context context) throws IOException, TemplateException { |
183 | - // 記事以外のファイルは処理せずに復帰します。(記事以外のファイルとは画像ファイルや記事ではない .md などです。) | |
184 | 181 | if(!factory.containsPost(context.getInputPath())) { |
185 | 182 | if(Post.isApplicable(context.getInputPath())) { |
186 | - // 記事として受理可能な拡張子のファイル(つまり記事ではない .md ということになります。)の場合は、 | |
187 | - // 既定のテンプレートを post.ftl ではなく default.ftl に変更します。 | |
188 | - context.getSystemDataModel().put("template", "default.ftl"); | |
183 | + if(factory.getNonPosts().contains(context.getInputPath())) { | |
184 | + // 記事以外のファイルには default.ftl を適用します。 | |
185 | + context.getSystemDataModel().put("template", "default.ftl"); | |
186 | + } else { | |
187 | + // 記事に含まれていないファイルは出力しません。 | |
188 | + // これには draft 記事を書いているときのその他の通常記事が該当します。 | |
189 | + context.setOutputPath(null); | |
190 | + } | |
189 | 191 | } |
190 | 192 | return; |
191 | 193 | } |
192 | 194 | |
195 | + if(factory.hasDraft) { | |
196 | + context.getSystemDataModel().put("template", "draft.ftl"); | |
197 | + } else { | |
198 | + context.getSystemDataModel().put("template", "post.ftl"); | |
199 | + } | |
200 | + | |
193 | 201 | Post post = factory.getPostBy(context.getInputPath()); |
194 | 202 | |
195 | 203 | blogDataModel.put("post", post); |
@@ -424,6 +432,7 @@ | ||
424 | 432 | private Path inputPath; |
425 | 433 | private Map<String, Category> categories = new HashMap<String, Category>(); |
426 | 434 | private Map<Path, Post> posts = new HashMap<Path, Post>(); |
435 | + private Set<Path> nonPosts = new LinkedHashSet<>(); | |
427 | 436 | private boolean hasDraft = false; |
428 | 437 | |
429 | 438 | public Factory(Path inputPath) { |
@@ -437,6 +446,10 @@ | ||
437 | 446 | public List<Post> getPosts() { |
438 | 447 | return new ArrayList<Post>(posts.values()); |
439 | 448 | } |
449 | + | |
450 | + public Set<Path> getNonPosts() { | |
451 | + return nonPosts; | |
452 | + } | |
440 | 453 | |
441 | 454 | public boolean containsCategory(String text) { |
442 | 455 | String name = text; |
@@ -537,7 +550,11 @@ | ||
537 | 550 | blocks.put("content", blocks.remove(null)); |
538 | 551 | } |
539 | 552 | String content = blocks.get("content"); |
540 | - | |
553 | + | |
554 | + // 日付(date)の指定されていないファイルは記事以外のファイルとして分類します。 | |
555 | + if(map.get("date") == null) { | |
556 | + nonPosts.add(path); | |
557 | + } | |
541 | 558 | // |
542 | 559 | if(map.get("date") != null && map.get("title") != null && content != null) { |
543 | 560 | LocalDate date; |