-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The iOS Times Newsletter automation π
- Loading branch information
0 parents
commit 749d962
Showing
8 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "issues"] | ||
path = issues | ||
url = [email protected]:mokacoding/the-ios-times-issues.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'rake' | ||
gem 'redcarpet' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
rake (10.4.2) | ||
redcarpet (3.2.3) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
rake | ||
redcarpet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
The iOS Times - Newsletter | ||
=== | ||
|
||
This repo contains the automation used to generated the source for [The iOS Times](http://theiostimes.com) weekly newsletter. | ||
|
||
```bash | ||
rake build | ||
``` | ||
|
||
--- | ||
|
||
(c) 2015 - mokacoding [@mokacoding](https://twitter.com/mokacoding) & Giovanni Lodi [@mokagio](https://twitter.com/mokagio) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
require 'tempfile' | ||
|
||
issues_folder = 'issues' | ||
|
||
desc "Update the issues list" | ||
task :update do | ||
sh "git submodule foreach git pull" | ||
end | ||
|
||
def stripped_front_matter_temp_file(issue) | ||
f = Tempfile.new('title') | ||
begin | ||
found_start = false | ||
found_end = false | ||
issue.each_line do |line| | ||
line = line.strip | ||
if not found_start | ||
found_start = line == '---' | ||
elsif not found_end | ||
found_end = line == '---' | ||
else | ||
f.puts line | ||
end | ||
end | ||
ensure | ||
f.close | ||
end | ||
return f | ||
end | ||
|
||
def title_temp_file(issue) | ||
f = Tempfile.open('title') | ||
begin | ||
f.puts '# The iOS Times' | ||
issue_number = File.basename(issue, '.*').split('-').last.to_i | ||
f.puts "## Year #{2015 - Time.now.year + 1} Issue #{issue_number}" | ||
f.puts "### #{File.basename(issue)[0, 10]}" | ||
ensure | ||
f.close | ||
end | ||
return f | ||
end | ||
|
||
desc "Generate the HTML code for the latest issue, and copy it to the clipboar" | ||
task :build => [:update] do | ||
latest = Dir["#{issues_folder}/*.md"].reject { |f| File.basename(f) == "README.md" }.last | ||
issue = File.open(latest) | ||
temp_issue = stripped_front_matter_temp_file(issue) | ||
temp_title = title_temp_file(issue) | ||
sh "redcarpet --parse-fenced_code_blocks --smarty #{temp_title.path} header.md #{temp_issue.path} footer.md | pbcopy" | ||
puts "π HTML code for #{latest} copied to clipboard" | ||
temp_issue.unlink | ||
temp_title.unlink | ||
issue.close | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
<!-- Footer start, empty line on top needed --> | ||
|
||
Thank you for reading **The iOS Times**, if you have comments, complaints, suggestions, or any other feedback please tweet me at [@mokagio](https://twitter.com/mokagio). | ||
|
||
_Have a happy week, and don't forget to contriubte to open source projects._ | ||
|
||
<!-- Footer end --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
**Your weekly digest with the most interesting Swift and Objective-C project from the past 7 days. Find useful tools, inspiration, projects to contribute to.** | ||
|
||
<!-- Header end --> |