-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from Covve/feature/supportV3PhotoParams
Feature/support v3 photo params
- Loading branch information
Showing
8 changed files
with
701 additions
and
505 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 |
---|---|---|
@@ -1,12 +1,20 @@ | ||
`0.1.0` 2020-03-05 | ||
--------------------------------------- | ||
## `1.1.1` | ||
|
||
- Add encoding to list of params to support PHOTO V3 and more | ||
|
||
## `1.1.0` | ||
|
||
- Add nickname | ||
|
||
## `0.1.0` 2020-03-05 | ||
|
||
- Add url field to vcard and formatter | ||
- Version bump | ||
|
||
`0.0.5` 2019-01-19 | ||
--------------------------------------- | ||
## `0.0.5` 2019-01-19 | ||
|
||
- `Fixed` gitignore preventing js files from being published | ||
|
||
`0.0.4` 2019-01-19 | ||
--------------------------------------- | ||
## `0.0.4` 2019-01-19 | ||
|
||
- `Added` photo field |
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
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 |
---|---|---|
|
@@ -12,50 +12,56 @@ import { Formatter, VCard } from "../src/index"; | |
const vcard = new VCard(); | ||
|
||
vcard | ||
.addFirstName('John') | ||
.addLastName('Doe') | ||
.addLastName('Foo') | ||
.addPrefixName('Dr.') | ||
.addEmail('[email protected]') | ||
.addEmail('[email protected]') | ||
.setUID('urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6') | ||
.setRevision('1') | ||
.addNotes('Jdoe\'s personal notes') | ||
.addNickname('Jonny') | ||
.addPhone('0-123456', { type: 'home', value: 'text'}) | ||
.addPhone('tel:123-456-789', { type: 'work', pref: '1', value: 'uri' }) | ||
.addTitle('Chief support officer') | ||
.addOrganization('Smithsonian Inc.', ['North America']) | ||
.addOrganization('Jdoe co.', []) | ||
.addAddress('123 High Str.', '', '', 'AB-123', 'USA', { type: 'home', label: 'Doe Residence, 123 High Str., AB-123, US'}) | ||
.addRole('Support manager') | ||
.addUrl('www.smithsonian.com'); | ||
|
||
.addFirstName("John") | ||
.addLastName("Doe") | ||
.addLastName("Foo") | ||
.addPrefixName("Dr.") | ||
.addEmail("[email protected]") | ||
.addEmail("[email protected]") | ||
.setUID("urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6") | ||
.setRevision("1") | ||
.addNotes("Jdoe's personal notes") | ||
.addNickname("Jonny") | ||
.addPhone("0-123456", { type: "home", value: "text" }) | ||
.addPhone("tel:123-456-789", { type: "work", pref: "1", value: "uri" }) | ||
.addTitle("Chief support officer") | ||
.addOrganization("Smithsonian Inc.", ["North America"]) | ||
.addOrganization("Jdoe co.", []) | ||
.addAddress("123 High Str.", "", "", "AB-123", "USA", { | ||
type: "home", | ||
label: "Doe Residence, 123 High Str., AB-123, US", | ||
}) | ||
.addRole("Support manager") | ||
.addUrl("www.smithsonian.com") | ||
.addPhoto( | ||
"MIICajCCAdOgAwIBAgICBEUwDQYJKoZIhvcNAQEEBQAwdzELMAkGA1UEBhMCVVMxLDAqBgNVBAoTI05ldHNjYXBlIENvbW11bmljYXRpb25zIENvcnBvcmF0aW9uMRwwGgYDVQQLExNJbmZvcm1hdGlvbi", | ||
{ type: "image/jpeg", encoding: "b" } | ||
); | ||
|
||
// set the path | ||
const path = "test.vcard"; | ||
|
||
// let it do it's thang | ||
Export(vcard, path); | ||
|
||
|
||
/**** HELPER ****/ | ||
|
||
function Export(vcard: VCard, filepath: string, ext = '.vcard') { | ||
function Export(vcard: VCard, filepath: string, ext = ".vcard") { | ||
const formatter = new Formatter(); | ||
const vcardString = formatter.format(vcard.toJSON()); | ||
if(!vcardString){ | ||
console.error('Empty string returned. Please check that your vcard is well defined'); | ||
if (!vcardString) { | ||
console.error( | ||
"Empty string returned. Please check that your vcard is well defined" | ||
); | ||
return; | ||
} | ||
|
||
if ((filepath.indexOf('.vcard') !== -1) || (filepath.indexOf('.vcf'))) | ||
writeFile(filepath, vcardString, errorHandler ); | ||
else | ||
writeFile(filepath + ext, vcardString, errorHandler); | ||
if (filepath.indexOf(".vcard") !== -1 || filepath.indexOf(".vcf")) | ||
writeFile(filepath, vcardString, errorHandler); | ||
else writeFile(filepath + ext, vcardString, errorHandler); | ||
} | ||
|
||
function errorHandler(err){ | ||
function errorHandler(err) { | ||
if (err) throw err; | ||
console.log('file written successfully'); | ||
console.log("file written successfully"); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.