Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does the embed plugin work? There is no render github link #189

Closed
woodchen-ink opened this issue Jul 30, 2024 · 21 comments
Closed

How does the embed plugin work? There is no render github link #189

woodchen-ink opened this issue Jul 30, 2024 · 21 comments
Assignees

Comments

@woodchen-ink
Copy link

image
So far it looks like this, I thought it was going to be the same as discourse
image

@woodchen-ink
Copy link
Author

Even the youtube link cannot be parsed correctly, for example: https://www.youtube.com/watch?v=VINZeWNhgIU. I don’t understand how to call this plug-in. The background options are already turned on.

image

@robinv8
Copy link
Contributor

robinv8 commented Jul 30, 2024

What is the version of Answer?

Regarding GitHub, currently, only GitHub gist is supported.

image

image

@woodchen-ink
Copy link
Author

What is the version of Answer?

Regarding GitHub, currently, only GitHub gist is supported.

image

image

1.3.6 , i will try again later

@robinv8
Copy link
Contributor

robinv8 commented Jul 31, 2024

My Answer version is also 1.3.6, so can you check what the Embed plugin version is?

@woodchen-ink
Copy link
Author

My Answer version is also 1.3.6, so can you check what the Embed plugin version is?

My plugin is up to date, and I found that I modified the code of embed_controller.go, because the site was migrated once, and the error: [interface {} is string, not bool], caused the page to not load properly. Then I fixed the error with the help of claude 3.5, but I didn't test if the embedding worked, I will restore the code and test again. I suspect it's because my MySQL version was originally 5.7 and the new server is MySQL 8.0, which caused this error

@woodchen-ink
Copy link
Author

image

Error log

2024-07-31 12:58:56.528	ERROR	runtime/panic.go:890	http: panic serving 172.18.0.1:47068: interface conversion: interface {} is string, not bool
goroutine 504 [running]:
net/http.(*conn).serve.func1()
	/usr/local/go/src/net/http/server.go:1850 +0xb8
panic({0x1168c60, 0x4002b98e40})
	/usr/local/go/src/runtime/panic.go:890 +0x260
github.com/apache/incubator-answer/internal/controller.(*EmbedController).GetEmbedConfig.func2({0xe2dc790a2968, 0x400054ee98})
	/go/src/github.com/apache/incubator-answer/answer_build3308615552/vendor/github.com/apache/incubator-answer/internal/controller/embed_controller.go:58 +0x24c
github.com/apache/incubator-answer/plugin.MakePlugin[...].func1()
	/go/src/github.com/apache/incubator-answer/answer_build3308615552/vendor/github.com/apache/incubator-answer/plugin/plugin.go:134 +0x150
github.com/apache/incubator-answer/internal/controller.(*EmbedController).GetEmbedConfig(0x4003121050?, 0x4002c86200?)
	/go/src/github.com/apache/incubator-answer/answer_build3308615552/vendor/github.com/apache/incubator-answer/internal/controller/embed_controller.go:53 +0x138
github.com/gin-gonic/gin.(*Context).Next(...)
	/go/src/github.com/apache/incubator-answer/answer_build3308615552/vendor/github.com/gin-gonic/gin/context.go:174
github.com/anargu/gin-brotli.Brotli.func1(0x4002c86200)
	/go/src/github.com/apache/incubator-answer/answer_build3308615552/vendor/github.com/anargu/gin-brotli/gin_brotli.go:71 +0x1d8
github.com/gin-gonic/gin.(*Context).Next(...)
	/go/src/github.com/apache/incubator-answer/answer_build3308615552/vendor/github.com/gin-gonic/gin/context.go:174
github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0x400010ed00, 0x4002c86200)
	/go/src/github.com/apache/incubator-answer/answer_build3308615552/vendor/github.com/gin-gonic/gin/gin.go:620 +0x560
github.com/gin-gonic/gin.(*Engine).ServeHTTP(0x400010ed00, {0x3bf9d88?, 0x4003674460}, 0x4001c70100)
	/go/src/github.com/apache/incubator-answer/answer_build3308615552/vendor/github.com/gin-gonic/gin/gin.go:576 +0x1fc
net/http.serverHandler.ServeHTTP({0x4002dfe540?}, {0x3bf9d88, 0x4003674460}, 0x4001c70100)
	/usr/local/go/src/net/http/server.go:2947 +0x2cc
net/http.(*conn).serve(0x400040ff40, {0x3bfaa98, 0x4001bcf710})
	/usr/local/go/src/net/http/server.go:1991 +0x544
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:3102 +0x43c

In the database, it's like this

image


I don't understand why this plugin isn't working

@woodchen-ink
Copy link
Author

mysql 8.2.0

@robinv8
Copy link
Contributor

robinv8 commented Aug 1, 2024

Check whether the plugin field enabled returned by the /answer/api/v1/plugin/status interface is true, and then observe whether the Chrome console reports an error.

Also, are all embeds not displayed, or just some of them?

@woodchen-ink
Copy link
Author

{"code":200,"reason":"base.success","msg":"Success.","data":[{"slug_name":"basic_reviewer","enabled":true},
{"slug_name":"akismet_reviewer","enabled":true},{"slug_name":"basic_captcha","enabled":true},
{"slug_name":"s3_storage","enabled":true},{"slug_name":"algolia-search","enabled":true},
{"slug_name":"redis_cache","enabled":true},{"slug_name":"basic_embed","enabled":true},
{"slug_name":"chart_editor","enabled":true},{"slug_name":"formula_editor","enabled":true},
{"slug_name":"github_connector","enabled":true},{"slug_name":"google_connector","enabled":true}]}

image
image
image
image

@woodchen-ink
Copy link
Author

Once this plugin is enabled, all question pages cannot be displayed properly

@robinv8
Copy link
Contributor

robinv8 commented Aug 1, 2024

After turning off the plugin, other interfaces are normal? I turn on the plugin and visit q58.org to try it.

@woodchen-ink
Copy link
Author

After closing the plugin, other interfaces are normal? Please open the plugin and visit q58.org to try it.

After closing this plugin, all functions are normal. Do you need me to open it now for you to check?

@robinv8
Copy link
Contributor

robinv8 commented Aug 1, 2024

After closing the plugin, other interfaces are normal? Please open the plugin and visit q58.org to try it.

After closing this plugin, all functions are normal. Do you need me to open it now for you to check?

Yes.

@woodchen-ink
Copy link
Author

After closing the plugin, other interfaces are normal? Please open the plugin and visit q58.org to try it.

After closing this plugin, all functions are normal. Do you need me to open it now for you to check?

Yes.

OK, I open it already

@woodchen-ink
Copy link
Author

If you have checked it, please leave a message, thank you. Otherwise, the content of the article cannot be accessed normally.

@robinv8
Copy link
Contributor

robinv8 commented Aug 1, 2024

Related to the /answer/api/v1/embed/config interface, which returns the enabled embed type, for example:

{
    "code": 200,
    "reason": "base.success",
    "msg": "Success.",
    "data": [
        {
            "platform": "CodePen",
            "enable": true
        },
        {
            "platform": "Dropbox",
            "enable": true
        },
        {
            "platform": "Excalidraw",
            "enable": true
        },
        {
            "platform": "Figma",
            "enable": true
        },
        {
            "platform": "GithubGist",
            "enable": true
        },
        {
            "platform": "JSFiddle",
            "enable": true
        },
        {
            "platform": "Loom",
            "enable": true
        },
        {
            "platform": "Twitter",
            "enable": true
        },
        {
            "platform": "YouTube",
            "enable": true
        }
    ]
}

I asked the plugin developer to check this issue.

@woodchen-ink
Copy link
Author

Thank you very much

@woodchen-ink
Copy link
Author

I would like to add some information: I am running on an ARM machine, which may be related to the platform
image

@kumfo
Copy link
Member

kumfo commented Aug 1, 2024

Sorry, this is a bug.

When defining the Embed plugin, the data structure is consistent with the Basic plugin, resulting in other installed plugins being recognized as the Embed plugin.

I will make corrections in the next version.

If you need to use it urgently and install it from source code, you can temporarily manually make changes to the source code before compiling and installing it.

Change the code location:

Code Line

The code changed:

func (c *EmbedController) GetEmbedConfig(ctx *gin.Context) {
	resp := make([]*schema.GetEmbedOptionResp, 0)

	_ = plugin.CallConfig(func(fn plugin.Config) error {
		if fn.Info().SlugName == "basic_embed" {
			for _, field := range fn.ConfigFields() {
				resp = append(resp, &schema.GetEmbedOptionResp{
					Platform: field.Name,
					Enable:   field.Value.(bool),
				})
			}
			return nil
		}
		return nil
	})
	handler.HandleResponse(ctx, nil, resp)
}

@woodchen-ink
Copy link
Author

Thank you very much, I will modify the source code, compile and install it, and I will test it again. It may take 2 hours.

I will leave a message again after testing.

@woodchen-ink
Copy link
Author

image
image
This plugin works, thank you for your support

kumfo added a commit that referenced this issue Aug 19, 2024
… conflict. It will be resolved when Answer v1.4.0 release.
@kumfo kumfo closed this as completed in 223be5a Aug 21, 2024
robinv8 pushed a commit that referenced this issue Sep 4, 2024
… conflict. It will be resolved when Answer v1.4.0 release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants