search for standard sites pub-search.waow.tech
search zig blog atproto
11
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: extract base_path from site.standard publication url field

zzstoatzz 8e45d1ed 9e3dd968

+19 -4
+19 -4
backend/src/tap.zig
··· 268 268 std.debug.print("indexed document: {s} [{s}] ({} chars, {} tags)\n", .{ uri, doc.platformName(), doc.content.len, doc.tags.len }); 269 269 } 270 270 271 - fn processPublication(allocator: Allocator, uri: []const u8, did: []const u8, rkey: []const u8, record: json.ObjectMap) !void { 271 + fn processPublication(_: Allocator, uri: []const u8, did: []const u8, rkey: []const u8, record: json.ObjectMap) !void { 272 272 const record_val: json.Value = .{ .object = record }; 273 - const pub_data = zat.json.extractAt(LeafletPublication, allocator, record_val, .{}) catch return; 273 + 274 + // extract required field 275 + const name = zat.json.getString(record_val, "name") orelse return; 276 + const description = zat.json.getString(record_val, "description"); 277 + 278 + // base_path: try leaflet's "base_path", then site.standard's "url" 279 + // url is full URL like "https://devlog.pckt.blog", we need just the host 280 + const base_path = zat.json.getString(record_val, "base_path") orelse 281 + stripUrlScheme(zat.json.getString(record_val, "url")); 282 + 283 + try indexer.insertPublication(uri, did, rkey, name, description, base_path); 284 + std.debug.print("indexed publication: {s} (base_path: {s})\n", .{ uri, base_path orelse "none" }); 285 + } 274 286 275 - try indexer.insertPublication(uri, did, rkey, pub_data.name, pub_data.description, pub_data.base_path); 276 - std.debug.print("indexed publication: {s} (base_path: {s})\n", .{ uri, pub_data.base_path orelse "none" }); 287 + fn stripUrlScheme(url: ?[]const u8) ?[]const u8 { 288 + const u = url orelse return null; 289 + if (mem.startsWith(u8, u, "https://")) return u["https://".len..]; 290 + if (mem.startsWith(u8, u, "http://")) return u["http://".len..]; 291 + return u; 277 292 }