]>
pere.pagekite.me Git - text-madewithcc.git/blob - fixup.rb
3 raise ArgumentError
, 'Source/destination files not specified' if ARGV.size !
= 2
7 data=File
.open(srcfile
).readlines
.map
{|l
| l
.chomp!
}
9 data.map
{|lin
| lin
.gsub!
(/<span id="anchor-?\d*"><\/span
>/, '')}
11 # There are several titles that are spread in more than one line. Make
12 # them into translatable sentences.
13 [ ['Made', '', 'with', '', 'Creative', '', 'Commons'],
14 ['The New','', 'World of', '', 'Digital', '', 'Commons'],
15 ['How', '', 'to Be', '', 'Made with', '', 'Creative', '', 'Commons'],
16 ['Use CC to get attribution and name', 'recognition'],
17 ['Use CC to enable hands-on engagement with', 'your work'],
18 ['Providing a custom service to consumers of', 'your work * \[MARKET-BASED\]*'],
19 ['Charging for the physical copy *', '\[MARKET-BASED\]*'],
20 ['Charging for the in-person version *','\[MARKET-BASED\]*'],
21 ['Charging advertisers or sponsors *', '\[MARKET-BASED\]*'],
22 ['Charging your content creators *', '\[MARKET-BASED\]*'],
23 ['Charging a transaction fee *', '\[MARKET-BASED\]*'],
24 ['Providing a service to your creators*', '\[MARKET-BASED\]*'],
25 ['Memberships and individual donations', '*\[RECIPROCITY-BASED\]*'],
26 ['The pay-what-you-want model', '*\[RECIPROCITY-BASED\]*'],
27 ['The', '', 'Creative', '', 'Commons', '', 'Licenses'],
28 ['PLOS','', '(Public Library of Science)']
30 # This should be done more generic, more robust... But before
31 # burning brain cells, verify if it's needed!
32 if (data.select
{|i
| i
== str
[0]}.size !
= 1)
33 raise RuntimeError
, 'First string appears multiple times: %s (%s)' %
34 [str
.reject
{|i
| i
==''}.join(' '), str
[0]]
38 at
= data.index(str
[0])
39 joined
= str
.reject
{|word
| word
==''}.join(' ')
41 if str
[offset
] !
= data[at+offset
]
43 'Warning: String does not match ("%s" of "%s", offset %d, book at %d)' %
44 [str
[offset
], joined
, offset
, at+offset
]
49 (str
.size
- 1).times
{ data.delete_at(at+
1) }
52 # Mark up headings: Very artisanal and suboptimal, but should do the
55 # For every heading, put here the full string and its heading level,
63 # Try to keep this ordered as it appears within the book, as it will
64 # help us spot omissions and mistakes!
68 [1, 'The Big Picture'],
69 [2, 'The New World of Digital Commons'],
70 [3, 'The Commons, the Market, and the State'],
71 [3, 'The Four Aspects of a Resource'],
72 [4, 'Characteristics'],
73 [4, 'People and processes'],
74 [4, 'Norms and rules'],
76 [3, 'A Short History of the Commons'],
77 [3, 'The Digital Revolution'],
78 [3, 'The Birth of Creative Commons'],
79 [3, 'The Changing Market'],
80 [3, 'Benefits of the Digital Commons'],
81 [3, 'Our Case Studies'],
83 [2, 'How to Be Made with Creative Commons'],
84 [3, 'Problem Zero: Getting Discovered'],
85 [4, 'Use CC to grow a larger audience'],
86 [4, 'Use CC to get attribution and name recognition'],
87 [4, 'Use CC-licensed content as a marketing tool'],
88 [4, 'Use CC to enable hands-on engagement with your work'],
89 [4, 'Use CC to differentiate yourself'],
91 [4, 'Market-based revenue streams'],
92 [4, 'Providing a custom service to consumers of your work * \[MARKET-BASED\]*'],
93 [4, 'Charging for the physical copy * \[MARKET-BASED\]*'],
94 [4, 'Charging for the in-person version * \[MARKET-BASED\]*'],
95 [4, 'Selling merchandise * \[MARKET-BASED\]*'],
96 [4, 'Charging advertisers or sponsors * \[MARKET-BASED\]*'],
97 [4, 'Charging your content creators * \[MARKET-BASED\]*'],
98 [4, 'Charging a transaction fee * \[MARKET-BASED\]*'],
99 [4, 'Providing a service to your creators* \[MARKET-BASED\]*'],
100 [4, 'Licensing a trademark* \[MARKET-BASED\]*'],
101 [4, 'Reciprocity-based revenue streams'],
102 [4, 'Memberships and individual donations *\[RECIPROCITY-BASED\]*'],
103 [4, 'The pay-what-you-want model *\[RECIPROCITY-BASED\]*'],
104 [4, 'Crowdfunding *\[RECIPROCITY-BASED\]*'],
105 [3, 'Making Human Connections'],
107 [4, 'Be open and accountable'],
108 [4, 'Design for the good actors'],
109 [4, 'Treat humans like, well, humans'],
110 [4, 'State your principles and stick to them'],
111 [4, 'Build a community'],
112 [4, 'Give more to the commons than you take'],
113 [4, 'Involve people in what you do'],
115 [2, 'The Creative Commons Licenses'],
117 [1, 'The Case Studies'],
120 [2, 'Blender Institute'],
121 [2, 'Cards Against Humanity'],
122 [2, 'The Conversation'],
123 [2, 'Cory Doctorow'],
126 [2, 'Knowledge Unlatched'],
127 [2, 'Lumen Learning'],
128 [2, 'Jonathan Mann'],
130 [2, 'Open Data Institute'],
133 [2, 'Amanda Palmer'],
134 [2, 'PLOS (Public Library of Science)'],
140 [2, 'Tribe of Noise'],
141 [2, 'Wikimedia Foundation'],
143 [2, 'Acknowledgments'],
146 at
= data.index
{|i
| i
== item
[1]}
148 raise RuntimeError
, 'Heading string (level %d) not found: «%s»' % item
150 data[at
] = '%s %s' % ['#' * item
[0], data[at
]]
155 # Join erroneously split paragraphs
156 ['to the values symbolized by',
157 'the kinds of participative communities that drive open',
158 'At a minimum, a CC-',
160 'free download, the',
161 'openness to fans remixing the game—give',
163 'both journal publishers and researchers. Figshare now provides',
164 'get the “network effect”—',
165 'access to scholarly books. For Frances, the current scholarly-',
168 'contributing to the open',
169 'doesn’t seem like it should be sung about',
170 'songwriter, and he has found a way to keep it interesting for',
171 'building trust is the top',
173 'authors and Shuttleworth; Mark remains incredibly proud of this',
174 'BY-SA and opting in others with collecting societies like',
175 'Cecilie Maria, Cedric Howe, Cefn Hoile,',
176 'Braddlee, Drew Spencer, Duncan',
177 'Elizabeth Holloway, Ellen Buecher, Ellen Kaye-',
180 at
= data.index
{|i
| i
== line
}
181 if !at
.nil? and data[at+
1] == ''
186 File
.open(dstfile
, 'w') {|f
| f
.puts
data.join("\n")}