diff --git a/writeframebutton1action.go b/writeframebutton1action.go new file mode 100644 index 0000000..57cfc0d --- /dev/null +++ b/writeframebutton1action.go @@ -0,0 +1,40 @@ +package frameproto + +import ( + "io" +) + +// WriteFrameButton1Action will write the HTML element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:1:action" name-value pair. +// +// For example, this call: +// +// var buttonAction string = "post" +// +// frameproto.WriteFrameButton1Action(writer, aspectRatio) +// +// Would write this HTML element: +// +// +// +// Note that this package provides some constants to use with WriteFrameButton1Action. +// Namely: ButtonActionLink (for "link"), ButtonActionMint (for "mint"), ButtonActionPost (for "post"), and ButtonActionPostRedirect (for "post_redirect"). +// +// Which in code would be used as: +// +// frameproto.WriteFrameButton1Action(writer, frameproto.ButtonActionLink) +// +// And: +// +// frameproto.WriteFrameButton1Action(writer, frameproto.ButtonActionMint) +// +// And: +// +// frameproto.WriteFrameButton1Action(writer, frameproto.ButtonActionPost) +// +// And: +// +// frameproto.WriteFrameButton1Action(writer, frameproto.ButtonActionPostRedirect) +func WriteFrameButton1Action(writer io.Writer, action string) { + const property string = MetaPropertyFrameButton1Action + writeMetaPropertyContent(writer, property, action) +} diff --git a/writeframebutton1action_test.go b/writeframebutton1action_test.go new file mode 100644 index 0000000..0a1ce83 --- /dev/null +++ b/writeframebutton1action_test.go @@ -0,0 +1,73 @@ +package frameproto + +import ( + "testing" + + "strings" +) + +func TestWriteFrameButton1Action(t *testing.T) { + + tests := []struct{ + Label string + Expected string + }{ + { + Label: "", + Expected: ``+"\n", + }, + + + + { + Label: "something", + Expected: ``+"\n", + }, + + + + { + Label: "Hello world! 🙂", + Expected: ``+"\n", + }, + + + + { + Label: "link", + Expected: ``+"\n", + }, + { + Label: "mint", + Expected: ``+"\n", + }, + { + Label: "post", + Expected: ``+"\n", + }, + { + Label: "post_redirect", + Expected: ``+"\n", + }, + } + + for testNumber, test := range tests { + + var buffer strings.Builder + + WriteFrameButton1Action(&buffer, test.Label) + + expected := test.Expected + actual := buffer.String() + + if expected != actual { + t.Errorf("For test #%d, the actual written meta-tag is not what was expected." ,testNumber) + t.Logf("EXPECTED: %s", expected) + t.Logf("ACTUAL: %s", actual) + t.Logf("EXPECTED: %q", expected) + t.Logf("ACTUAL: %q", actual) + t.Logf("LABEL: %q", test.Label) + continue + } + } +} diff --git a/writeframebutton2action.go b/writeframebutton2action.go new file mode 100644 index 0000000..aaba295 --- /dev/null +++ b/writeframebutton2action.go @@ -0,0 +1,40 @@ +package frameproto + +import ( + "io" +) + +// WriteFrameButton2Action will write the HTML element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:2:action" name-value pair. +// +// For example, this call: +// +// var buttonAction string = "post" +// +// frameproto.WriteFrameButton2Action(writer, aspectRatio) +// +// Would write this HTML element: +// +// +// +// Note that this package provides some constants to use with WriteFrameButton2Action. +// Namely: ButtonActionLink (for "link"), ButtonActionMint (for "mint"), ButtonActionPost (for "post"), and ButtonActionPostRedirect (for "post_redirect"). +// +// Which in code would be used as: +// +// frameproto.WriteFrameButton2Action(writer, frameproto.ButtonActionLink) +// +// And: +// +// frameproto.WriteFrameButton2Action(writer, frameproto.ButtonActionMint) +// +// And: +// +// frameproto.WriteFrameButton2Action(writer, frameproto.ButtonActionPost) +// +// And: +// +// frameproto.WriteFrameButton2Action(writer, frameproto.ButtonActionPostRedirect) +func WriteFrameButton2Action(writer io.Writer, action string) { + const property string = MetaPropertyFrameButton2Action + writeMetaPropertyContent(writer, property, action) +} diff --git a/writeframebutton2action_test.go b/writeframebutton2action_test.go new file mode 100644 index 0000000..4f4456e --- /dev/null +++ b/writeframebutton2action_test.go @@ -0,0 +1,73 @@ +package frameproto + +import ( + "testing" + + "strings" +) + +func TestWriteFrameButton2Action(t *testing.T) { + + tests := []struct{ + Label string + Expected string + }{ + { + Label: "", + Expected: ``+"\n", + }, + + + + { + Label: "something", + Expected: ``+"\n", + }, + + + + { + Label: "Hello world! 🙂", + Expected: ``+"\n", + }, + + + + { + Label: "link", + Expected: ``+"\n", + }, + { + Label: "mint", + Expected: ``+"\n", + }, + { + Label: "post", + Expected: ``+"\n", + }, + { + Label: "post_redirect", + Expected: ``+"\n", + }, + } + + for testNumber, test := range tests { + + var buffer strings.Builder + + WriteFrameButton2Action(&buffer, test.Label) + + expected := test.Expected + actual := buffer.String() + + if expected != actual { + t.Errorf("For test #%d, the actual written meta-tag is not what was expected." ,testNumber) + t.Logf("EXPECTED: %s", expected) + t.Logf("ACTUAL: %s", actual) + t.Logf("EXPECTED: %q", expected) + t.Logf("ACTUAL: %q", actual) + t.Logf("LABEL: %q", test.Label) + continue + } + } +} diff --git a/writeframebutton3action.go b/writeframebutton3action.go new file mode 100644 index 0000000..9637438 --- /dev/null +++ b/writeframebutton3action.go @@ -0,0 +1,40 @@ +package frameproto + +import ( + "io" +) + +// WriteFrameButton3Action will write the HTML element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:3:action" name-value pair. +// +// For example, this call: +// +// var buttonAction string = "post" +// +// frameproto.WriteFrameButton3Action(writer, aspectRatio) +// +// Would write this HTML element: +// +// +// +// Note that this package provides some constants to use with WriteFrameButton3Action. +// Namely: ButtonActionLink (for "link"), ButtonActionMint (for "mint"), ButtonActionPost (for "post"), and ButtonActionPostRedirect (for "post_redirect"). +// +// Which in code would be used as: +// +// frameproto.WriteFrameButton3Action(writer, frameproto.ButtonActionLink) +// +// And: +// +// frameproto.WriteFrameButton3Action(writer, frameproto.ButtonActionMint) +// +// And: +// +// frameproto.WriteFrameButton3Action(writer, frameproto.ButtonActionPost) +// +// And: +// +// frameproto.WriteFrameButton3Action(writer, frameproto.ButtonActionPostRedirect) +func WriteFrameButton3Action(writer io.Writer, action string) { + const property string = MetaPropertyFrameButton3Action + writeMetaPropertyContent(writer, property, action) +} diff --git a/writeframebutton3action_test.go b/writeframebutton3action_test.go new file mode 100644 index 0000000..68cb0da --- /dev/null +++ b/writeframebutton3action_test.go @@ -0,0 +1,73 @@ +package frameproto + +import ( + "testing" + + "strings" +) + +func TestWriteFrameButton3Action(t *testing.T) { + + tests := []struct{ + Label string + Expected string + }{ + { + Label: "", + Expected: ``+"\n", + }, + + + + { + Label: "something", + Expected: ``+"\n", + }, + + + + { + Label: "Hello world! 🙂", + Expected: ``+"\n", + }, + + + + { + Label: "link", + Expected: ``+"\n", + }, + { + Label: "mint", + Expected: ``+"\n", + }, + { + Label: "post", + Expected: ``+"\n", + }, + { + Label: "post_redirect", + Expected: ``+"\n", + }, + } + + for testNumber, test := range tests { + + var buffer strings.Builder + + WriteFrameButton3Action(&buffer, test.Label) + + expected := test.Expected + actual := buffer.String() + + if expected != actual { + t.Errorf("For test #%d, the actual written meta-tag is not what was expected." ,testNumber) + t.Logf("EXPECTED: %s", expected) + t.Logf("ACTUAL: %s", actual) + t.Logf("EXPECTED: %q", expected) + t.Logf("ACTUAL: %q", actual) + t.Logf("LABEL: %q", test.Label) + continue + } + } +} diff --git a/writeframebutton4action.go b/writeframebutton4action.go new file mode 100644 index 0000000..e6b81e8 --- /dev/null +++ b/writeframebutton4action.go @@ -0,0 +1,40 @@ +package frameproto + +import ( + "io" +) + +// WriteFrameButton4Action will write the HTML element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:4:action" name-value pair. +// +// For example, this call: +// +// var buttonAction string = "post" +// +// frameproto.WriteFrameButton4Action(writer, aspectRatio) +// +// Would write this HTML element: +// +// +// +// Note that this package provides some constants to use with WriteFrameButton4Action. +// Namely: ButtonActionLink (for "link"), ButtonActionMint (for "mint"), ButtonActionPost (for "post"), and ButtonActionPostRedirect (for "post_redirect"). +// +// Which in code would be used as: +// +// frameproto.WriteFrameButton4Action(writer, frameproto.ButtonActionLink) +// +// And: +// +// frameproto.WriteFrameButton4Action(writer, frameproto.ButtonActionMint) +// +// And: +// +// frameproto.WriteFrameButton4Action(writer, frameproto.ButtonActionPost) +// +// And: +// +// frameproto.WriteFrameButton4Action(writer, frameproto.ButtonActionPostRedirect) +func WriteFrameButton4Action(writer io.Writer, action string) { + const property string = MetaPropertyFrameButton4Action + writeMetaPropertyContent(writer, property, action) +} diff --git a/writeframebutton4action_test.go b/writeframebutton4action_test.go new file mode 100644 index 0000000..bacecd4 --- /dev/null +++ b/writeframebutton4action_test.go @@ -0,0 +1,73 @@ +package frameproto + +import ( + "testing" + + "strings" +) + +func TestWriteFrameButton4Action(t *testing.T) { + + tests := []struct{ + Label string + Expected string + }{ + { + Label: "", + Expected: ``+"\n", + }, + + + + { + Label: "something", + Expected: ``+"\n", + }, + + + + { + Label: "Hello world! 🙂", + Expected: ``+"\n", + }, + + + + { + Label: "link", + Expected: ``+"\n", + }, + { + Label: "mint", + Expected: ``+"\n", + }, + { + Label: "post", + Expected: ``+"\n", + }, + { + Label: "post_redirect", + Expected: ``+"\n", + }, + } + + for testNumber, test := range tests { + + var buffer strings.Builder + + WriteFrameButton4Action(&buffer, test.Label) + + expected := test.Expected + actual := buffer.String() + + if expected != actual { + t.Errorf("For test #%d, the actual written meta-tag is not what was expected." ,testNumber) + t.Logf("EXPECTED: %s", expected) + t.Logf("ACTUAL: %s", actual) + t.Logf("EXPECTED: %q", expected) + t.Logf("ACTUAL: %q", actual) + t.Logf("LABEL: %q", test.Label) + continue + } + } +}