Thiago Cafe - Programming is fun !
Created by thiago on 2016-07-02 14:25:22

New features and a bit about D

I've written a considerable number of features since I listed the So far good progress! I already wrote the following features:

Features

Missing:

  1. Author in post
  2. Comments
  3. Post composer - I'm still writing offline
  4. Caching system

Probably, just after comments and author, I'm going to implement caching system.

Some noticiable things:

[ID]: # (post_id)
[DATE]: # (post_date)
[AUTHOR]: # (author name)

A bit about D

I used for the first time template parameters today.

How to get ordered list of files ?

First, let's check the sort algorithm and dirEntries

//First sortedRange
SortedRange!(Range, less) sort(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable, Range)(Range r)
//Now dirEntries
DirIterator dirEntries(string path, SpanMode mode, bool followSymlink = true); 

Although it looks simple, dirEntries returns DirIterator and sort requires a range. Luckly the solution is pretty simple

auto dir_list = array(base_dir.dirEntries(SpanMode.shallow));

Now, we have a range based on DirIterator. The only thing we need is to invert less operator

sort!("a.name > b.name")(dir_list);

Done. We have our list sorted from Z to A.

Some other option we have:

sort!("a.timeLastModified > b.timeLastModified")(dir_list);
sort!("a.size > b.size")(dir_list);
sort!("a.timeCreated > b.timeCreated")(dir_list);

References:

...