initial commits
parent
0bc2bd3c9d
commit
699d841914
|
@ -0,0 +1,40 @@
|
|||
package frameproto
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
// WriteFrameButton1Action will write the HTML <meta/> 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 <meta/> element:
|
||||
//
|
||||
// <meta property="fc:frame:button:1:action" content="post" />
|
||||
//
|
||||
// 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)
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package frameproto
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
func TestWriteFrameButton1Action(t *testing.T) {
|
||||
|
||||
tests := []struct{
|
||||
Label string
|
||||
Expected string
|
||||
}{
|
||||
{
|
||||
Label: "",
|
||||
Expected: `<meta property="fc:frame:button:1:action" content="" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "something",
|
||||
Expected: `<meta property="fc:frame:button:1:action" content="something" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "Hello world! 🙂",
|
||||
Expected: `<meta property="fc:frame:button:1:action" content="Hello world! 🙂" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "link",
|
||||
Expected: `<meta property="fc:frame:button:1:action" content="link" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "mint",
|
||||
Expected: `<meta property="fc:frame:button:1:action" content="mint" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "post",
|
||||
Expected: `<meta property="fc:frame:button:1:action" content="post" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "post_redirect",
|
||||
Expected: `<meta property="fc:frame:button:1:action" content="post_redirect" />`+"\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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package frameproto
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
// WriteFrameButton2Action will write the HTML <meta/> 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 <meta/> element:
|
||||
//
|
||||
// <meta property="fc:frame:button:2:action" content="post" />
|
||||
//
|
||||
// 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)
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package frameproto
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
func TestWriteFrameButton2Action(t *testing.T) {
|
||||
|
||||
tests := []struct{
|
||||
Label string
|
||||
Expected string
|
||||
}{
|
||||
{
|
||||
Label: "",
|
||||
Expected: `<meta property="fc:frame:button:2:action" content="" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "something",
|
||||
Expected: `<meta property="fc:frame:button:2:action" content="something" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "Hello world! 🙂",
|
||||
Expected: `<meta property="fc:frame:button:2:action" content="Hello world! 🙂" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "link",
|
||||
Expected: `<meta property="fc:frame:button:2:action" content="link" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "mint",
|
||||
Expected: `<meta property="fc:frame:button:2:action" content="mint" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "post",
|
||||
Expected: `<meta property="fc:frame:button:2:action" content="post" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "post_redirect",
|
||||
Expected: `<meta property="fc:frame:button:2:action" content="post_redirect" />`+"\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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package frameproto
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
// WriteFrameButton3Action will write the HTML <meta/> 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 <meta/> element:
|
||||
//
|
||||
// <meta property="fc:frame:button:3:action" content="post" />
|
||||
//
|
||||
// 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)
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package frameproto
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
func TestWriteFrameButton3Action(t *testing.T) {
|
||||
|
||||
tests := []struct{
|
||||
Label string
|
||||
Expected string
|
||||
}{
|
||||
{
|
||||
Label: "",
|
||||
Expected: `<meta property="fc:frame:button:3:action" content="" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "something",
|
||||
Expected: `<meta property="fc:frame:button:3:action" content="something" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "Hello world! 🙂",
|
||||
Expected: `<meta property="fc:frame:button:3:action" content="Hello world! 🙂" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "link",
|
||||
Expected: `<meta property="fc:frame:button:3:action" content="link" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "mint",
|
||||
Expected: `<meta property="fc:frame:button:3:action" content="mint" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "post",
|
||||
Expected: `<meta property="fc:frame:button:3:action" content="post" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "post_redirect",
|
||||
Expected: `<meta property="fc:frame:button:3:action" content="post_redirect" />`+"\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
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package frameproto
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
// WriteFrameButton4Action will write the HTML <meta/> 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 <meta/> element:
|
||||
//
|
||||
// <meta property="fc:frame:button:4:action" content="post" />
|
||||
//
|
||||
// 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)
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package frameproto
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
func TestWriteFrameButton4Action(t *testing.T) {
|
||||
|
||||
tests := []struct{
|
||||
Label string
|
||||
Expected string
|
||||
}{
|
||||
{
|
||||
Label: "",
|
||||
Expected: `<meta property="fc:frame:button:4:action" content="" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "something",
|
||||
Expected: `<meta property="fc:frame:button:4:action" content="something" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "Hello world! 🙂",
|
||||
Expected: `<meta property="fc:frame:button:4:action" content="Hello world! 🙂" />`+"\n",
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
Label: "link",
|
||||
Expected: `<meta property="fc:frame:button:4:action" content="link" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "mint",
|
||||
Expected: `<meta property="fc:frame:button:4:action" content="mint" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "post",
|
||||
Expected: `<meta property="fc:frame:button:4:action" content="post" />`+"\n",
|
||||
},
|
||||
{
|
||||
Label: "post_redirect",
|
||||
Expected: `<meta property="fc:frame:button:4:action" content="post_redirect" />`+"\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
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue