diff --git a/dashing.go b/dashing.go index 1edf295..4e59c38 100644 --- a/dashing.go +++ b/dashing.go @@ -425,6 +425,16 @@ func initDB(name string, fresh bool) (*sql.DB, error) { // texasRanger is... wait for it... a WALKER! func texasRanger(base string, base_depth int, name string, dashing Dashing, db *sql.DB) error { + tx, err := db.Begin() + if err != nil { + fmt.Printf("Error on db begin") + return nil + } + query, err := tx.Prepare(`INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES (?,?,?)`) + if err != nil { + return err + } + defer query.Close() filepath.Walk(base, func(path string, info os.FileInfo, err error) error { fmt.Printf("Reading %s\n", path) if strings.HasPrefix(path, name+".docset") { @@ -460,6 +470,12 @@ func texasRanger(base string, base_depth int, name string, dashing Dashing, db * } return nil }) + err = tx.Commit() + if err != nil { + fmt.Printf("Error on commit") + return nil + } + return nil } @@ -484,8 +500,9 @@ func ignore(src string) bool { func encodeHTMLentities(orig string) string { escaped := new(bytes.Buffer) + escaped.Grow(len(orig)) for _, c := range orig { - if point_to_entity[c] == "" { + if c < 160 || point_to_entity[c] == "" { escaped.WriteRune(c) } else { escaped.WriteString(point_to_entity[c]) @@ -699,88 +716,23 @@ func copyFile(src, dest string) error { } var point_to_entity = map[rune]string{ - 8704: "∀", - 8194: " ", - 8195: " ", - 8709: "∅", - 8711: "∇", - 8712: "∈", - 8201: " ", - 8715: "∋", - 8204: "‌", - 8205: "‍", - 8206: "‎", - 8719: "∏", - 8721: "∑", - 8722: "−", - 8211: "–", - 8212: "—", - 8727: "∗", - 8216: "‘", - 8217: "’", - 8730: "√", - 175: "¯", - 8220: "“", - 8221: "”", - 8222: "„", - 8224: "†", - 8225: "‡", - 8226: "•", - 8230: "…", - 8743: "∧", - 8744: "∨", - 8745: "∩", - 8746: "∪", - 8747: "∫", - 8240: "‰", - 8242: "′", - 8243: "″", - 8756: "∴", - 8713: "∉", - 8249: "‹", - 8250: "›", - 8764: "∼", - // 62: ">", // this is already encoded for us - 8629: "↵", - 9824: "♠", - 8260: "⁄", - 8773: "≅", - 8776: "≈", - 8207: "‏", - 9829: "♥", - 8800: "≠", - 8801: "≡", - 9827: "♣", - 8804: "≤", - 8805: "≥", - 9830: "♦", - // 38: "&", // this is already encoded for us - 8834: "⊂", - 8835: "⊃", - 8836: "⊄", - 8838: "⊆", - 8839: "⊇", - 8853: "⊕", - 8855: "⊗", - 8734: "∞", - 8218: "‚", - 8901: "⋅", + // 34: """, // this is already encoded 160: " ", 161: "¡", 162: "¢", 163: "£", 164: "¤", - 8869: "⊥", 166: "¦", + 165: "¥", 167: "§", 168: "¨", 169: "©", 170: "ª", 171: "«", - 8364: "€", + 172: "¬", 173: "­", 174: "®", - 8733: "∝", + 175: "¯", 176: "°", 177: "±", 178: "²", @@ -810,7 +762,7 @@ var point_to_entity = map[rune]string{ 202: "Ê", 203: "Ë", 204: "Ì", - // 34: """, // this is already encoded + 205: "Í", 206: "Î", 207: "Ï", 208: "Ð", @@ -838,11 +790,11 @@ var point_to_entity = map[rune]string{ 230: "æ", 231: "ç", 232: "è", - 205: "Í", + 233: "é", 234: "ê", 235: "ë", 236: "ì", - 8658: "⇒", + 237: "í", 238: "î", 239: "ï", 240: "ð", @@ -861,41 +813,18 @@ var point_to_entity = map[rune]string{ 253: "ý", 254: "þ", 255: "ÿ", - 172: "¬", - 8968: "⌈", - 8969: "⌉", - 8970: "⌊", - 8971: "⌋", - 8465: "ℑ", - 8472: "℘", - 8476: "ℜ", - 8482: "™", - 732: "˜", - 9002: "⟩", - 8736: "∠", - 402: "ƒ", - 8706: "∂", - 8501: "ℵ", - 710: "ˆ", + 376: "Ÿ", 338: "Œ", 339: "œ", 352: "Š", 353: "š", - 8593: "↑", - // 60: "<", // this is already encoded for us - 8594: "→", - 8707: "∃", - 8595: "↓", - 8254: "‾", - 233: "é", - 376: "Ÿ", - 916: "Δ", - 237: "í", - 8592: "←", + 402: "ƒ", + 710: "ˆ", + 732: "˜", 913: "Α", 914: "Β", 915: "Γ", - 8596: "↔", + 916: "Δ", 917: "Ε", 918: "Ζ", 919: "Η", @@ -941,14 +870,102 @@ var point_to_entity = map[rune]string{ 967: "χ", 968: "ψ", 969: "ω", - 9674: "◊", - 8656: "⇐", 977: "ϑ", 978: "ϒ", - 8659: "⇓", - 8660: "⇔", 982: "ϖ", - 165: "¥", + 8194: " ", + 8195: " ", + 8220: "“", + 8221: "”", + 8222: "„", + 8224: "†", + 8225: "‡", + 8226: "•", + 8230: "…", + 8704: "∀", + 8709: "∅", + 8711: "∇", + 8712: "∈", + 8201: " ", + 8715: "∋", + 8204: "‌", + 8205: "‍", + 8206: "‎", + 8719: "∏", + 8721: "∑", + 8722: "−", + 8211: "–", + 8212: "—", + 8727: "∗", + 8216: "‘", + 8217: "’", + 8730: "√", + 8743: "∧", + 8744: "∨", + 8745: "∩", + 8746: "∪", + 8747: "∫", + 8240: "‰", + 8242: "′", + 8243: "″", + 8756: "∴", + 8713: "∉", + 8249: "‹", + 8250: "›", + 8764: "∼", + // 62: ">", // this is already encoded for us + 8629: "↵", + 9824: "♠", + 8260: "⁄", + 8773: "≅", + 8776: "≈", + 8207: "‏", + 9829: "♥", + 8800: "≠", + 8801: "≡", + 9827: "♣", + 8804: "≤", + 8805: "≥", + 9830: "♦", + // 38: "&", // this is already encoded for us + 8834: "⊂", + 8835: "⊃", + 8836: "⊄", + 8838: "⊆", + 8839: "⊇", + 8853: "⊕", + 8855: "⊗", + 8734: "∞", + 8218: "‚", + 8901: "⋅", + 8869: "⊥", + 8364: "€", + 8733: "∝", + 8658: "⇒", + 8968: "⌈", + 8969: "⌉", + 8970: "⌊", + 8971: "⌋", + 8465: "ℑ", + 8472: "℘", + 8476: "ℜ", + 8482: "™", + 9002: "⟩", + 8736: "∠", + 8706: "∂", + 8501: "ℵ", + 8593: "↑", + // 60: "<", // this is already encoded for us + 8594: "→", + 8707: "∃", + 8595: "↓", + 8254: "‾", + 8592: "←", + 8656: "⇐", 8657: "⇑", + 8659: "⇓", + 8660: "⇔", 9001: "⟨", + 9674: "◊", + 8596: "↔", }