public String buildPermalink ( final Post post ) { final String authorSlug = post . author != null ? Strings . nullToEmpty ( post . author . slug ) : "" ; final List < TaxonomyTerm > categories = post . categories ( ) ; final Term categoryTerm = categories . size ( ) > 0 ? categories . get ( 0 ) . term : defaultCategory ; final String category = Strings . nullToEmpty ( categoryTerm . slug ) ; final String post_id = Long . toString ( post . id ) ; final DateTime publishTime = new DateTime ( post . publishTimestamp ) ; final String year = Integer . toString ( publishTime . getYear ( ) ) ; final String monthnum = String . format ( "%02d" , publishTime . getMonthOfYear ( ) ) ; final String day = String . format ( "%02d" , publishTime . getDayOfMonth ( ) ) ; final String hour = String . format ( "%02d" , publishTime . getHourOfDay ( ) ) ; final String minute = String . format ( "%02d" , publishTime . getMinuteOfHour ( ) ) ; final String second = String . format ( "%02d" , publishTime . getSecondOfMinute ( ) ) ; final String path = permalinkStructure . replace ( "%year%" , year ) . replace ( "%monthnum%" , monthnum ) . replace ( "%day%" , day ) . replace ( "%hour%" , hour ) . replace ( "%minute%" , minute ) . replace ( "%second%" , second ) . replace ( "%post_id%" , post_id ) . replace ( "%postname%" , Strings . nullToEmpty ( post . slug ) ) . replace ( "%category%" , category ) . replace ( "%author%" , authorSlug ) ; return baseURL + path ; }
Builds the permalink for a post from this site .