linkscape 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,418 @@
1
+ directory = File.expand_path(File.dirname(__FILE__))
2
+ require File.join(directory, 'constants', 'anchor-metrics')
3
+ require File.join(directory, 'constants', 'url-metrics')
4
+ require File.join(directory, 'constants', 'link-metrics')
5
+
6
+ module Linkscape
7
+ module Constants
8
+ URLResponseFields = {
9
+
10
+ :uu => {
11
+ :name => 'URL',
12
+ :key => :url,
13
+ :desc => %Q[The URL in question, as it has been canonicalized in the Linkscape index],
14
+ },
15
+ :urid => {
16
+ :name => 'Internal ID',
17
+ :key => :internal_id,
18
+ :desc => %Q[Internal ID of the URL],
19
+ },
20
+ :ur => {
21
+ :name => 'Canonical URL',
22
+ :key => :canonical_url,
23
+ :desc => %Q[If the URL in question performs some kind of search engine canonicalization that is known to Linkscape (e.g., a 301 redirect), this field will contain the target of the canonicalization],
24
+ },
25
+ :urrid => {
26
+ :name => 'Canonical URL Internal ID',
27
+ :key => :canonical_internal_id,
28
+ :desc => %Q[Internal ID of the canonical URL],
29
+ },
30
+
31
+ :us => {
32
+ :name => 'HTTP Status',
33
+ :key => :status,
34
+ :desc => %Q[The HTTP status of the target URL],
35
+ },
36
+ :ut => {
37
+ :name => 'Page Title',
38
+ :key => :title,
39
+ :desc => %Q[The title of the target URL, if a title is available],
40
+ },
41
+
42
+ :ff => {
43
+ :name => 'Time of Last FQ Domain Update',
44
+ :key => :fq_domain_updated_at,
45
+ :desc => %Q[The unix timestamp giving a rough idea of how fresh the data is of the FQ domain of the target URL],
46
+ },
47
+ :pf => {
48
+ :name => 'Time of Last PL Domain Update',
49
+ :key => :pl_domain_updated_at,
50
+ :desc => %Q[The unix timestamp giving a rough idea of how fresh the data is of the PL domain of the target URL],
51
+ },
52
+ :uf => {
53
+ :name => 'Time of Last Update',
54
+ :key => :updated_at,
55
+ :desc => %Q[The unix timestamp giving a rough idea of how fresh the data is of the target URL],
56
+ },
57
+
58
+ :fid => {
59
+ :name => 'Number of Links to FQ Domain',
60
+ :key => :fq_domain_fq_domains_linking,
61
+ :desc => %Q[The number of domains with at least one link to any page on the FQ domain of the target URL],
62
+ },
63
+ :fipl => {
64
+ :name => 'Number of Links to FQ Domain',
65
+ :key => :fq_domain_pl_domains_linking,
66
+ :desc => %Q[The number of domains with at least one link to any page on the FQ domain of the target URL],
67
+ },
68
+ :feid => {
69
+ :name => 'Number of External Juice-Passing Links to this Subdomain',
70
+ :key => :fq_domain_external_links,
71
+ :desc => %Q[the number of external (from other subdomains), juice-passing links to pages on this subdomain],
72
+ },
73
+ :pid => {
74
+ :name => 'Number of Links to PL Domain',
75
+ :key => :pl_domain_pl_domains_linking,
76
+ :desc => %Q[The number of domains with at least one link to any page on the PL domain of the target URL],
77
+ },
78
+ :peid => {
79
+ :name => 'Number of External Juice-Passing Links to this Domain',
80
+ :key => :pl_domain_external_links,
81
+ :desc => %Q[the number of external (from other root domains), juice-passing links to pages on this root domain],
82
+ },
83
+ :uid => {
84
+ :name => 'Number of Links',
85
+ :key => :links,
86
+ :desc => %Q[The number of internal and external, juice and non-juice passing links to the target URL in the Linkscape index],
87
+ },
88
+ :fuid => {
89
+ :name => 'Number of Links to Subdomain',
90
+ :key => :fq_domain_links,
91
+ :desc => %Q[The number of internal and external, juice and non-juice passing links to the subdomain of the target URL in the Linkscape index],
92
+ },
93
+ :puid => {
94
+ :name => 'Number of Links to Root Domain',
95
+ :key => :pl_domain_links,
96
+ :desc => %Q[The number of internal and external, juice and non-juice passing links to the root domain of the target URL in the Linkscape index],
97
+ },
98
+ :ujid => {
99
+ :name => 'Number of Juice-passing Links',
100
+ :key => :juice_links,
101
+ :desc => %Q[The number of juice passing links (internal or external) to the target URL in the Linkscape index],
102
+ },
103
+ :ueid => {
104
+ :name => 'Number of External Juice-Passing Links',
105
+ :key => :external_links,
106
+ :desc => %Q[The number of external (from other subdomains), juice passing links to the target URL in the Linkscape index],
107
+ },
108
+
109
+ :fejp => {
110
+ :name => 'External mozRank sum of all FQ Domain Pages',
111
+ :key => :fq_domain_external_mozrank_sum,
112
+ :desc => %Q[The pretty (logarithmically scaled) sum of the mozRank due to external links of all the pages of the FQ domain of the target URL in the Linkscape index],
113
+ },
114
+ :fjp => {
115
+ :name => 'mozRank sum of all FQ Domain Pages',
116
+ :key => :fq_domain_mozrank_sum,
117
+ :desc => %Q[The pretty (logarithmically scaled) sum of the mozRank of all the pages of the FQ domain of the target URL in the Linkscape index],
118
+ },
119
+ :pejp => {
120
+ :name => 'External mozRank sum of all PL Domain Pages',
121
+ :key => :pl_domain_external_mozrank_sum,
122
+ :desc => %Q[The pretty (logarithmically scaled) sum of the mozRank due to external links of all the pages of the PL domain of the target URL in the Linkscape index],
123
+ },
124
+ :pjp => {
125
+ :name => 'mozRank sum of all PL Domain Pages',
126
+ :key => :pl_domain_mozrank_sum,
127
+ :desc => %Q[The pretty (logarithmically scaled) sum of the mozRank of all the pages of the PL domain of the target URL in the Linkscape index],
128
+ },
129
+
130
+ :fejr => {
131
+ :name => 'External mozRank sum of all FQ Domain Pages (raw)',
132
+ :key => :fq_domain_external_mozrank_sum_raw,
133
+ :desc => %Q[The raw (linearly scaled) sum of the mozRank due to external links of all the pages of the FQ domain of the target URL in the Linkscape index],
134
+ },
135
+ :fjr => {
136
+ :name => 'mozRank sum of all FQ Domain Pages (raw)',
137
+ :key => :fq_domain_mozrank_sum_raw,
138
+ :desc => %Q[The raw (linearly scaled) sum of the mozRank of all the pages of the FQ domain of the target URL in the Linkscape index],
139
+ },
140
+ :pejr => {
141
+ :name => 'External mozRank sum of all PL Domain Pages (raw)',
142
+ :key => :pl_domain_external_mozrank_sum_raw,
143
+ :desc => %Q[The raw (linearly scaled) sum of the mozRank due to external links of all the pages of the PL domain of the target URL in the Linkscape index],
144
+ },
145
+ :pjr => {
146
+ :name => 'mozRank sum of all PL Domain Pages (raw)',
147
+ :key => :pl_domain_mozrank_sum_raw,
148
+ :desc => %Q[The raw (linearly scaled) sum of the mozRank of all the pages of the PL domain of the target URL in the Linkscape index],
149
+ },
150
+
151
+ :fmrp => {
152
+ :name => 'mozRank of FQ Domain',
153
+ :key => :fq_domain_mozrank,
154
+ :desc => %Q[The pretty (ten point, logarithmically scaled) measure of the mozRank of the FQ domain of the target URL in the Linkscape index],
155
+ },
156
+ :pmrp => {
157
+ :name => 'mozRank of PL Domain',
158
+ :key => :pl_domain_mozrank,
159
+ :desc => %Q[The pretty (ten point, logarithmically scaled) measure of the mozRank of the PL domain of target URL in the Linkscape index],
160
+ },
161
+ :umrp => {
162
+ :name => 'mozRank',
163
+ :key => :mozrank,
164
+ :desc => %Q[The pretty (ten point, logarithmically scaled) measure of the mozRank of the target URL in the Linkscape index],
165
+ },
166
+
167
+ :fmrr => {
168
+ :name => 'mozRank of FQ Domain (raw)',
169
+ :key => :fq_domain_mozrank_raw,
170
+ :desc => %Q[The raw (zero to one, linearly scaled) measure of the mozRank of the FQ domain of the target URL in the Linkscape index],
171
+ },
172
+ :pmrr => {
173
+ :name => 'mozRank of PL Domain (raw)',
174
+ :key => :pl_domain_mozrank_raw,
175
+ :desc => %Q[The raw (zero to one, linearly scaled) measure of the mozRank of the PL domain of the target URL in the Linkscape index],
176
+ },
177
+ :umrr => {
178
+ :name => 'mozRank (raw)',
179
+ :key => :mozrank_raw,
180
+ :desc => %Q[The raw (zero to one, linearly scaled) measure of the mozRank of the target URL in the Linkscape index],
181
+ },
182
+
183
+ :ftrp => {
184
+ :name => 'mozTrust of FQ Domain',
185
+ :key => :fq_domain_moztrust,
186
+ :desc => %Q[The pretty (ten point, logarithmically scaled) measure of the mozTrust of the FQ domain of the target URL in the Linkscape index],
187
+ },
188
+ :ptrp => {
189
+ :name => 'mozTrust of PL Domain',
190
+ :key => :pl_domain_moztrust,
191
+ :desc => %Q[The pretty (ten point, logarithmically scaled) measure of the mozTrust of the PL domain of the target URL in the Linkscape index],
192
+ },
193
+ :utrp => {
194
+ :name => 'mozTrust',
195
+ :key => :moztrust,
196
+ :desc => %Q[The pretty (ten point, logarithmically scaled) measure of the mozTrust of the target URL in the Linkscape index],
197
+ },
198
+ :ftrr => {
199
+ :name => 'mozTrust of FQ Domain (raw)',
200
+ :key => :fq_domain_moztrust_raw,
201
+ :desc => %Q[The raw (zero to one, linearly scaled) measure of the mozTrust of the FQ domain of the target URL in the Linkscape index],
202
+ },
203
+ :ptrr => {
204
+ :name => 'mozTrust of PL Domain (raw)',
205
+ :key => :pl_domain_moztrust_raw,
206
+ :desc => %Q[The raw (zero to one, linearly scaled) measure of the mozTrust of the PL domain of the target URL in the Linkscape index],
207
+ },
208
+ :utrr => {
209
+ :name => 'mozTrust (raw)',
210
+ :key => :moztrust_raw,
211
+ :desc => %Q[The raw (zero to one, linearly scaled) measure of the mozTrust of the target URL in the Linkscape index],
212
+ },
213
+
214
+ :uemrp => {
215
+ :name => 'External mozRank',
216
+ :key => :external_mozrank,
217
+ :desc => %Q[The pretty (ten point, logarithmically scaled) measure of the mozRank of the target URL due to external links in the Linkscape index],
218
+ },
219
+ :uemrr => {
220
+ :name => 'External mozRank (raw)',
221
+ :key => :external_mozrank_raw,
222
+ :desc => %Q[The raw (zero to one, linearly scaled) measure of the mozRank of the target URL due to external links in the Linkscape index],
223
+ },
224
+ :ufq => {
225
+ :name => 'Fully-Qualified Domain',
226
+ :key => :fq_domain,
227
+ :desc => %Q[The fully qualified domain (FQ domain) as it's identified in the Linkscape index],
228
+ },
229
+ :uifq => {
230
+ :name => 'Number of FQ Domains Linking',
231
+ :key => :fq_domains_linking,
232
+ :desc => %Q[The number of FQ domains with at least one link to the target URL in the Linkscape index],
233
+ },
234
+ :uipl => {
235
+ :name => 'Number of PL Domains Linking',
236
+ :key => :pl_domains_linking,
237
+ :desc => %Q[The number of PL domains with at least one link to the target URL in the Linkscape index],
238
+ },
239
+ :upl => {
240
+ :name => 'Pay-Level Domain',
241
+ :key => :pl_domain,
242
+ :desc => %Q[The pay-level domain (PL domain) as it's identified in the Linkscape index],
243
+ },
244
+
245
+ :upa => {
246
+ :name => 'Page Authority',
247
+ :key => :page_authority,
248
+ :desc => %Q[The pretty (zero to one hundred, logarithmically scaled) page authority of the target URL],
249
+ },
250
+ :pda => {
251
+ :name => 'Domain Authority',
252
+ :key => :domain_authority,
253
+ :desc => %Q[The pretty (zero to one hundred, logarithmically scaled) domain authority of the target URL's PL domain],
254
+ },
255
+ :upar => {
256
+ :name => 'Page Authority (raw)',
257
+ :key => :page_authority_raw,
258
+ :desc => %Q[The raw (zero to one, linearly scaled) page authority of the target URL],
259
+ },
260
+ :pdar => {
261
+ :name => 'Domain Authority (raw)',
262
+ :key => :domain_authority_raw,
263
+ :desc => %Q[The raw (zero to one, linearly scaled) domain authority of the target URL's PL domain],
264
+ },
265
+
266
+ }
267
+ URLResponsePrefixes = {
268
+ nil => :source,
269
+ :lu => :target,
270
+ }
271
+
272
+
273
+ LinkResponseFields = {
274
+ :t => {
275
+ :name => 'Anchor Text',
276
+ :key => :text,
277
+ :desc => %Q[The anchor text of the link, including any markup (e.g. image tags with alt text)],
278
+ },
279
+ :src => {
280
+ :name => 'Source Internal ID',
281
+ :key => :source_internal_id,
282
+ :desc => %Q[Internal ID of the source URL],
283
+ },
284
+ :rid => {
285
+ :name => 'Link Internal ID',
286
+ :key => :internal_id,
287
+ :desc => %Q[Internal ID of the link],
288
+ },
289
+ :tgt => {
290
+ :name => 'Target Internal ID',
291
+ :key => :target_internal_id,
292
+ :desc => %Q[Internal ID of the target URL],
293
+ },
294
+ :f => {
295
+ :name => 'Link Flags',
296
+ :key => :flags,
297
+ :desc => %Q[A bit field indicating link attributes that apply to this link],
298
+ :bitfield => :link,
299
+ },
300
+ :mrr => {
301
+ :name => 'mozRank Passed (raw)',
302
+ :key => :mozrank_raw,
303
+ :desc => %Q[The raw (zero to one, linearly scaled) measure of the mozRank passed to the target of this link],
304
+ },
305
+ :mrp => {
306
+ :name => 'mozRank Passed',
307
+ :key => :mozrank,
308
+ :desc => %Q[The pretty (ten point, logarithmically scaled) measure of the mozRank passed to the target URL in the Linkscape index],
309
+ },
310
+ }
311
+ LinkResponsePrefixes = {
312
+ :l => :link,
313
+ }
314
+
315
+
316
+ AnchorResponseFields = {
317
+ :t => {
318
+ :name => 'Anchor Text',
319
+ :key => :text,
320
+ :desc => %Q[The Anchor Text term or phrase],
321
+ },
322
+ :i => {
323
+ :name => 'Internal Target ID',
324
+ :key => :record_id,
325
+ :desc => %Q[Internal ID of the target URL],
326
+ },
327
+ :iu => {
328
+ :name => 'Internal Pages Linking',
329
+ :key => :internal_pages_linking,
330
+ :desc => %Q[Number of internal pages linking],
331
+ },
332
+ :if => {
333
+ :name => 'Internal Subdomains Linking',
334
+ :key => :internal_subdomains_linking,
335
+ :desc => %Q[Number of internal subdomains linking],
336
+ },
337
+ :eu => {
338
+ :name => 'External Pages Linking',
339
+ :key => :external_pages_linking,
340
+ :desc => %Q[number of external pages linking],
341
+ },
342
+ :ef => {
343
+ :name => 'External Subdomains Linking',
344
+ :key => :external_subdomains_linking,
345
+ :desc => %Q[number of external subdomains linking],
346
+ },
347
+ :ep => {
348
+ :name => 'External Domains Linking',
349
+ :key => :external_domains_linking,
350
+ :desc => %Q[number of external domains linking],
351
+ },
352
+ :imp => {
353
+ :name => 'Internal mozRank',
354
+ :key => :internal_mozrank,
355
+ :desc => %Q[sum of internal mozrank],
356
+ },
357
+ :emp => {
358
+ :name => 'External mozRank',
359
+ :key => :external_mozrank,
360
+ :desc => %Q[sum of external mozrank],
361
+ },
362
+ :f => {
363
+ :name => 'flags',
364
+ :key => :flags,
365
+ :bitfield => :anchor,
366
+ :desc => %Q[Flags],
367
+ },
368
+ }
369
+ AnchorResponsePrefixes = {
370
+ :app => :anchor,
371
+ :apf => :anchor,
372
+ :apu => :anchor,
373
+ :atp => :anchor,
374
+ :atf => :anchor,
375
+ :atu => :anchor,
376
+ }
377
+
378
+
379
+ ResponseFields = {}
380
+
381
+ URLResponsePrefixes.each do |prefix, subject|
382
+ URLResponseFields.each do |k,v|
383
+ v = v.dup.merge(
384
+ :desc => "#{v[:desc]} (#{subject.to_s.capitalize})",
385
+ :source => "#{prefix}#{k}".to_sym,
386
+ :subject => subject
387
+ )
388
+ ResponseFields[v[:source]] = v
389
+ end
390
+ end
391
+ LinkResponsePrefixes.each do |prefix, subject|
392
+ LinkResponseFields.each do |k,v|
393
+ v = v.dup.merge(
394
+ :desc => "#{v[:desc]} (#{subject.to_s.capitalize})",
395
+ :source => "#{prefix}#{k}".to_sym,
396
+ :subject => subject
397
+ )
398
+ ResponseFields[v[:source]] = v
399
+ end
400
+ end
401
+ AnchorResponsePrefixes.each do |prefix, subject|
402
+ AnchorResponseFields.each do |k,v|
403
+ v = v.dup.merge(
404
+ :desc => "#{v[:desc]} (#{subject.to_s.capitalize})",
405
+ :source => "#{prefix}#{k}".to_sym,
406
+ :subject => subject
407
+ )
408
+ ResponseFields[v[:source]] = v
409
+ end
410
+ end
411
+
412
+ ResponseFields.keys.each {|k| ResponseFields[ResponseFields[k][:key]] ||= ResponseFields[k] if ResponseFields[k][:key] }
413
+
414
+ LongestNameLength = ResponseFields.collect{|k,v|v[:name].length}.max
415
+ LongestKeyLength = ResponseFields.collect{|k,v|v[:key].to_s.length}.max
416
+
417
+ end
418
+ end
@@ -0,0 +1,75 @@
1
+ module Linkscape
2
+ module Constants
3
+ module AnchorMetrics
4
+
5
+ RequestBits = {
6
+ :text => {
7
+ :name => 'text',
8
+ :flag => 2,
9
+ :desc => %Q[The anchor text term or phrase]
10
+ },
11
+ :record_id => {
12
+ :name => 'record_id',
13
+ :flag => 4,
14
+ :desc => %Q[Internal record ID of the target]
15
+ },
16
+ :internal_pages_linking => {
17
+ :name => 'Internal Pages Linking',
18
+ :flag => 8,
19
+ :desc => %Q[the number of internal pages linking]
20
+ },
21
+ :internal_subdomains_linking => {
22
+ :name => 'Internal Subdomains Linking',
23
+ :flag => 16,
24
+ :desc => %Q[the number of internal subdomains linking]
25
+ },
26
+ :external_pages_linking => {
27
+ :name => 'External Pages Linking',
28
+ :flag => 32,
29
+ :desc => %Q[the number of external pages linking]
30
+ },
31
+ :external_subdomains_linking => {
32
+ :name => 'External Subdomains Linking',
33
+ :flag => 64,
34
+ :desc => %Q[the number of external subdomains linking]
35
+ },
36
+ :external_domains_linking => {
37
+ :name => 'External Domains Linking',
38
+ :flag => 128,
39
+ :desc => %Q[the number of external domains linking]
40
+ },
41
+ :internal_mozrank => {
42
+ :name => 'Internal mozRank',
43
+ :flag => 256,
44
+ :desc => %Q[the sum of mozRank passed along internal links]
45
+ },
46
+ :external_mozrank => {
47
+ :name => 'External mozRank',
48
+ :flag => 512,
49
+ :desc => %Q[the sum of mozRank passed along external links]
50
+ },
51
+ :flags => {
52
+ :name => 'Flags',
53
+ :flag => 1024,
54
+ :desc => %Q[a flags column]
55
+ },
56
+ }
57
+ RequestBits[:all] = {
58
+ :name => 'All columnts',
59
+ :flag => RequestBits.keys.inject(0) {|sum,k| sum + RequestBits[k][:flag]},
60
+ :desc => %Q[Requests all known columns from the API]
61
+ }
62
+
63
+ ResponseFlags = {
64
+ :alt_text => {
65
+ :name => 'Alt Text',
66
+ :flag => 1,
67
+ :desc => %Q[The anchor text is from the alt text of an image]
68
+ },
69
+ }
70
+ ResponseFlagMap = {}
71
+ ResponseFlags.each {|k,v| ResponseFlagMap[v[:flag]] = k }
72
+
73
+ end
74
+ end
75
+ end