mirror of
https://github.com/MinimalBible/MinimalBible.github.io
synced 2024-12-21 06:08:19 -05:00
Add new posts
This commit is contained in:
parent
f2ed37b58b
commit
445b430c3c
74
Gemfile.lock
74
Gemfile.lock
@ -1,74 +0,0 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
activesupport (4.0.2)
|
||||
i18n (~> 0.6, >= 0.6.4)
|
||||
minitest (~> 4.2)
|
||||
multi_json (~> 1.3)
|
||||
thread_safe (~> 0.1)
|
||||
tzinfo (~> 0.3.37)
|
||||
atomic (1.1.14)
|
||||
blankslate (2.1.2.4)
|
||||
classifier (1.3.4)
|
||||
fast-stemmer (>= 1.0.0)
|
||||
coderay (1.1.0)
|
||||
colorator (0.1)
|
||||
commander (4.1.6)
|
||||
highline (~> 1.6.11)
|
||||
fast-stemmer (1.0.2)
|
||||
ffi (1.9.3-x86-mingw32)
|
||||
highline (1.6.20)
|
||||
i18n (0.6.9)
|
||||
jekyll (1.4.2)
|
||||
classifier (~> 1.3)
|
||||
colorator (~> 0.1)
|
||||
commander (~> 4.1.3)
|
||||
liquid (~> 2.5.5)
|
||||
listen (~> 1.3)
|
||||
maruku (~> 0.7.0)
|
||||
pygments.rb (~> 0.5.0)
|
||||
redcarpet (~> 2.3.0)
|
||||
safe_yaml (~> 0.9.7)
|
||||
toml (~> 0.1.0)
|
||||
kramdown (1.3.1)
|
||||
liquid (2.5.5)
|
||||
listen (1.3.1)
|
||||
rb-fsevent (>= 0.9.3)
|
||||
rb-inotify (>= 0.9)
|
||||
rb-kqueue (>= 0.2)
|
||||
maruku (0.7.1)
|
||||
minitest (4.7.5)
|
||||
multi_json (1.8.4)
|
||||
parslet (1.5.0)
|
||||
blankslate (~> 2.0)
|
||||
posix-spawn (0.3.8)
|
||||
posix-spawn (~> 0.3.6)
|
||||
yajl-ruby (~> 1.1.0)
|
||||
rake (10.1.1)
|
||||
rb-fsevent (0.9.4)
|
||||
rb-inotify (0.9.3)
|
||||
ffi (>= 0.5.0)
|
||||
rb-kqueue (0.2.0)
|
||||
ffi (>= 0.5.0)
|
||||
redcarpet (2.3.0)
|
||||
safe_yaml (0.9.7)
|
||||
stringex (2.2.0)
|
||||
thor (0.18.1)
|
||||
thread_safe (0.1.3)
|
||||
atomic
|
||||
toml (0.1.0)
|
||||
parslet (~> 1.5.0)
|
||||
tzinfo (0.3.38)
|
||||
yajl-ruby (1.1.0-x86-mingw32)
|
||||
|
||||
PLATFORMS
|
||||
x86-mingw32
|
||||
|
||||
DEPENDENCIES
|
||||
activesupport
|
||||
coderay
|
||||
jekyll
|
||||
kramdown
|
||||
rake
|
||||
stringex
|
||||
thor
|
@ -1,103 +0,0 @@
|
||||
---
|
||||
layout: post
|
||||
title: Sample Post
|
||||
description: "Just about everything you'll need to style in the theme: headings, paragraphs, blockquotes, tables, code blocks, and more."
|
||||
modified: 2013-05-31
|
||||
tags: [sample post]
|
||||
image:
|
||||
feature: abstract-3.jpg
|
||||
credit: dargadgetz
|
||||
creditlink: http://www.dargadgetz.com/ios-7-abstract-wallpaper-pack-for-iphone-5-and-ipod-touch-retina/
|
||||
comments: true
|
||||
share: true
|
||||
---
|
||||
|
||||
Below is just about everything you'll need to style in the theme. Check the source code to see the many embedded elements within paragraphs.
|
||||
|
||||
# Heading 1
|
||||
|
||||
## Heading 2
|
||||
|
||||
### Heading 3
|
||||
|
||||
#### Heading 4
|
||||
|
||||
##### Heading 5
|
||||
|
||||
###### Heading 6
|
||||
|
||||
### Body text
|
||||
|
||||
Lorem ipsum dolor sit amet, test link adipiscing elit. **This is strong**. Nullam dignissim convallis est. Quisque aliquam.
|
||||
|
||||
![Smithsonian Image]({{ site.url }}/images/3953273590_704e3899d5_m.jpg)
|
||||
{: .pull-right}
|
||||
|
||||
*This is emphasized*. Donec faucibus. Nunc iaculis suscipit dui. 53 = 125. Water is H<sub>2</sub>O. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. The New York Times <cite>(That’s a citation)</cite>. <u>Underline</u>. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla nonummy. Mauris a ante. Suspendisse quam sem, consequat at, commodo vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus.
|
||||
|
||||
HTML and <abbr title="cascading stylesheets">CSS<abbr> are our tools. Mauris a ante. Suspendisse quam sem, consequat at, commodo vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus. Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus.
|
||||
|
||||
### Blockquotes
|
||||
|
||||
> Lorem ipsum dolor sit amet, test link adipiscing elit. Nullam dignissim convallis est. Quisque aliquam.
|
||||
|
||||
## List Types
|
||||
|
||||
### Ordered Lists
|
||||
|
||||
1. Item one
|
||||
1. sub item one
|
||||
2. sub item two
|
||||
3. sub item three
|
||||
2. Item two
|
||||
|
||||
### Unordered Lists
|
||||
|
||||
* Item one
|
||||
* Item two
|
||||
* Item three
|
||||
|
||||
## Tables
|
||||
|
||||
| Header1 | Header2 | Header3 |
|
||||
|:--------|:-------:|--------:|
|
||||
| cell1 | cell2 | cell3 |
|
||||
| cell4 | cell5 | cell6 |
|
||||
|----
|
||||
| cell1 | cell2 | cell3 |
|
||||
| cell4 | cell5 | cell6 |
|
||||
|=====
|
||||
| Foot1 | Foot2 | Foot3
|
||||
{: rules="groups"}
|
||||
|
||||
## Code Snippets
|
||||
|
||||
Syntax highlighting via Pygments
|
||||
|
||||
{% highlight css %}
|
||||
#container {
|
||||
float: left;
|
||||
margin: 0 -240px 0 0;
|
||||
width: 100%;
|
||||
}
|
||||
{% endhighlight %}
|
||||
|
||||
Non Pygments code example
|
||||
|
||||
<div id="awesome">
|
||||
<p>This is great isn't it?</p>
|
||||
</div>
|
||||
|
||||
## Buttons
|
||||
|
||||
Make any link standout more when applying the `.btn` class.
|
||||
|
||||
{% highlight html %}
|
||||
<a href="#" class="btn btn-success">Success Button</a>
|
||||
{% endhighlight %}
|
||||
|
||||
<div markdown="0"><a href="#" class="btn">Primary Button</a></div>
|
||||
<div markdown="0"><a href="#" class="btn btn-success">Success Button</a></div>
|
||||
<div markdown="0"><a href="#" class="btn btn-warning">Warning Button</a></div>
|
||||
<div markdown="0"><a href="#" class="btn btn-danger">Danger Button</a></div>
|
||||
<div markdown="0"><a href="#" class="btn btn-info">Info Button</a></div>
|
@ -1,49 +0,0 @@
|
||||
---
|
||||
layout: post
|
||||
title: "Testing Readability with a Bunch of Text"
|
||||
description: "A ton of text to test readability."
|
||||
tags: [sample post, readability, test, intro]
|
||||
image:
|
||||
feature: abstract-6.jpg
|
||||
credit: dargadgetz
|
||||
creditlink: http://www.dargadgetz.com/ios-7-abstract-wallpaper-pack-for-iphone-5-and-ipod-touch-retina/
|
||||
comments: true
|
||||
share: true
|
||||
---
|
||||
|
||||
Portland in shoreditch Vice, labore typewriter pariatur hoodie fap sartorial Austin. Pinterest literally occupy Schlitz forage. Odio ad blue bottle vinyl, 90's narwhal commodo bitters pour-over nostrud. Ugh est hashtag in, fingerstache adipisicing laboris esse Pinterest shabby chic Portland. Shoreditch bicycle rights anim, flexitarian laboris put a bird on it vinyl cupidatat narwhal. Hashtag artisan skateboard, flannel Bushwick nesciunt salvia aute fixie do plaid post-ironic dolor McSweeney's. Cliche pour-over chambray nulla four loko skateboard sapiente hashtag.
|
||||
|
||||
Vero laborum commodo occupy. Semiotics voluptate mumblecore pug. Cosby sweater ullamco quinoa ennui assumenda, sapiente occupy delectus lo-fi. Ea fashion axe Marfa cillum aliquip. Retro Bushwick keytar cliche. Before they sold out sustainable gastropub Marfa readymade, ethical Williamsburg skateboard brunch qui consectetur gentrify semiotics. Mustache cillum irony, fingerstache magna pour-over keffiyeh tousled selfies.
|
||||
|
||||
## Cupidatat 90's lo-fi authentic try-hard
|
||||
|
||||
In pug Portland incididunt mlkshk put a bird on it vinyl quinoa. Terry Richardson shabby chic +1, scenester Tonx excepteur tempor fugiat voluptate fingerstache aliquip nisi next level. Farm-to-table hashtag Truffaut, Odd Future ex meggings gentrify single-origin coffee try-hard 90's.
|
||||
|
||||
* Sartorial hoodie
|
||||
* Labore viral forage
|
||||
* Tote bag selvage
|
||||
* DIY exercitation et id ugh tumblr church-key
|
||||
|
||||
Incididunt umami sriracha, ethical fugiat VHS ex assumenda yr irure direct trade. Marfa Truffaut bicycle rights, kitsch placeat Etsy kogi asymmetrical. Beard locavore flexitarian, kitsch photo booth hoodie plaid ethical readymade leggings yr.
|
||||
|
||||
Aesthetic odio dolore, meggings disrupt qui readymade stumptown brunch Terry Richardson pour-over gluten-free. Banksy american apparel in selfies, biodiesel flexitarian organic meh wolf quinoa gentrify banjo kogi. Readymade tofu ex, scenester dolor umami fingerstache occaecat fashion axe Carles jean shorts minim. Keffiyeh fashion axe nisi Godard mlkshk dolore. Lomo you probably haven't heard of them eu non, Odd Future Truffaut pug keytar meggings McSweeney's Pinterest cred. Etsy literally aute esse, eu bicycle rights qui meggings fanny pack. Gentrify leggings pug flannel duis.
|
||||
|
||||
## Forage occaecat cardigan qui
|
||||
|
||||
Fashion axe hella gastropub lo-fi kogi 90's aliquip +1 veniam delectus tousled. Cred sriracha locavore gastropub kale chips, iPhone mollit sartorial. Anim dolore 8-bit, pork belly dolor photo booth aute flannel small batch. Dolor disrupt ennui, tattooed whatever salvia Banksy sartorial roof party selfies raw denim sint meh pour-over. Ennui eu cardigan sint, gentrify iPhone cornhole.
|
||||
|
||||
> Whatever velit occaecat quis deserunt gastropub, leggings elit tousled roof party 3 wolf moon kogi pug blue bottle ea. Fashion axe shabby chic Austin quinoa pickled laborum bitters next level, disrupt deep v accusamus non fingerstache.
|
||||
|
||||
Tote bag asymmetrical elit sunt. Occaecat authentic Marfa, hella McSweeney's next level irure veniam master cleanse. Sed hoodie letterpress artisan wolf leggings, 3 wolf moon commodo ullamco. Anim occupy ea labore Terry Richardson. Tofu ex master cleanse in whatever pitchfork banh mi, occupy fugiat fanny pack Austin authentic. Magna fugiat 3 wolf moon, labore McSweeney's sustainable vero consectetur. Gluten-free disrupt enim, aesthetic fugiat jean shorts trust fund keffiyeh magna try-hard.
|
||||
|
||||
## Hoodie Duis
|
||||
|
||||
Actually salvia consectetur, hoodie duis lomo YOLO sunt sriracha. Aute pop-up brunch farm-to-table odio, salvia irure occaecat. Sriracha small batch literally skateboard. Echo Park nihil hoodie, aliquip forage artisan laboris. Trust fund reprehenderit nulla locavore. Stumptown raw denim kitsch, keffiyeh nulla twee dreamcatcher fanny pack ullamco 90's pop-up est culpa farm-to-table. Selfies 8-bit do pug odio.
|
||||
|
||||
### Thundercats Ho!
|
||||
|
||||
Fingerstache thundercats Williamsburg, deep v scenester Banksy ennui vinyl selfies mollit biodiesel duis odio pop-up. Banksy 3 wolf moon try-hard, sapiente enim stumptown deep v ad letterpress. Squid beard brunch, exercitation raw denim yr sint direct trade. Raw denim narwhal id, flannel DIY McSweeney's seitan. Letterpress artisan bespoke accusamus, meggings laboris consequat Truffaut qui in seitan. Sustainable cornhole Schlitz, twee Cosby sweater banh mi deep v forage letterpress flannel whatever keffiyeh. Sartorial cred irure, semiotics ethical sed blue bottle nihil letterpress.
|
||||
|
||||
Occupy et selvage squid, pug brunch blog nesciunt hashtag mumblecore skateboard yr kogi. Ugh small batch swag four loko. Fap post-ironic qui tote bag farm-to-table american apparel scenester keffiyeh vero, swag non pour-over gentrify authentic pitchfork. Schlitz scenester lo-fi voluptate, tote bag irony bicycle rights pariatur vero Vice freegan wayfarers exercitation nisi shoreditch. Chambray tofu vero sed. Street art swag literally leggings, Cosby sweater mixtape PBR lomo Banksy non in pitchfork ennui McSweeney's selfies. Odd Future Banksy non authentic.
|
||||
|
||||
Aliquip enim artisan dolor post-ironic. Pug tote bag Marfa, deserunt pour-over Portland wolf eu odio intelligentsia american apparel ugh ea. Sunt viral et, 3 wolf moon gastropub pug id. Id fashion axe est typewriter, mlkshk Portland art party aute brunch. Sint pork belly Cosby sweater, deep v mumblecore kitsch american apparel. Try-hard direct trade tumblr sint skateboard. Adipisicing bitters excepteur biodiesel, pickled gastropub aute veniam.
|
@ -1,66 +0,0 @@
|
||||
---
|
||||
layout: post
|
||||
title: "A Post with Images"
|
||||
description: "Examples and code for displaying images in posts."
|
||||
tags: [sample post, images, test]
|
||||
comments: true
|
||||
share: true
|
||||
---
|
||||
|
||||
Here are some examples of what a post with images might look like. If you want to display two or three images next to each other responsively use `figure` with the appropriate `class`. Each instance of `figure` is auto-numbered and displayed in the caption.
|
||||
|
||||
## Figures (for images or video)
|
||||
|
||||
### One Up
|
||||
|
||||
<figure>
|
||||
<a href="http://farm9.staticflickr.com/8426/7758832526_cc8f681e48_b.jpg"><img src="http://farm9.staticflickr.com/8426/7758832526_cc8f681e48_c.jpg" alt=""></a>
|
||||
<figcaption><a href="http://www.flickr.com/photos/80901381@N04/7758832526/" title="Morning Fog Emerging From Trees by A Guy Taking Pictures, on Flickr">Morning Fog Emerging From Trees by A Guy Taking Pictures, on Flickr</a>.</figcaption>
|
||||
</figure>
|
||||
|
||||
### Two Up
|
||||
|
||||
Apply the `half` class like so to display two images side by side that share the same caption.
|
||||
|
||||
{% highlight html %}
|
||||
<figure class="half">
|
||||
<img src="/images/image-filename-1.jpg" alt="">
|
||||
<img src="/images/image-filename-2.jpg" alt="">
|
||||
<figcaption>Caption describing these two images.</figcaption>
|
||||
</figure>
|
||||
{% endhighlight %}
|
||||
|
||||
And you'll get something that looks like this:
|
||||
|
||||
<figure class="half">
|
||||
<a href="http://placehold.it/1200x600.jpg"><img src="http://placehold.it/600x300.jpg" alt=""></a>
|
||||
<a href="http://placehold.it/1200x600.jpg"><img src="http://placehold.it/600x300.jpg" alt=""></a>
|
||||
<img src="http://placehold.it/600x300.jpg" alt="">
|
||||
<img src="http://placehold.it/600x300.jpg" alt="">
|
||||
<figcaption>Two images.</figcaption>
|
||||
</figure>
|
||||
|
||||
### Three Up
|
||||
|
||||
Apply the `third` class like so to display three images side by side that share the same caption.
|
||||
|
||||
{% highlight html %}
|
||||
<figure class="third">
|
||||
<a href="http://placehold.it/1200x600.jpg"><img src="http://placehold.it/600x300.jpg" alt=""></a>
|
||||
<a href="http://placehold.it/1200x600.jpg"><img src="http://placehold.it/600x300.jpg" alt=""></a>
|
||||
<a href="http://placehold.it/1200x600.jpg"><img src="http://placehold.it/600x300.jpg" alt=""></a>
|
||||
<figcaption>Caption describing these three images.</figcaption>
|
||||
</figure>
|
||||
{% endhighlight %}
|
||||
|
||||
And you'll get something that looks like this:
|
||||
|
||||
<figure class="third">
|
||||
<a href="http://placehold.it/1200x600.jpg"><img src="http://placehold.it/600x300.jpg" alt=""></a>
|
||||
<a href="http://placehold.it/1200x600.jpg"><img src="http://placehold.it/600x300.jpg" alt=""></a>
|
||||
<a href="http://placehold.it/1200x600.jpg"><img src="http://placehold.it/600x300.jpg" alt=""></a>
|
||||
<a href="http://placehold.it/1200x600.jpg"><img src="http://placehold.it/600x300.jpg" alt=""></a>
|
||||
<a href="http://placehold.it/1200x600.jpg"><img src="http://placehold.it/600x300.jpg" alt=""></a>
|
||||
<a href="http://placehold.it/1200x600.jpg"><img src="http://placehold.it/600x300.jpg" alt=""></a>
|
||||
<figcaption>Three images.</figcaption>
|
||||
</figure>
|
@ -1,50 +0,0 @@
|
||||
---
|
||||
layout: post
|
||||
title: "Post with Large Feature Image and Text"
|
||||
description: "Custom written post descriptions are the way to go... if you're not lazy."
|
||||
tags: [sample post, readability]
|
||||
modified: 2013-06-30
|
||||
image:
|
||||
feature: abstract-7.jpg
|
||||
credit: dargadgetz
|
||||
creditlink: http://www.dargadgetz.com/ios-7-abstract-wallpaper-pack-for-iphone-5-and-ipod-touch-retina/
|
||||
comments: true
|
||||
share: true
|
||||
---
|
||||
|
||||
This is a sample post with a large feature image up top and tons of text. Odio ad blue bottle vinyl, 90's narwhal commodo bitters pour-over nostrud. Ugh est hashtag in, fingerstache adipisicing laboris esse Pinterest shabby chic Portland. Shoreditch bicycle rights anim, flexitarian laboris put a bird on it vinyl cupidatat narwhal. Hashtag artisan skateboard, flannel Bushwick nesciunt salvia aute fixie do plaid post-ironic dolor McSweeney's. Cliche pour-over chambray nulla four loko skateboard sapiente hashtag.
|
||||
|
||||
Vero laborum commodo occupy. Semiotics voluptate mumblecore pug. Cosby sweater ullamco quinoa ennui assumenda, sapiente occupy delectus lo-fi. Ea fashion axe Marfa cillum aliquip. Retro Bushwick keytar cliche. Before they sold out sustainable gastropub Marfa readymade, ethical Williamsburg skateboard brunch qui consectetur gentrify semiotics. Mustache cillum irony, fingerstache magna pour-over keffiyeh tousled selfies.
|
||||
|
||||
## Cupidatat 90's lo-fi authentic try-hard
|
||||
|
||||
In pug Portland incididunt mlkshk put a bird on it vinyl quinoa. Terry Richardson shabby chic +1, scenester Tonx excepteur tempor fugiat voluptate fingerstache aliquip nisi next level. Farm-to-table hashtag Truffaut, Odd Future ex meggings gentrify single-origin coffee try-hard 90's.
|
||||
|
||||
* Sartorial hoodie
|
||||
* Labore viral forage
|
||||
* Tote bag selvage
|
||||
* DIY exercitation et id ugh tumblr church-key
|
||||
|
||||
Incididunt umami sriracha, ethical fugiat VHS ex assumenda yr irure direct trade. Marfa Truffaut bicycle rights, kitsch placeat Etsy kogi asymmetrical. Beard locavore flexitarian, kitsch photo booth hoodie plaid ethical readymade leggings yr.
|
||||
|
||||
Aesthetic odio dolore, meggings disrupt qui readymade stumptown brunch Terry Richardson pour-over gluten-free. Banksy american apparel in selfies, biodiesel flexitarian organic meh wolf quinoa gentrify banjo kogi. Readymade tofu ex, scenester dolor umami fingerstache occaecat fashion axe Carles jean shorts minim. Keffiyeh fashion axe nisi Godard mlkshk dolore. Lomo you probably haven't heard of them eu non, Odd Future Truffaut pug keytar meggings McSweeney's Pinterest cred. Etsy literally aute esse, eu bicycle rights qui meggings fanny pack. Gentrify leggings pug flannel duis.
|
||||
|
||||
## Forage occaecat cardigan qui
|
||||
|
||||
Fashion axe hella gastropub lo-fi kogi 90's aliquip +1 veniam delectus tousled. Cred sriracha locavore gastropub kale chips, iPhone mollit sartorial. Anim dolore 8-bit, pork belly dolor photo booth aute flannel small batch. Dolor disrupt ennui, tattooed whatever salvia Banksy sartorial roof party selfies raw denim sint meh pour-over. Ennui eu cardigan sint, gentrify iPhone cornhole.
|
||||
|
||||
> Whatever velit occaecat quis deserunt gastropub, leggings elit tousled roof party 3 wolf moon kogi pug blue bottle ea. Fashion axe shabby chic Austin quinoa pickled laborum bitters next level, disrupt deep v accusamus non fingerstache.
|
||||
|
||||
Tote bag asymmetrical elit sunt. Occaecat authentic Marfa, hella McSweeney's next level irure veniam master cleanse. Sed hoodie letterpress artisan wolf leggings, 3 wolf moon commodo ullamco. Anim occupy ea labore Terry Richardson. Tofu ex master cleanse in whatever pitchfork banh mi, occupy fugiat fanny pack Austin authentic. Magna fugiat 3 wolf moon, labore McSweeney's sustainable vero consectetur. Gluten-free disrupt enim, aesthetic fugiat jean shorts trust fund keffiyeh magna try-hard.
|
||||
|
||||
## Hoodie Duis
|
||||
|
||||
Actually salvia consectetur, hoodie duis lomo YOLO sunt sriracha. Aute pop-up brunch farm-to-table odio, salvia irure occaecat. Sriracha small batch literally skateboard. Echo Park nihil hoodie, aliquip forage artisan laboris. Trust fund reprehenderit nulla locavore. Stumptown raw denim kitsch, keffiyeh nulla twee dreamcatcher fanny pack ullamco 90's pop-up est culpa farm-to-table. Selfies 8-bit do pug odio.
|
||||
|
||||
### Thundercats Ho!
|
||||
|
||||
Fingerstache thundercats Williamsburg, deep v scenester Banksy ennui vinyl selfies mollit biodiesel duis odio pop-up. Banksy 3 wolf moon try-hard, sapiente enim stumptown deep v ad letterpress. Squid beard brunch, exercitation raw denim yr sint direct trade. Raw denim narwhal id, flannel DIY McSweeney's seitan. Letterpress artisan bespoke accusamus, meggings laboris consequat Truffaut qui in seitan. Sustainable cornhole Schlitz, twee Cosby sweater banh mi deep v forage letterpress flannel whatever keffiyeh. Sartorial cred irure, semiotics ethical sed blue bottle nihil letterpress.
|
||||
|
||||
Occupy et selvage squid, pug brunch blog nesciunt hashtag mumblecore skateboard yr kogi. Ugh small batch swag four loko. Fap post-ironic qui tote bag farm-to-table american apparel scenester keffiyeh vero, swag non pour-over gentrify authentic pitchfork. Schlitz scenester lo-fi voluptate, tote bag irony bicycle rights pariatur vero Vice freegan wayfarers exercitation nisi shoreditch. Chambray tofu vero sed. Street art swag literally leggings, Cosby sweater mixtape PBR lomo Banksy non in pitchfork ennui McSweeney's selfies. Odd Future Banksy non authentic.
|
||||
|
||||
Aliquip enim artisan dolor post-ironic. Pug tote bag Marfa, deserunt pour-over Portland wolf eu odio intelligentsia american apparel ugh ea. Sunt viral et, 3 wolf moon gastropub pug id. Id fashion axe est typewriter, mlkshk Portland art party aute brunch. Sint pork belly Cosby sweater, deep v mumblecore kitsch american apparel. Try-hard direct trade tumblr sint skateboard. Adipisicing bitters excepteur biodiesel, pickled gastropub aute veniam.
|
@ -1,18 +0,0 @@
|
||||
---
|
||||
layout: post
|
||||
title: "A Post with a Video"
|
||||
description: "Custom written post descriptions are the way to go... if you're not lazy."
|
||||
tags: [sample post, video]
|
||||
comments: true
|
||||
share: true
|
||||
---
|
||||
|
||||
<iframe width="560" height="315" src="//www.youtube.com/embed/SU3kYxJmWuQ" frameborder="0"> </iframe>
|
||||
|
||||
Video embeds are responsive and scale with the width of the main content block with the help of [FitVids](http://fitvidsjs.com/).
|
||||
|
||||
Not sure if this only effects Kramdown or if it's an issue with Markdown in general. But adding YouTube video embeds causes errors when building your Jekyll site. To fix add a space between the `<iframe>` tags and remove `allowfullscreen`. Example below:
|
||||
|
||||
{% highlight html %}
|
||||
<iframe width="560" height="315" src="//www.youtube.com/embed/SU3kYxJmWuQ" frameborder="0"> </iframe>
|
||||
{% endhighlight %}
|
@ -1,11 +0,0 @@
|
||||
---
|
||||
layout: post
|
||||
title: "Sample Link Post"
|
||||
description: "Example and code for using link posts."
|
||||
tags: [sample post, link post]
|
||||
comments: true
|
||||
link: http://mademistakes.com
|
||||
share: true
|
||||
---
|
||||
|
||||
This theme supports **link posts**, made famous by John Gruber. To use, just add `link: http://url-you-want-linked` to the post's YAML front matter and you're done.
|
@ -1,120 +0,0 @@
|
||||
---
|
||||
layout: post
|
||||
title: Syntax Highlighting Post
|
||||
description: "Demo post displaying the various ways of highlighting code in Markdown."
|
||||
modified: 2013-08-20
|
||||
tags: [sample post, code, highlighting]
|
||||
image:
|
||||
feature: abstract-10.jpg
|
||||
credit: dargadgetz
|
||||
creditlink: http://www.dargadgetz.com/ios-7-abstract-wallpaper-pack-for-iphone-5-and-ipod-touch-retina/
|
||||
comments: true
|
||||
share: true
|
||||
---
|
||||
|
||||
[Syntax highlighting](http://en.wikipedia.org/wiki/Syntax_highlighting) is a feature that displays source code, in different colors and fonts according to the category of terms. This feature facilitates writing in a structured language such as a programming language or a markup language as both structures and syntax errors are visually distinct. Highlighting does not affect the meaning of the text itself; it is intended only for human readers.
|
||||
|
||||
### Pygments Code Blocks
|
||||
|
||||
To modify styling and highlight colors edit `/assets/less/pygments.less` and compile `main.less` with your favorite preprocessor. Or edit `main.css` if that's your thing, the classes you want to modify all begin with `.highlight`.
|
||||
|
||||
{% highlight css %}
|
||||
#container {
|
||||
float: left;
|
||||
margin: 0 -240px 0 0;
|
||||
width: 100%;
|
||||
}
|
||||
{% endhighlight %}
|
||||
|
||||
Line numbering enabled:
|
||||
|
||||
{% highlight html linenos %}
|
||||
{% raw %}
|
||||
<nav class="pagination" role="navigation">
|
||||
{% if page.previous %}
|
||||
<a href="{{ site.url }}{{ page.previous.url }}" class="btn" title="{{ page.previous.title }}">Previous article</a>
|
||||
{% endif %}
|
||||
{% if page.next %}
|
||||
<a href="{{ site.url }}{{ page.next.url }}" class="btn" title="{{ page.next.title }}">Next article</a>
|
||||
{% endif %}
|
||||
</nav><!-- /.pagination -->
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
{% highlight ruby %}
|
||||
module Jekyll
|
||||
class TagIndex < Page
|
||||
def initialize(site, base, dir, tag)
|
||||
@site = site
|
||||
@base = base
|
||||
@dir = dir
|
||||
@name = 'index.html'
|
||||
self.process(@name)
|
||||
self.read_yaml(File.join(base, '_layouts'), 'tag_index.html')
|
||||
self.data['tag'] = tag
|
||||
tag_title_prefix = site.config['tag_title_prefix'] || 'Tagged: '
|
||||
tag_title_suffix = site.config['tag_title_suffix'] || '–'
|
||||
self.data['title'] = "#{tag_title_prefix}#{tag}"
|
||||
self.data['description'] = "An archive of posts tagged #{tag}."
|
||||
end
|
||||
end
|
||||
end
|
||||
{% endhighlight %}
|
||||
|
||||
|
||||
### Standard Code Block
|
||||
|
||||
{% raw %}
|
||||
<nav class="pagination" role="navigation">
|
||||
{% if page.previous %}
|
||||
<a href="{{ site.url }}{{ page.previous.url }}" class="btn" title="{{ page.previous.title }}">Previous article</a>
|
||||
{% endif %}
|
||||
{% if page.next %}
|
||||
<a href="{{ site.url }}{{ page.next.url }}" class="btn" title="{{ page.next.title }}">Next article</a>
|
||||
{% endif %}
|
||||
</nav><!-- /.pagination -->
|
||||
{% endraw %}
|
||||
|
||||
|
||||
### Fenced Code Blocks
|
||||
|
||||
To modify styling and highlight colors edit `/assets/less/coderay.less` and compile `main.less` with your favorite preprocessor. Or edit `main.css` if that's your thing, the classes you want to modify all begin with `.coderay`. Line numbers and a few other things can be modified in `_config.yml` under `coderay`.
|
||||
|
||||
~~~ css
|
||||
#container {
|
||||
float: left;
|
||||
margin: 0 -240px 0 0;
|
||||
width: 100%;
|
||||
}
|
||||
~~~
|
||||
|
||||
~~~ html
|
||||
{% raw %}<nav class="pagination" role="navigation">
|
||||
{% if page.previous %}
|
||||
<a href="{{ site.url }}{{ page.previous.url }}" class="btn" title="{{ page.previous.title }}">Previous article</a>
|
||||
{% endif %}
|
||||
{% if page.next %}
|
||||
<a href="{{ site.url }}{{ page.next.url }}" class="btn" title="{{ page.next.title }}">Next article</a>
|
||||
{% endif %}
|
||||
</nav><!-- /.pagination -->{% endraw %}
|
||||
~~~
|
||||
|
||||
~~~ ruby
|
||||
module Jekyll
|
||||
class TagIndex < Page
|
||||
def initialize(site, base, dir, tag)
|
||||
@site = site
|
||||
@base = base
|
||||
@dir = dir
|
||||
@name = 'index.html'
|
||||
self.process(@name)
|
||||
self.read_yaml(File.join(base, '_layouts'), 'tag_index.html')
|
||||
self.data['tag'] = tag
|
||||
tag_title_prefix = site.config['tag_title_prefix'] || 'Tagged: '
|
||||
tag_title_suffix = site.config['tag_title_suffix'] || '–'
|
||||
self.data['title'] = "#{tag_title_prefix}#{tag}"
|
||||
self.data['description'] = "An archive of posts tagged #{tag}."
|
||||
end
|
||||
end
|
||||
end
|
||||
~~~
|
@ -1,23 +0,0 @@
|
||||
---
|
||||
layout: post
|
||||
title: Post with a Background Image
|
||||
description: "Sample post with a background image CSS override."
|
||||
tags: [sample post]
|
||||
image:
|
||||
background: triangular.png
|
||||
comments: true
|
||||
share: true
|
||||
---
|
||||
|
||||
Here be a sample post with a custom background image. To utilize this "feature" just add the following YAML to a post's front matter.
|
||||
|
||||
{% highlight yaml %}
|
||||
image:
|
||||
background: filename.png
|
||||
{% endhighlight %}
|
||||
|
||||
This little bit of YAML makes the assumption that your background image asset is in the `/images` folder. If you place it somewhere else or are hotlinking from the web, just include the full http(s):// URL. Either way you should have a background image that is tiled.
|
||||
|
||||
If you want to set a background image for the entire site just add `background: filename.png` to your `_config.yml` and BOOM --- background images on every page!
|
||||
|
||||
<div xmlns:cc="http://creativecommons.org/ns#" xmlns:dct="http://purl.org/dc/terms/" about="http://subtlepatterns.com" class="notice">Background images from <span property="dct:title">Subtle Patterns</span> (<a rel="cc:attributionURL" property="cc:attributionName" href="http://subtlepatterns.com">Subtle Patterns</a>) / <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a></div>
|
43
_posts/2014-04-17-what-is-minimalbible.md
Normal file
43
_posts/2014-04-17-what-is-minimalbible.md
Normal file
@ -0,0 +1,43 @@
|
||||
---
|
||||
layout: post
|
||||
title: "What is MinimalBible?"
|
||||
modified: 2014-04-29 17:29:03 -0400
|
||||
tags: [outline, why, bible, minimal, minimalbible, youversion, esv, andbible]
|
||||
image:
|
||||
feature:
|
||||
credit:
|
||||
creditlink:
|
||||
comments:
|
||||
share:
|
||||
---
|
||||
|
||||
When we're talking about starting a project, I think it's incredibly important to make sure you're clear on why it is that the project is being undertaken.
|
||||
On that note, what exactly is MinimalBible?
|
||||
|
||||
**MinimalBible** is going to be a Bible reading and study app for the Android platform with three goals in mind:
|
||||
|
||||
|
||||
1. Usability
|
||||
2. Efficiency
|
||||
3. Simplicity
|
||||
|
||||
In my opinion, the current offerings for a Bible app could really use some improvement. The three main apps I'm aware of are: [YouVersion][1], [ESV][2], and [AndBible][3]. I have a few issues with each:
|
||||
|
||||
|
||||
* YouVersion - Tends to be very slow, and I think it tries to accomplish way too much (friends, videos, plans, etc.). Additionally, I'd prefer having a pure offline app, YouVersion gives me a lot of notifications if my data is off.
|
||||
* ESV - Hasn't been updated in a while, and from conversations with people, it tends to crash on some devices. Additionally, it's hard to share verses, bookmarks, etc
|
||||
* AndBible - The interface just seems to be very out of date. I like how focused it is, but it doesn't take advantage of a lot of modern UI design. It does use the same [backing library][4] I'm planning on though.
|
||||
So in addition to changing a lot of things that I think are frustrating in other Bible apps, there are a few things I want to do in addition:
|
||||
|
||||
|
||||
* Infinite scroll - I don't want to keep clicking buttons to switch between chapters, disrupting how they flow. I'd like to be able to scroll through an entire book at a time.
|
||||
* Search - Search functionality seems to be problematic for everyone. I'd like to get a more fuzzy search implemented, as the current searches I've used haven't been very helpful unless I already know most of the text.
|
||||
* Footnotes/Commentary - I think it would be great to make it easier to view Commentaries or footnotes inline. This will take some work to get a usable UI, but trying to view footnotes especially is challenging with the apps listed above.
|
||||
|
||||
So I'm hoping to use this site to document my ongoing development and progress, so other people can use this as a resource in the future! Looking forward to taking this journey, and I'd appreciate prayers for grace and strength to go through with this!
|
||||
|
||||
[1]: https://play.google.com/store/apps/details?id=com.sirma.mobile.bible.android
|
||||
[2]: https://play.google.com/store/apps/details?id=com.subsplash.esv
|
||||
[3]: https://play.google.com/store/apps/details?id=net.bible.android.activity
|
||||
[4]: http://www.crosswire.org/jsword/
|
||||
|
@ -0,0 +1,33 @@
|
||||
---
|
||||
layout: post
|
||||
title: "A Star Wars reference, and practical-scale builds"
|
||||
modified: 2014-04-29 17:35:35 -0400
|
||||
tags: [shade, ant, jsword, and-bible, maven, xml, jarjar]
|
||||
image:
|
||||
feature:
|
||||
credit:
|
||||
creditlink:
|
||||
comments:
|
||||
share:
|
||||
---
|
||||
|
||||
_Also some really cool build logic_
|
||||
|
||||
So I’ve covered in [another post][1] how I got to create a build.xml file for the MinimalBible. The actual process of writing the build.xml file is another story entirely.
|
||||
|
||||
First, a few disclaimers. Google’s version of the Apache HttpClient is [old and outdated][2]. You can’t just include the httpclient library in your project, as it produces [errors][3]. Also, I wanted an entirely automated, one-click build. That meant no copying in a [new library][2] by hand. Especially since said new library would not be compatible with code expecting a vanilla HttpClient (see Compatibility notes number 2). It’s possible there would be no compatibility issues, but I never followed this path. Finally, I had run into this problem when I was using Maven to build the jSword library. The solution I used then was to do a [shaded build][4], which basically manipulated the bytecode to look for the library in a different path. Thus, all the code referencing org.apache.http could instead reference org.apache.shaded.http, or something similar.
|
||||
|
||||
So, knowing that I was going to write a build script using Ant, I now had to figure out how to do something similar to the Maven shaded build. Very long story short, [JarJar][5] was the plugin I found to do the trick (ironically, searching “JarJar” on Google yielded the library and not the character as the first result. I’m OK with this). I had a couple of reservations since the most recent version of jarjar was released November 2012, but so far it’s panned out all right.
|
||||
|
||||
Now I needed to edit the jar task in Ant to use the new JarJar plugin. The existing jar task that I copied from And-bible did most of the work, but did not include the shaded build. The JarJar [Getting Started page][6] had most of the information I needed on getting this set up for MinimalBible. Honestly, the only thing I really needed that wasn’t documented was including multiple jars at a time. I didn’t want to manually list out a ][7] for every jar file that needed to get built in with jSword, so after a lot of digging around, I found the . It doesn’t seem to be officially documented, so using some information [found on Stack Overflow][8], I hacked together a solution that allowed me to include the jSword dependencies, while excluding the libraries used for testing.
|
||||
|
||||
So at this point, I’ve now got a shaded build for jSword working as expected. I’m now ready to start focusing on MinimalBible code exclusively, and I can easily include building jSword as a part of building MinimalBible. In the future I’ll need to work on stripping out more of the code that goes into jSword that isn’t needed (it’s currently an 18MB library), but for now I’ve got a stable, consistent, one-click build working. I’ll call that good.
|
||||
|
||||
[1]: http://minimalbible.blogspot.com/2014/04/xml-is-terrible-programming-language.html
|
||||
[2]: https://hc.apache.org/httpcomponents-client-4.3.x/android-port.html
|
||||
[3]: http://stackoverflow.com/questions/19836012/how-to-override-android-api-class-with-a-class-available-in-added-jar
|
||||
[4]: http://maven.apache.org/plugins/maven-shade-plugin/
|
||||
[5]: http://code.google.com/p/jarjar/
|
||||
[6]: http://code.google.com/p/jarjar/wiki/GettingStarted
|
||||
[7]: http://ant.apache.org/manual/Types/zipfileset.html
|
||||
[8]: http://stackoverflow.com/questions/1821803/creating-a-bundle-jar-with-ant
|
55
_posts/2014-04-22-xml-is-a-terrible-programming-language.md
Normal file
55
_posts/2014-04-22-xml-is-a-terrible-programming-language.md
Normal file
@ -0,0 +1,55 @@
|
||||
---
|
||||
layout: post
|
||||
title: "XML is a terrible programming language"
|
||||
modified: 2014-04-29 17:32:29 -0400
|
||||
tags: [xml, ant, gradle, maven, dependency management, android studio]
|
||||
image:
|
||||
feature:
|
||||
credit:
|
||||
creditlink:
|
||||
comments:
|
||||
share:
|
||||
---
|
||||
|
||||
_But Gradle is worse_
|
||||
|
||||
So, one of the first goals in building MinimalBible was getting the underlying library building correctly. I’m using [jSword][1] to drive most of the underlying functionality of the app – downloading Bibles, searching Bibles, displaying the text, etc. I have incredibly little experience with Java build systems, but in my experience prior, I had worked with Maven a bit. So when I noticed a pom.xml file, I thought I had it made. Turns out the pom.xml was outdated, and for an old build of the library.
|
||||
|
||||
Looking at [And-bible][2] was one of the things that first clued me in that I was approaching this the wrong way (the fact that the build was producing a jsword-1.6.jar when I knew the build was at least at version 2.1 was the other). The build.xml file also looked important, so I decided to do some more research. Here’s what I’ve learned.
|
||||
|
||||
There are a lot of different systems to build Java projects (I come from Python/C). The three most prevalent are [Gradle][3], [Ant][4], and [Maven][5]. By default, Android projects (using [Android Development Tools in Eclipse][6]) use none of these. Small-scale Android apps that don’t rely on a lot of extra libraries or other projects simply don’t need the level of functionality provided by any of these. But for the apps that do need extra functionality, you’re going to need to put a build system in place.
|
||||
|
||||
I’ll start with Maven, since it seems to be the least used in the Android world. There’s a [tutorial][7] and a [plugin][8] for doing it, but on the whole I didn’t see a whole lot of information on how to use it. That being said, the Maven project retains a [central repository][9] of Java libraries that all the other build systems rely on. This way, you can declare dependencies on other libraries, and have the build system automatically download and install them. Lovely.
|
||||
|
||||
Ant seems to be the most well-used (if soon to be phased-out) build system in use with Android. ADT has support for generating an Ant build file, and Google has info on how to use Ant with ADT [online][10]. However, Ant in and of itself does not have the dependency management that Maven and Gradle do. For that, we rely on a different library known as [Ivy][11]. This way, while Ant handles the build process, Ant can invoke Ivy to fetch all the needed libraries before actually compiling. This build system is what is in use by jSword, and they have a fairly nice build set up.
|
||||
|
||||
Gradle is the final build toolkit I’ll talk about. First things first, Gradle is **powerful**. Their manifesto even [says so][12]: “Make the impossible possible, make the possible easy and make the easy elegant.” Gradle is also the build system used by [Android Studio][13], the IDE that will eventually replace ADT. So starting as a new project, I thought it would be a good idea to give Android Studio/Gradle a spin. This is eventually going to be the way of the future.
|
||||
|
||||
Getting the initial Eclipse project imported wasn’t too complicated, the documentation for doing that [is pretty simple][14]. I generated my build.gradle file, and imported the project. And that’s about as far as I got.
|
||||
|
||||
The first order of business was making sure that I could build the jSword project using the new Gradle system. Building the Android project itself I’m sure is incredibly simple, I can get to that later. I wanted to first make sure it would be possible to even get the underlying library working first. To that end, I started doing some research and playing around with getting [Ant to work with Gradle][15]. Theoretically, Ant build tasks are first-class citizens in Gradle world. The problem is, Gradle has no way of namespacing the imported Ant tasks. That means if there’s a naming conflict, the build fails (there’s a [patch to fix this][16] coming up). While this isn’t an issue if you’re just migrating from Ant to Gradle, if you’re trying to use both Gradle and Ant at the same time, this will cause catastrophic problems. Since I don’t intend to fork jSword for Gradle alone, I needed to come up with something different.
|
||||
|
||||
For a while I tried to hack together namespacing by putting the jSword Ant tasks into another project. You can find an example (that I assume worked for the author) [over here][17]. This didn’t really work for me. By this time, I had been checking the And-bible [build script][18] trying to see how its author solved this problem. Without having any actual knowledge of how to write Ant tasks, what I learned by just looking at the code was that he copied over the original source, merged in his modified code, and then compiled the entire thing. And to be honest, I didn’t even try to attempt this with Gradle. While I’m sure Gradle is more than capable of doing this, it wasn’t worth the effort to figure it out; I had a build I could imitate and use as a starting point.
|
||||
|
||||
And so, using the And-bible build.xml as a starting point, I wrote my own build script, which is now available over [here][19]. I’ll have more information about actually writing the build script in another post!
|
||||
|
||||
[1]: http://crosswire.org/jsword/
|
||||
[2]: https://github.com/mjdenham/and-bible/tree/master/AndBible
|
||||
[3]: http://www.gradle.org/
|
||||
[4]: https://ant.apache.org/
|
||||
[5]: http://maven.apache.org/
|
||||
[6]: http://developer.android.com/sdk/index.html
|
||||
[7]: http://www.vogella.com/tutorials/AndroidBuildMaven/article.html
|
||||
[8]: https://code.google.com/p/maven-android-plugin/
|
||||
[9]: http://search.maven.org/
|
||||
[10]: http://developer.android.com/tools/building/building-eclipse.html
|
||||
[11]: https://ant.apache.org/ivy/
|
||||
[12]: http://www.gradle.org/docs/current/userguide/tutorial_using_tasks.html
|
||||
[13]: http://developer.android.com/sdk/installing/studio.html
|
||||
[14]: http://developer.android.com/sdk/installing/migrate.html
|
||||
[15]: http://www.gradle.org/docs/current/userguide/ant.html
|
||||
[16]: http://issues.gradle.org/i#browse/GRADLE-771
|
||||
[17]: http://gradle.1045684.n5.nabble.com/Accessing-ant-build-xml-from-gradle-td4650344.html
|
||||
[18]: https://github.com/mjdenham/and-bible/blob/master/jsword-tweaks/build.xml
|
||||
[19]: https://github.com/DjBushido/MinimalBible/blob/master/jsword-minimalbible/build.xml
|
||||
|
112
_posts/2014-04-29-asynctask-caching.md
Normal file
112
_posts/2014-04-29-asynctask-caching.md
Normal file
@ -0,0 +1,112 @@
|
||||
---
|
||||
layout: post
|
||||
title: "AsyncTask caching"
|
||||
modified: 2014-04-29 17:36:19 -0400
|
||||
tags: [singleton, asynctask, eventbus, caching, fragment, asynchronous]
|
||||
image:
|
||||
feature:
|
||||
credit:
|
||||
creditlink:
|
||||
comments:
|
||||
share:
|
||||
---
|
||||
|
||||
Singletons, AsyncTasks, & EventBus! Oh my!
|
||||
------------------------------------------
|
||||
|
||||
So, MinimalBible is my first full-scale Android app. I'm trying to do what I can to make sure the code is readable and follows good design patterns. To that end, let me describe the problem:
|
||||
|
||||
I need to fetch the list of modules available for download (may or may not be from the internet, not worried about that here). To do so is a relatively expensive operation (since it may involve the internet) so using the `Fragment` that displays the module list is right out. Some potential solutions:
|
||||
|
||||
* Eat the cost of fetching the list, each `Fragment` fires an `AsyncTask`
|
||||
* The `Fragment` is initialized with the list it needs
|
||||
* Have some external singleton class cache the list in memory, and each fragment can retrieve it from that class
|
||||
* Have a service responsible for doing the download, everyone comes to the service
|
||||
* If no value exists, Fragment displays that there is no information, and manually force a reload when the information has been retrieved
|
||||
|
||||
This is complicated by the fact that the `Fragment` should be able to retrieve the list synchronously if it has already been loaded. That is, the Fragment needs to know if the value exists and it can do its work, or if it needs to wait a bit. Since the Fragment is on the UI thread, I can't assume a synchronous operation unless the value is already prepared.
|
||||
So the basic problem is: **I need to get a value asynchronously, but how do I cache it to re-use? Or, who is responsible for caching?** None of the solutions above seem to have a sound answer to the problem.
|
||||
The solution I chose then doesn't fundamentally solve the problem either. But I'm more than happy to accept suggestions on how to do this differently!
|
||||
|
||||
First off, somebody has to be responsible for doing the work of actually fetching the modules, whether from the internet, or from the jSword cache. Because fetching from cache is still an expensive operation (2-3 sec.), it's easier to have one `AsyncTask` responsible for doing all of that work.
|
||||
|
||||
Second, I only ever want this `AsyncTask` to run once. The module list (hopefully) can stay persisted in memory to be re-used by the different `Fragment`s that need it. That means that there needs to be a Singleton somewhere along the line that's responsible for caching the value.
|
||||
|
||||
Finally, that Singleton has a method available to inspect whether the content the `AsyncTask` was fetching exists yet.
|
||||
|
||||
That's the basic methodology I used. However, instead of caching the returned value in the parent Singleton, I used the [EventBus](https://github.com/greenrobot/EventBus) to handle it for me. This way, **I avoid the boilerplate of an Interface/Listener pattern, and I avoid the [Sleeping Barber](http://en.wikipedia.org/wiki/Sleeping_barber_problem) problem.**
|
||||
|
||||
The EventBus is an asynchronous communication bus that allows us to connect senders and receivers of POJO objects. This way, the Singleton I was describing above retains a reference to the bus the `AsyncTask` will post on, and connects listeners to it. After that, the EventBus has a concept of *sticky events*, which are events persisted in memory until explicitly cleared.
|
||||
So, let's get into some actual pseudo-code!
|
||||
|
||||
**FetchTask.java**
|
||||
```
|
||||
class FetchTask extends AsyncTask<...> {
|
||||
private EventBus downloadBus;
|
||||
public FetchTask(EventBus downloadBus) {
|
||||
this.downloadBus = downloadBus;
|
||||
}
|
||||
|
||||
public doInBackground(...) {
|
||||
// Do the deed
|
||||
downloadBus.postSticky(results);
|
||||
return results;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**DownloadManager.java**
|
||||
```
|
||||
class DownloadManager {
|
||||
private EventBus downloadBus;
|
||||
private DownloadManager instance;
|
||||
|
||||
private DownloadManager() {}
|
||||
public static DownloadManager getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new DownloadManager();
|
||||
instance.downloadBus = new EventBus();
|
||||
new FetchTask().execute();
|
||||
}
|
||||
}
|
||||
public EventBus getDownloadBus() {
|
||||
return this.downloadBus;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Fragment.java**
|
||||
```
|
||||
class Fragment {
|
||||
public void init() {
|
||||
EventBus downloadBus = DownloadManager.getInstance().getDownloadBus();
|
||||
Results results = downloadBus.getStickyEvent(Results.class);
|
||||
if (results == null) {
|
||||
// The operation hasn't finished yet, so notify us when done
|
||||
downloadBus.registerSticky(this);
|
||||
} else {
|
||||
// Operation is already done, initialize now
|
||||
initUI(results);
|
||||
}
|
||||
}
|
||||
|
||||
public void onEventMainThread(Results results) {
|
||||
// EventBus will call this
|
||||
initUI(results);
|
||||
}
|
||||
|
||||
public void initUI(Results results) {
|
||||
// Initialize the UI - can safely assume we're on main thread
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
So, let's quickly review what's going on - the Fragment gets initialized, and gets the Download manager, so it can get the event bus. Then, since the AsyncTask is started alongside the new `DownloadManager`, we register that we should be notified when done.
|
||||
|
||||
Then the DownloadManager starts the initial AsyncTask to download the list, and cache it in the EventBus. Finally, we `postSticky()` and call it a day.
|
||||
|
||||
After this, any new `Fragment`s checking the `downloadBus` will see that the value already exists, and can do work.
|
||||
|
||||
So this isn't a perfect implementation, and honestly, just shoves the problem onto the `EventBus`. That being said, it's a sane implementation, and is relatively readable.
|
||||
|
||||
**TODO:** Switch around some of the singletons to use dependency injection. I've got my eye on [Dagger](http://square.github.io/dagger/).
|
Loading…
Reference in New Issue
Block a user